hank
2017-06-14 3f9b5125cd79f60e878a3f93708d1254048fd1fb
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
78
79
80
81
82
83
84
85
86
87
88
89
90
//
//  TWTRRequestSigningOperation.h
//  TwitterKit
//
//  Created by Chase Latta on 6/24/15.
//  Copyright (c) 2015 Twitter. All rights reserved.
//
 
#import <Foundation/Foundation.h>
 
@class TWTRGuestSession;
@class TWTRNetworkingPipelinePackage;
@class TWTRSession;
 
NS_ASSUME_NONNULL_BEGIN
 
/**
 * The block that is executed after the request is signed.
 */
typedef void (^TWTRRequestSigningSuccessBlock)(NSURLRequest *signedRequest);
 
/**
 * The block that is executed if the operation is cancelled.
 */
typedef void (^TWTRRequestSigningCancelBlock)(void);
 
typedef TWTRGuestSession *_Nonnull (^TWTRGuestSessionProvider)(void);
typedef TWTRSession *_Nonnull (^TWTRUserSessionProvider)(void);
 
/**
 * Do not instantiate this operation directly. Use one of the concrete
 * subclasses instead.
 */
@interface TWTRRequestSigningOperation : NSOperation
 
@property (nonatomic, readonly) TWTRNetworkingPipelinePackage *networkingPackage;
 
/**
 * Creates a signing operation.
 *
 * @param package the pipeline package that holds the request to sign
 * @param successBlock a block to execute when the package is signed.
 * @param cancelBlock a block to execute when the operation is cancelled.
 *
 * @note the callback blocks will execute on arbitrary queues.
 */
- (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock;
 
- (instancetype)init NS_UNAVAILABLE;
 
/**
 * Subclasses must implement this method to return the signed request.
 */
- (NSURLRequest *)signRequest:(NSURLRequest *)request;
 
@end
 
@interface TWTRGuestRequestSigningOperation : TWTRRequestSigningOperation
 
/**
 * Creates a guest signing operation.
 *
 * @param package the pipeline package that holds the request to sign.
 * @param sessionProvider a block that will execute to provide the session at invocation time.
 * @param successBlock a block to execute when the package is signed.
 * @param cancelBlock a block to execute when the operation is cancelled.
 *
 * @note the callback blocks will execute on arbitrary queues.
 */
- (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package sessionProvider:(TWTRGuestSessionProvider)sessionProvider success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock;
 
@end
 
@interface TWTRUserRequestSigningOperation : TWTRRequestSigningOperation
 
/**
 * Creates a user signing operation.
 *
 * @param package the pipeline package that holds the request to sign.
 * @param sessionProvider a block that will execute to provide the session at invocation time.
 * @param successBlock a block to execute when the package is signed.
 * @param cancelBlock a block to execute when the operation is cancelled.
 *
 * @note the callback blocks will execute on arbitrary queues.
 */
- (instancetype)initWithPackage:(TWTRNetworkingPipelinePackage *)package sessionProvider:(TWTRUserSessionProvider)sessionProvider success:(nullable TWTRRequestSigningSuccessBlock)successBlock cancel:(nullable TWTRRequestSigningCancelBlock)cancelBlock;
 
@end
 
NS_ASSUME_NONNULL_END