mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-13 04:10:50 +00:00
185 lines
5.0 KiB
Plaintext
185 lines
5.0 KiB
Plaintext
#import <Foundation/Foundation.h>
|
|
#import <ISO8601/ISO8601.h>
|
|
#import <AFNetworking/AFNetworking.h>
|
|
#import "{{classPrefix}}JSONResponseSerializer.h"
|
|
#import "{{classPrefix}}JSONRequestSerializer.h"
|
|
#import "{{classPrefix}}QueryParamCollection.h"
|
|
#import "{{classPrefix}}Configuration.h"
|
|
#import "{{classPrefix}}ResponseDeserializer.h"
|
|
#import "{{classPrefix}}Sanitizer.h"
|
|
#import "{{classPrefix}}Logger.h"
|
|
|
|
{{>licenceInfo}}
|
|
|
|
{{#models}}{{#model}}#import "{{classname}}.h"
|
|
{{/model}}{{/models}}
|
|
{{^models}}#import "{{classPrefix}}Object.h"{{/models}}
|
|
|
|
@class {{classPrefix}}Configuration;
|
|
|
|
/**
|
|
* A key for `NSError` user info dictionaries.
|
|
*
|
|
* The corresponding value is the parsed response body for an HTTP error.
|
|
*/
|
|
extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
|
|
|
@interface {{classPrefix}}ApiClient : AFHTTPSessionManager
|
|
|
|
@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
|
|
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
|
@property(nonatomic, readonly) NSOperationQueue* queue;
|
|
|
|
/// In order to ensure the HTTPResponseHeaders are correct, it is recommended to initialize one {{classPrefix}}ApiClient instance per thread.
|
|
@property(nonatomic, readonly) NSDictionary* HTTPResponseHeaders;
|
|
|
|
@property(nonatomic, strong) id<{{classPrefix}}ResponseDeserializer> responseDeserializer;
|
|
|
|
@property(nonatomic, strong) id<{{classPrefix}}Sanitizer> sanitizer;
|
|
/**
|
|
* Clears Cache
|
|
*/
|
|
+(void)clearCache;
|
|
|
|
/**
|
|
* Turns on cache
|
|
*
|
|
* @param enabled If the cached is enable, must be `YES` or `NO`
|
|
*/
|
|
+(void)setCacheEnabled:(BOOL) enabled;
|
|
|
|
/**
|
|
* Gets the request queue size
|
|
*
|
|
* @return The size of `queuedRequests` static variable.
|
|
*/
|
|
+(NSUInteger)requestQueueSize;
|
|
|
|
/**
|
|
* Sets the client unreachable
|
|
*
|
|
* @param state off line state, must be `YES` or `NO`
|
|
*/
|
|
+(void) setOfflineState:(BOOL) state;
|
|
|
|
/**
|
|
* Gets if the client is unreachable
|
|
*
|
|
* @return The client offline state
|
|
*/
|
|
+(BOOL) getOfflineState;
|
|
|
|
/**
|
|
* Sets the client reachability, this may be overridden by the reachability manager if reachability changes
|
|
*
|
|
* @param The client reachability.
|
|
*/
|
|
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status;
|
|
|
|
/**
|
|
* Gets the client reachability
|
|
*
|
|
* @return The client reachability.
|
|
*/
|
|
+(AFNetworkReachabilityStatus) getReachabilityStatus;
|
|
|
|
/**
|
|
* Gets the next request id
|
|
*
|
|
* @return The next executed request id.
|
|
*/
|
|
+(NSNumber*) nextRequestId;
|
|
|
|
/**
|
|
* Generates request id and add it to the queue
|
|
*
|
|
* @return The next executed request id.
|
|
*/
|
|
+(NSNumber*) queueRequest;
|
|
|
|
/**
|
|
* Removes request id from the queue
|
|
*
|
|
* @param requestId The request which will be removed.
|
|
*/
|
|
+(void) cancelRequest:(NSNumber*)requestId;
|
|
|
|
/**
|
|
* Customizes the behavior when the reachability changed
|
|
*
|
|
* @param changeBlock The block will be executed when the reachability changed.
|
|
*/
|
|
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock;
|
|
|
|
/**
|
|
* Sets the api client reachability strategy
|
|
*/
|
|
- (void)configureCacheReachibility;
|
|
|
|
/**
|
|
* Sets header for request
|
|
*
|
|
* @param value The header value
|
|
* @param forKey The header key
|
|
*/
|
|
-(void)setHeaderValue:(NSString*) value
|
|
forKey:(NSString*) forKey;
|
|
|
|
/**
|
|
* Updates header parameters and query parameters for authentication
|
|
*
|
|
* @param headers The header parameter will be updated, passed by pointer to pointer.
|
|
* @param querys The query parameters will be updated, passed by pointer to pointer.
|
|
* @param authSettings The authentication names NSArray.
|
|
*/
|
|
- (void) updateHeaderParams:(NSDictionary **)headers
|
|
queryParams:(NSDictionary **)querys
|
|
WithAuthSettings:(NSArray *)authSettings;
|
|
|
|
/**
|
|
* Performs request
|
|
*
|
|
* @param path Request url.
|
|
* @param method Request method.
|
|
* @param pathParams Request path parameters.
|
|
* @param queryParams Request query parameters.
|
|
* @param body Request body.
|
|
* @param headerParams Request header parameters.
|
|
* @param authSettings Request authentication names.
|
|
* @param requestContentType Request content-type.
|
|
* @param responseContentType Response content-type.
|
|
* @param completionBlock The block will be executed when the request completed.
|
|
*
|
|
* @return The request id.
|
|
*/
|
|
-(NSNumber*) requestWithPath:(NSString*) path
|
|
method:(NSString*) method
|
|
pathParams:(NSDictionary *) pathParams
|
|
queryParams:(NSDictionary*) queryParams
|
|
formParams:(NSDictionary *) formParams
|
|
files:(NSDictionary *) files
|
|
body:(id) body
|
|
headerParams:(NSDictionary*) headerParams
|
|
authSettings:(NSArray *) authSettings
|
|
requestContentType:(NSString*) requestContentType
|
|
responseContentType:(NSString*) responseContentType
|
|
responseType:(NSString *) responseType
|
|
completionBlock:(void (^)(id, NSError *))completionBlock;
|
|
|
|
/**
|
|
* Custom security policy
|
|
*
|
|
* @return AFSecurityPolicy
|
|
*/
|
|
- (AFSecurityPolicy *) customSecurityPolicy;
|
|
|
|
/**
|
|
* {{classPrefix}}Configuration return sharedConfig
|
|
*
|
|
* @return {{classPrefix}}Configuration
|
|
*/
|
|
- ({{classPrefix}}Configuration*) configuration;
|
|
|
|
|
|
@end
|