xref: /expo/ios/Exponent/Kernel/Api/EXApiV2Client.h (revision 00b26551)
1 // Copyright 2015-present 650 Industries. All rights reserved.
2 
3 @import Foundation;
4 
5 #import "EXApiV2Result.h"
6 
7 NS_ASSUME_NONNULL_BEGIN
8 
9 FOUNDATION_EXPORT NSString * const EXApiErrorDomain;
10 
11 typedef NS_ENUM(NSInteger, EXApiErrorCode) {
12   EXApiErrorCodeMalformedRequestBody,
13   EXApiErrorCodeEmptyResponse,
14   EXApiErrorCodeMalformedJson,
15   EXApiErrorCodeMalformedResponse,
16   EXApiErrorCodeApiError,
17 };
18 
19 FOUNDATION_EXPORT NSString * const EXApiResponseKey;
20 FOUNDATION_EXPORT NSString * const EXApiResultKey;
21 FOUNDATION_EXPORT NSString * const EXApiHttpStatusCodeKey;
22 FOUNDATION_EXPORT NSString * const EXApiErrorCodeKey;
23 FOUNDATION_EXPORT NSString * const EXApiErrorStackKey;
24 
25 typedef void (^EXApiV2CompletionHandler)(EXApiV2Result * _Nullable response,
26                                          NSError * _Nullable error);
27 
28 @interface EXApiV2Client : NSObject
29 
30 + (instancetype)sharedClient;
31 
32 - (instancetype)init NS_UNAVAILABLE;
33 - (instancetype)initWithUrlSession:(NSURLSession *)urlSession NS_DESIGNATED_INITIALIZER;
34 
35 - (nullable NSURLSessionTask *)callRemoteMethod:(NSString *)method
36                                       arguments:(nullable NSDictionary *)arguments
37                                      httpMethod:(NSString *)httpMethod
38                               completionHandler:(EXApiV2CompletionHandler)handler;
39 
40 @end
41 
42 NS_ASSUME_NONNULL_END
43