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 |
|
a0a843
|
18 |
#import <Foundation/Foundation.h> |
H |
19 |
#import <TwitterCore/TWTRNetworkingPipeline.h> |
|
20 |
|
|
21 |
@class TWTRNetworkingPipelinePackage; |
|
22 |
|
|
23 |
NS_ASSUME_NONNULL_BEGIN |
|
24 |
|
|
25 |
typedef NS_ENUM(NSInteger, TWTRNetworkingPipelineQueueType) { |
|
26 |
/** |
|
27 |
* Queues that depend on having a valid guest session |
|
28 |
*/ |
|
29 |
TWTRNetworkingPipelineQueueTypeGuest, |
|
30 |
|
|
31 |
/** |
|
32 |
* Queues that depend on having a valid user session |
|
33 |
*/ |
|
34 |
TWTRNetworkingPipelineQueueTypeUser |
|
35 |
}; |
|
36 |
|
|
37 |
@interface TWTRNetworkingPipelineQueue : NSObject |
|
38 |
|
|
39 |
/** |
|
40 |
* Returns the type that this queue was initialized with. |
|
41 |
*/ |
|
42 |
@property (nonatomic, readonly) TWTRNetworkingPipelineQueueType queueType; |
|
43 |
|
|
44 |
/** |
|
45 |
* A response validator to use to validate network responses. |
|
46 |
*/ |
|
47 |
@property (nonatomic, readonly, nullable) id<TWTRNetworkingResponseValidating> responseValidator; |
|
48 |
|
|
49 |
/** |
|
50 |
* Initializes the queue witht the given type. |
|
51 |
* |
|
52 |
* @param type The type of queue to initialize |
|
53 |
* @param session The NSURLSession to send requests with |
|
54 |
* @param responseValidator The response validator to use for this queue |
|
55 |
*/ |
|
56 |
- (instancetype)initWithType:(TWTRNetworkingPipelineQueueType)type URLSession:(NSURLSession *)session responseValidator:(nullable id<TWTRNetworkingResponseValidating>)responseValidator NS_DESIGNATED_INITIALIZER; |
|
57 |
|
|
58 |
/** |
|
59 |
* Convenience initializer to make a new guest pipeline. |
|
60 |
*/ |
|
61 |
+ (instancetype)guestPipelineQueueWithURLSession:(NSURLSession *)session responseValidator:(nullable id<TWTRNetworkingResponseValidating>)responseValidator; |
|
62 |
|
|
63 |
/** |
|
64 |
* Convenience initializer to make a new user pipeline. |
|
65 |
*/ |
|
66 |
+ (instancetype)userPipelineQueueWithURLSession:(NSURLSession *)session responseValidator:(nullable id<TWTRNetworkingResponseValidating>)responseValidator; |
|
67 |
|
|
68 |
/** |
|
69 |
* Enqueues a package for processing. |
|
70 |
* @return an NSProgress object which can be used to cancel the request. |
|
71 |
*/ |
|
72 |
- (NSProgress *)enqueuePipelinePackage:(TWTRNetworkingPipelinePackage *)package; |
|
73 |
|
|
74 |
/** |
|
75 |
* Use -[TWTRNetworkingPipelineQueue initWithType:URLSession:] instead. |
|
76 |
*/ |
|
77 |
- (instancetype)init NS_UNAVAILABLE; |
|
78 |
|
|
79 |
@end |
|
80 |
|
|
81 |
NS_ASSUME_NONNULL_END |