Available on crate feature helix only.
Expand description

Starts a commercial on a specified channel. start-commercial

Accessing the endpoint

Request: StartCommercialRequest

To use this endpoint, construct a StartCommercialRequest with the StartCommercialRequest::new() method.

use twitch_api2::helix::channels::start_commercial;
let request = start_commercial::StartCommercialRequest::new();

Body: StartCommercialBody

We also need to provide a body to the request specifying length of commercial and where to start it.

let body = start_commercial::StartCommercialBody::builder()
    .broadcaster_id("1234".to_string())
    .length(twitch_api2::types::CommercialLength::Length90)
    .build();

Response: StartCommercialRequest

Send the request to receive the response with HelixClient::req_post().

use twitch_api2::helix::{self, channels::start_commercial};
let request = start_commercial::StartCommercialRequest::new();
let body = start_commercial::StartCommercialBody::builder()
    .broadcaster_id("1234".to_string())
    .length(twitch_api2::types::CommercialLength::Length90)
    .build();
let response: Vec<start_commercial::StartCommercial> = client.req_post(request, body, &token).await?.data;

You can also get the http::Request with request.create_request(body, &token, &client_id) and parse the http::Response with StartCommercialRequest::parse_response(None, &request.get_uri(), response)

Structs