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