14
14
//!
15
15
//! ## Response: [CreatedClip]
16
16
//!
17
- //! Send the request to receive the response with [`HelixClient::req_get ()`](helix::HelixClient::req_get ).
17
+ //! Send the request to receive the response with [`HelixClient::req_post ()`](helix::HelixClient::req_post ).
18
18
//!
19
19
//! ```rust, no_run
20
20
//! use twitch_api::helix::{self, clips::create_clip};
25
25
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
26
26
//! # let token = twitch_oauth2::UserToken::from_existing(&client, token, None, None).await?;
27
27
//! let request = create_clip::CreateClipRequest::broadcaster_id("1234");
28
- //! let response: Vec<create_clip::CreatedClip> = client.req_get(request, &token).await?.data;
28
+ //! let body = helix::EmptyBody;
29
+ //! let response: create_clip::CreatedClip = client.req_post(request, body, &token).await?.data;
29
30
//! # Ok(())
30
31
//! # }
31
32
//! ```
32
33
//!
33
- //! You can also get the [`http::Request`] with [`request.create_request(&token, &client_id)`](helix::RequestGet ::create_request)
34
+ //! You can also get the [`http::Request`] with [`request.create_request(&token, &client_id)`](helix::RequestPost ::create_request)
34
35
//! and parse the [`http::Response`] with [`CreateClipRequest::parse_response(None, &request.get_uri(), response)`](CreateClipRequest::parse_response)
35
36
36
37
use super :: * ;
37
- use helix:: RequestGet ;
38
+ use helix:: RequestPost ;
38
39
39
40
/// Query Parameters for [Create Clip](super::create_clip)
40
41
///
@@ -48,7 +49,7 @@ pub struct CreateClipRequest<'a> {
48
49
#[ cfg_attr( feature = "typed-builder" , builder( setter( into) ) ) ]
49
50
#[ cfg_attr( feature = "deser_borrow" , serde( borrow = "'a" ) ) ]
50
51
pub broadcaster_id : Cow < ' a , types:: UserIdRef > ,
51
- /// A Boolean value that determines whether the API captures the clip at the moment the viewer requests it or after a delay. If false (default), Twitch captures the clip at the moment the viewer requests it (this is the same clip experience as the Twitch UX). If true, Twitch adds a delay before capturing the clip
52
+ /// A Boolean value that determines whether the API captures the clip at the moment the viewer requests it or after a delay. If false (default), Twitch captures the clip at the moment the viewer requests it (this is the same clip experience as the Twitch UX). If true, Twitch adds a delay before capturing the clip (this basically shifts the capture window to the right slightly).
52
53
#[ cfg_attr( feature = "typed-builder" , builder( default , setter( into) ) ) ]
53
54
pub has_delay : Option < bool > ,
54
55
}
@@ -76,22 +77,38 @@ impl<'a> CreateClipRequest<'a> {
76
77
#[ cfg_attr( feature = "deny_unknown_fields" , serde( deny_unknown_fields) ) ]
77
78
#[ non_exhaustive]
78
79
pub struct CreatedClip {
79
- /// ID of the created clip.
80
+ /// An ID that uniquely identifies the clip.
80
81
pub id : types:: ClipId ,
81
82
/// A URL that you can use to edit the clip’s title, identify the part of the clip to publish, and publish the clip.
83
+ ///
84
+ /// The URL is valid for up to 24 hours or until the clip is published, whichever comes first.
82
85
pub edit_url : String ,
83
86
}
84
87
85
88
impl Request for CreateClipRequest < ' _ > {
86
- type Response = Vec < CreatedClip > ;
89
+ type Response = CreatedClip ;
87
90
88
91
const PATH : & ' static str = "clips" ;
89
92
#[ cfg( feature = "twitch_oauth2" ) ]
90
93
const SCOPE : twitch_oauth2:: Validator =
91
94
twitch_oauth2:: validator![ twitch_oauth2:: Scope :: ClipsEdit ] ;
92
95
}
93
96
94
- impl RequestGet for CreateClipRequest < ' _ > { }
97
+ impl RequestPost for CreateClipRequest < ' _ > {
98
+ type Body = helix:: EmptyBody ;
99
+
100
+ fn parse_inner_response (
101
+ request : Option < Self > ,
102
+ uri : & http:: Uri ,
103
+ response : & str ,
104
+ status : http:: StatusCode ,
105
+ ) -> Result < helix:: Response < Self , <Self as Request >:: Response > , helix:: HelixRequestPostError >
106
+ where
107
+ Self : Sized ,
108
+ {
109
+ helix:: parse_single_return ( request, uri, response, status)
110
+ }
111
+ }
95
112
96
113
#[ cfg( test) ]
97
114
#[ test]
0 commit comments