1212//! # }
1313//! ```
1414use std:: marker:: PhantomData ;
15- use std:: borrow:: BorrowMut ;
1615use std:: cell:: RefCell ;
16+ use std:: borrow:: BorrowMut ;
17+ use std:: default:: Default ;
1718
1819use hyper;
1920use oauth2;
@@ -45,6 +46,10 @@ impl<'a, C, NC, A> YouTube<C, NC, A>
4546 pub fn videos ( & ' a self ) -> videos:: Service < ' a , C , NC , A > {
4647 videos:: Service :: new ( & self )
4748 }
49+
50+ pub fn channel_sections ( & ' a self ) -> ChannelSectionMethodsBuilder < ' a , C , NC , A > {
51+ ChannelSectionMethodsBuilder { hub : & self }
52+ }
4853}
4954
5055
@@ -77,4 +82,81 @@ mod tests {
7782
7883 let v = yt. videos ( ) . insert ( "snippet" , & Default :: default ( ) ) ;
7984 }
80- }
85+
86+ #[ test] fn helper_test ( ) {
87+ use std:: default:: Default ;
88+ use oauth2:: { Authenticator , DefaultAuthenticatorDelegate , ApplicationSecret , MemoryStorage } ;
89+
90+ let secret: ApplicationSecret = Default :: default ( ) ;
91+ let auth = Authenticator :: new ( & secret, DefaultAuthenticatorDelegate ,
92+ hyper:: Client :: new ( ) ,
93+ <MemoryStorage as Default >:: default ( ) , None ) ;
94+ let mut hub = YouTube :: new ( hyper:: Client :: new ( ) , auth) ;
95+ let result = hub. channel_sections ( ) . insert ( )
96+ . delegate ( & mut <DefaultDelegate as Default >:: default ( ) )
97+ . doit ( ) ;
98+ }
99+ }
100+
101+ pub struct ChannelSectionMethodsBuilder < ' a , C , NC , A >
102+ where NC : ' a ,
103+ C : ' a ,
104+ A : ' a , {
105+
106+ hub : & ' a YouTube < C , NC , A > ,
107+ }
108+
109+ impl < ' a , C , NC , A > ChannelSectionMethodsBuilder < ' a , C , NC , A > {
110+
111+ /// Create a builder to help you perform the following task:
112+ ///
113+ /// Adds a channelSection for the authenticated user's channel.
114+ pub fn insert ( & self ) -> ChannelSectionInsertMethodBuilder < ' a , C , NC , A > {
115+ ChannelSectionInsertMethodBuilder {
116+ hub : self . hub ,
117+ _delegate : Default :: default ( ) ,
118+ }
119+ }
120+ }
121+
122+ pub struct ChannelSectionInsertMethodBuilder < ' a , C , NC , A >
123+ where NC : ' a ,
124+ C : ' a ,
125+ A : ' a , {
126+
127+ hub : & ' a YouTube < C , NC , A > ,
128+ _delegate : Option < & ' a mut Delegate > ,
129+ }
130+
131+
132+ impl < ' a , C , NC , A > ChannelSectionInsertMethodBuilder < ' a , C , NC , A > where NC : hyper:: net:: NetworkConnector , C : BorrowMut < hyper:: Client < NC > > + ' a , A : oauth2:: GetToken {
133+
134+ /// Perform the operation you have build so far.
135+ /// TODO: Build actual call
136+ pub fn doit ( mut self ) -> ( ) {
137+ if self . _delegate . is_some ( ) {
138+ self . _delegate . as_mut ( ) . unwrap ( ) . connection_error ( hyper:: HttpError :: HttpStatusError ) ;
139+ }
140+ }
141+
142+ pub fn delegate ( mut self , new_value : & ' a mut Delegate ) -> ChannelSectionInsertMethodBuilder < ' a , C , NC , A > {
143+ self . _delegate = Some ( new_value) ;
144+ self
145+ }
146+
147+ }
148+
149+ pub trait Delegate {
150+
151+ /// Called whenever there is an HttpError, usually if there are network problems.
152+ ///
153+ /// Return retry information.
154+ fn connection_error ( & mut self , hyper:: HttpError ) -> oauth2:: Retry {
155+ oauth2:: Retry :: Abort
156+ }
157+ }
158+
159+ #[ derive( Default ) ]
160+ pub struct DefaultDelegate ;
161+
162+ impl Delegate for DefaultDelegate { }
0 commit comments