hank
2017-06-14 a0a84333e64f1e94ae9d0f69545037c60e781842
commit | author | age
a0a843 1 //
H 2 //  TWTRNetworkingPipelineQueue.h
3 //  TwitterKit
4 //
5 //  Created by Chase Latta on 6/23/15.
6 //  Copyright (c) 2015 Twitter. All rights reserved.
7 //
8
9 #import <Foundation/Foundation.h>
10 #import <TwitterCore/TWTRNetworkingPipeline.h>
11
12 @class TWTRNetworkingPipelinePackage;
13
14 NS_ASSUME_NONNULL_BEGIN
15
16 typedef NS_ENUM(NSInteger, TWTRNetworkingPipelineQueueType) {
17     /**
18      * Queues that depend on having a valid guest session
19      */
20     TWTRNetworkingPipelineQueueTypeGuest,
21
22     /**
23      * Queues that depend on having a valid user session
24      */
25     TWTRNetworkingPipelineQueueTypeUser
26 };
27
28 @interface TWTRNetworkingPipelineQueue : NSObject
29
30 /**
31  * Returns the type that this queue was initialized with.
32  */
33 @property (nonatomic, readonly) TWTRNetworkingPipelineQueueType queueType;
34
35 /**
36  * A response validator to use to validate network responses.
37  */
38 @property (nonatomic, readonly, nullable) id<TWTRNetworkingResponseValidating> responseValidator;
39
40 /**
41  * Initializes the queue witht the given type.
42  *
43  * @param type The type of queue to initialize
44  * @param session The NSURLSession to send requests with
45  * @param responseValidator The response validator to use for this queue
46  */
47 - (instancetype)initWithType:(TWTRNetworkingPipelineQueueType)type URLSession:(NSURLSession *)session responseValidator:(nullable id<TWTRNetworkingResponseValidating>)responseValidator NS_DESIGNATED_INITIALIZER;
48
49 /**
50  * Convenience initializer to make a new guest pipeline.
51  */
52 + (instancetype)guestPipelineQueueWithURLSession:(NSURLSession *)session responseValidator:(nullable id<TWTRNetworkingResponseValidating>)responseValidator;
53
54 /**
55  * Convenience initializer to make a new user pipeline.
56  */
57 + (instancetype)userPipelineQueueWithURLSession:(NSURLSession *)session responseValidator:(nullable id<TWTRNetworkingResponseValidating>)responseValidator;
58
59 /**
60  * Enqueues a package for processing.
61  * @return an NSProgress object which can be used to cancel the request.
62  */
63 - (NSProgress *)enqueuePipelinePackage:(TWTRNetworkingPipelinePackage *)package;
64
65 /**
66  * Use -[TWTRNetworkingPipelineQueue initWithType:URLSession:] instead.
67  */
68 - (instancetype)init NS_UNAVAILABLE;
69
70 @end
71
72 NS_ASSUME_NONNULL_END