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