1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use crate::types;
use super::*;
use serde::{Deserialize, Serialize};
impl Topic for UserFollowsTopic {
type Helix = crate::helix::users::GetUsersFollowsRequest;
const PATH: &'static str = "users/follows";
#[cfg(feature = "twitch_oauth2")]
const SCOPE: &'static [twitch_oauth2::Scope] = &[];
}
#[derive(PartialEq, typed_builder::TypedBuilder, Deserialize, Serialize, Clone, Debug)]
pub struct UserFollowsTopic {
#[serde(default = "one")]
#[builder(setter(skip), default = 1)]
first: u32,
#[builder(setter(into), default)]
pub from_id: Option<types::UserId>,
#[builder(setter(into), default)]
pub to_id: Option<types::UserId>,
}
#[inline(always)]
const fn one() -> u32 { 1 }
#[test]
fn test_topic() {
use crate::helix::webhooks::hub::*;
use crate::helix::*;
let req = WebhookHubRequest::<UserFollowsTopic>::builder().build();
let body = WebhookHubBody::builder()
.callback("https://example.com/this-is-a-callback")
.lease_seconds(864000)
.mode(WebhookSubscriptionMode::Subscribe)
.secret("12233213890390".to_string())
.topic(
UserFollowsTopic::builder()
.from_id(1336.to_string())
.build(),
)
.build();
req.create_request(body, "token", "clientid").unwrap();
let data = br#"
{
"data": [
{
"from_id": "1336",
"from_name": "ebi",
"from_login": "EBI",
"to_id": "1337",
"to_name": "oliver0823nagy",
"followed_at": "2017-08-22T22:55:24Z"
}
]
}
"#
.to_vec();
let http_response = http::Response::builder().body(data).unwrap();
dbg!(UserFollowsTopic::parse_payload(http_response).unwrap());
}