hank
2017-06-14 a0a84333e64f1e94ae9d0f69545037c60e781842
commit | author | age
a0a843 1 //
H 2 //  TWTRRequestSigningOperation.h
3 //  TwitterKit
4 //
5 //  Created by Chase Latta on 6/24/15.
6 //  Copyright (c) 2015 Twitter. All rights reserved.
7 //
8
9 #import <Foundation/Foundation.h>
10
11 @class TWTRGuestSession;
12 @class TWTRNetworkingPipelinePackage;
13 @class TWTRSession;
14
15 NS_ASSUME_NONNULL_BEGIN
16
17 /**
18  * The block that is executed after the request is signed.
19  */
20 typedef void (^TWTRRequestSigningSuccessBlock)(NSURLRequest *signedRequest);
21
22 /**
23  * The block that is executed if the operation is cancelled.
24  */
25 typedef void (^TWTRRequestSigningCancelBlock)(void);
26
27 typedef TWTRGuestSession *_Nonnull (^TWTRGuestSessionProvider)(void);
28 typedef TWTRSession *_Nonnull (^TWTRUserSessionProvider)(void);
29
30 /**
31  * Do not instantiate this operation directly. Use one of the concrete
32  * subclasses instead.
33  */
34 @interface TWTRRequestSigningOperation : NSOperation
35
36 @property (nonatomic, readonly) TWTRNetworkingPipelinePackage *networkingPackage;
37
38 /**
39  * Creates a signing operation.
40  *
41  * @param package the pipeline package that holds the request to sign
42  * @param successBlock a block to execute when the package is signed.
43  * @param cancelBlock a block to execute when the operation is cancelled.
44  *
45  * @note the callback blocks will execute on arbitrary queues.
46  */
47 - (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock;
48
49 - (instancetype)init NS_UNAVAILABLE;
50
51 /**
52  * Subclasses must implement this method to return the signed request.
53  */
54 - (NSURLRequest *)signRequest:(NSURLRequest *)request;
55
56 @end
57
58 @interface TWTRGuestRequestSigningOperation : TWTRRequestSigningOperation
59
60 /**
61  * Creates a guest signing operation.
62  *
63  * @param package the pipeline package that holds the request to sign.
64  * @param sessionProvider a block that will execute to provide the session at invocation time.
65  * @param successBlock a block to execute when the package is signed.
66  * @param cancelBlock a block to execute when the operation is cancelled.
67  *
68  * @note the callback blocks will execute on arbitrary queues.
69  */
70 - (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package sessionProvider:(TWTRGuestSessionProvider)sessionProvider success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock;
71
72 @end
73
74 @interface TWTRUserRequestSigningOperation : TWTRRequestSigningOperation
75
76 /**
77  * Creates a user signing operation.
78  *
79  * @param package the pipeline package that holds the request to sign.
80  * @param sessionProvider a block that will execute to provide the session at invocation time.
81  * @param successBlock a block to execute when the package is signed.
82  * @param cancelBlock a block to execute when the operation is cancelled.
83  *
84  * @note the callback blocks will execute on arbitrary queues.
85  */
86 - (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package sessionProvider:(TWTRUserSessionProvider)sessionProvider success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock;
87
88 @end
89
90 NS_ASSUME_NONNULL_END