Module twitch_api2::eventsub[][src]

Expand description

Holds serializable EventSub stuff

Use CreateEventSubSubscription to subscribe to an event according to the EventSub guide. Parse the response payload text with Payload::parse or Payload::parse_http.

Examples

You’ve used CreateEventSubSubscription to create a subscription for user.authorization.revoke, after verifying your callback accordingly you will then get events sent to the callback

To parse these, use Payload::parse

use twitch_api2::eventsub::Payload;
let payload = r#"{
    "subscription": {
        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
        "type": "user.authorization.revoke",
        "version": "1",
        "status": "enabled",
        "cost": 0,
        "condition": {
            "client_id": "crq72vsaoijkc83xx42hz6i37"
        },
         "transport": {
            "method": "webhook",
            "callback": "https://example.com/webhooks/callback"
        },
        "created_at": "2019-11-16T10:11:12.123Z"
    },
    "event": {
        "client_id": "crq72vsaoijkc83xx42hz6i37",
        "user_id": "1337",
        "user_login": "cool_user",
        "user_name": "Cool_User"
    }
}"#;

let payload = Payload::parse(payload).unwrap();
match payload {
    Payload::UserAuthorizationRevokeV1(p) => {
        println!("User with id `{}` has revoked access to client `{}`",
            p.event.user_id,
            p.event.client_id
        )
    }
    _ => { panic!() }
}

Modules

Subscription types regarding channels

Subscription types regarding streams

Subscription types regarding users

Structs

General information about an EventSub subscription.

Metadata about the subscription.

Notification received

Transport setting for event notification

Transport response on event notification

Verification Request

Enums

Event name

Subscription payload. Received on events. Enumerates all possible NotificationPayloads

Errors that can happen when parsing payload

Subscription request status

Transport method

Traits

An EventSub subscription.