commit | author | age
|
655e66
|
1 |
/* |
H |
2 |
* Copyright (C) 2017 Twitter, Inc. |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
* |
|
16 |
*/ |
|
17 |
|
|
18 |
/** |
|
19 |
This header is private to the Twitter Core SDK and not exposed for public SDK consumption |
|
20 |
*/ |
a0a843
|
21 |
|
H |
22 |
#import <Foundation/Foundation.h> |
|
23 |
|
|
24 |
@class TWTRGuestSession; |
|
25 |
@class TWTRNetworkingPipelinePackage; |
|
26 |
@class TWTRSession; |
|
27 |
|
|
28 |
NS_ASSUME_NONNULL_BEGIN |
|
29 |
|
|
30 |
/** |
|
31 |
* The block that is executed after the request is signed. |
|
32 |
*/ |
|
33 |
typedef void (^TWTRRequestSigningSuccessBlock)(NSURLRequest *signedRequest); |
|
34 |
|
|
35 |
/** |
|
36 |
* The block that is executed if the operation is cancelled. |
|
37 |
*/ |
|
38 |
typedef void (^TWTRRequestSigningCancelBlock)(void); |
|
39 |
|
|
40 |
typedef TWTRGuestSession *_Nonnull (^TWTRGuestSessionProvider)(void); |
|
41 |
typedef TWTRSession *_Nonnull (^TWTRUserSessionProvider)(void); |
|
42 |
|
|
43 |
/** |
|
44 |
* Do not instantiate this operation directly. Use one of the concrete |
|
45 |
* subclasses instead. |
|
46 |
*/ |
|
47 |
@interface TWTRRequestSigningOperation : NSOperation |
|
48 |
|
|
49 |
@property (nonatomic, readonly) TWTRNetworkingPipelinePackage *networkingPackage; |
|
50 |
|
|
51 |
/** |
|
52 |
* Creates a signing operation. |
|
53 |
* |
|
54 |
* @param package the pipeline package that holds the request to sign |
|
55 |
* @param successBlock a block to execute when the package is signed. |
|
56 |
* @param cancelBlock a block to execute when the operation is cancelled. |
|
57 |
* |
|
58 |
* @note the callback blocks will execute on arbitrary queues. |
|
59 |
*/ |
|
60 |
- (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock; |
|
61 |
|
|
62 |
- (instancetype)init NS_UNAVAILABLE; |
|
63 |
|
|
64 |
/** |
|
65 |
* Subclasses must implement this method to return the signed request. |
|
66 |
*/ |
|
67 |
- (NSURLRequest *)signRequest:(NSURLRequest *)request; |
|
68 |
|
|
69 |
@end |
|
70 |
|
|
71 |
@interface TWTRGuestRequestSigningOperation : TWTRRequestSigningOperation |
|
72 |
|
|
73 |
/** |
|
74 |
* Creates a guest signing operation. |
|
75 |
* |
|
76 |
* @param package the pipeline package that holds the request to sign. |
|
77 |
* @param sessionProvider a block that will execute to provide the session at invocation time. |
|
78 |
* @param successBlock a block to execute when the package is signed. |
|
79 |
* @param cancelBlock a block to execute when the operation is cancelled. |
|
80 |
* |
|
81 |
* @note the callback blocks will execute on arbitrary queues. |
|
82 |
*/ |
|
83 |
- (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package sessionProvider:(TWTRGuestSessionProvider)sessionProvider success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock; |
|
84 |
|
|
85 |
@end |
|
86 |
|
|
87 |
@interface TWTRUserRequestSigningOperation : TWTRRequestSigningOperation |
|
88 |
|
|
89 |
/** |
|
90 |
* Creates a user signing operation. |
|
91 |
* |
|
92 |
* @param package the pipeline package that holds the request to sign. |
|
93 |
* @param sessionProvider a block that will execute to provide the session at invocation time. |
|
94 |
* @param successBlock a block to execute when the package is signed. |
|
95 |
* @param cancelBlock a block to execute when the operation is cancelled. |
|
96 |
* |
|
97 |
* @note the callback blocks will execute on arbitrary queues. |
|
98 |
*/ |
|
99 |
- (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package sessionProvider:(TWTRUserSessionProvider)sessionProvider success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock; |
|
100 |
|
|
101 |
@end |
|
102 |
|
|
103 |
NS_ASSUME_NONNULL_END |