Module twitch_api2::helix::webhooks::hub[][src]

This is supported on crate feature helix only.

Subscribe to or unsubscribe from events for a specified topic. subscribe-tounsubscribe-from-events

Accessing the endpoint

Request: WebhookHubRequest

To use this endpoint, construct a WebhookHubRequest with the WebhookHubRequest::builder() method.

use twitch_api2::helix::webhooks::hub;
let request = hub::WebhookHubRequest::<twitch_api2::helix::webhooks::topics::users::UserFollowsTopic>::builder()
    .build();

Body: WebhookHubBody

We also need to provide a body to the request containing what we want to change.

let body = hub::WebhookHubBody::builder()
    .callback("https://example.com/this-is-a-callback")
    .lease_seconds(864000)
    .mode(hub::WebhookSubscriptionMode::Subscribe)
    .secret("12233213890390".to_string())
    .topic(twitch_api2::helix::webhooks::topics::users::UserFollowsTopic::builder().from_id(1336.to_string()).build())
    .build();

Response: WebhookHub

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

use twitch_api2::helix::{self, webhooks::hub};
let request = hub::WebhookHubRequest::builder()
    .build();
let body = hub::WebhookHubBody::builder()
    .callback("https://example.com/this-is-a-callback")
    .lease_seconds(864000)
    .mode(hub::WebhookSubscriptionMode::Subscribe)
    .secret("12233213890390".to_string())
    .topic(twitch_api2::helix::webhooks::topics::users::UserFollowsTopic::builder().from_id(1336.to_string()).build())
    .build();
let response: hub::WebhookHub = client.req_post(request, body, &token).await?.data;

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

Structs

WebhookHubBody

Body Parameters for Subscribe to/Unsubscribe From Events

WebhookHubRequest

Query Parameters for Subscribe to/Unsubscribe From Events

Enums

WebhookHub

Return Values for Subscribe to/Unsubscribe From Events

WebhookSubscriptionMode

Subscription mode