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 "TWTRNetworkingPipeline.h" |
|
24 |
|
|
25 |
NS_ASSUME_NONNULL_BEGIN |
|
26 |
|
|
27 |
/** |
|
28 |
Abstraction around the Twitter REST API networking response validation and errors to handle various |
|
29 |
quirks of the API. |
|
30 |
*/ |
|
31 |
@interface TWTRAPINetworkErrorsShim : NSObject |
|
32 |
|
|
33 |
/** |
|
34 |
* @param response response from the API request |
|
35 |
* @param responseData data from the request response |
|
36 |
*/ |
|
37 |
- (instancetype)initWithHTTPResponse:(NSURLResponse *)response responseData:(NSData *)responseData NS_DESIGNATED_INITIALIZER; |
|
38 |
|
655e66
|
39 |
- (instancetype)init NS_UNAVAILABLE; |
a0a843
|
40 |
/** |
H |
41 |
* Validates the error response while taking into account some Twitter-specific quirks. |
|
42 |
* |
|
43 |
* @return the normalized error if there was something to surface from either the HTTP response |
|
44 |
* or API response |
|
45 |
*/ |
|
46 |
|
|
47 |
- (nullable NSError *)validate; |
|
48 |
|
|
49 |
@end |
|
50 |
|
|
51 |
/// This class just simply wraps the TWTRAPINetworkErrorsShim class so that we can use |
|
52 |
/// something that conforms to the TWTRNetworkingResponseValidating. It simply creates |
|
53 |
/// an instance of TWTRAPINetworkErrorsShim for each validation call. Eventually, the |
|
54 |
/// TWTRAPINetworkErrorsShim class can be removed or hidden. |
|
55 |
@interface TWTRAPIResponseValidator : NSObject <TWTRNetworkingResponseValidating> |
|
56 |
@end |
|
57 |
|
|
58 |
NS_ASSUME_NONNULL_END |