Blame view
ios/GameSDKDemo/letsgameDemo/VKSdk.framework/Versions/A/Headers/VKRequest.h
8.37 KB
23a302b86
![]() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
// // VKRequest.h // // Copyright (c) 2014 VK.com // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #import <Foundation/Foundation.h> #import "VKResponse.h" #import "VKApiConst.h" #import "VKObject.h" /** Creates and debug timings for VKRequest */ @interface VKRequestTiming : VKObject /// Date of request start @property(nonatomic, strong) NSDate *startTime; /// Date of request finished (after all operations) @property(nonatomic, strong) NSDate *finishTime; /// Interval of networking load time @property(nonatomic, assign) NSTimeInterval loadTime; /// Interval of model parsing time @property(nonatomic, assign) NSTimeInterval parseTime; /// Total time, as difference (finishTime - startTime) @property(nonatomic, readonly) NSTimeInterval totalTime; @end /** Class for execution API-requests */ @interface VKRequest : VKObject /// Specify progress for uploading or downloading. Useless for text requests (because gzip encoding bytesTotal will always return -1) @property(nonatomic, copy) void (^progressBlock)(VKProgressType progressType, long long bytesLoaded, long long bytesTotal); /// Specify completion block for request @property(nonatomic, copy) void (^completeBlock)(VKResponse *response); /// Specity error (HTTP or API) block for request. @property(nonatomic, copy) void (^errorBlock)(NSError *error); /// Specify attempts for request loading if caused HTTP-error. 0 for infinite @property(nonatomic, assign) int attempts; /// Use HTTPS requests (by default is YES). If http-request is impossible (user denied no https access), SDK will load https version @property(nonatomic, assign) BOOL secure; /// Sets current system language as default for API data @property(nonatomic, assign) BOOL useSystemLanguage; /// Set to NO if you don't need automatic model parsing @property(nonatomic, assign) BOOL parseModel; /// Set to YES if you need info about request timing @property(nonatomic, assign) BOOL debugTiming; /// Timeout for this request @property(nonatomic, assign) NSInteger requestTimeout; /// Sets dispatch queue for returning result @property(nonatomic, assign) dispatch_queue_t responseQueue; /// Set to YES if you need to freeze current thread for response @property(nonatomic, assign) BOOL waitUntilDone; /// Returns method for current request, e.g. users.get @property(nonatomic, readonly) NSString *methodName; /// Returns HTTP-method for current request @property(nonatomic, readonly) NSString *httpMethod; /// Returns list of method parameters (without common parameters) @property(nonatomic, readonly) NSDictionary *methodParameters; /// Returns http operation that can be enqueued @property(nonatomic, readonly) NSOperation *executionOperation; /// Returns info about request timings @property(nonatomic, readonly) VKRequestTiming *requestTiming; /// Return YES if current request was started @property(nonatomic, readonly) BOOL isExecuting; /// Return YES if current request was started @property(nonatomic, copy) NSArray *preventThisErrorsHandling; ///------------------------------- /// @name Preparing requests ///------------------------------- /** Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods @param method API-method name, e.g. audio.get @param parameters method parameters @param httpMethod HTTP method for execution, e.g. GET, POST @return Complete request object for execute or configure method @deprecated Use requestWithMethod:andParameters: instead */ + (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters andHttpMethod:(NSString *)httpMethod __deprecated; /** Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods @param method API-method name, e.g. audio.get @param parameters method parameters @return Complete request object for execute or configure method */ + (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters; /** Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods @param method API-method name, e.g. audio.get @param parameters method parameters @param httpMethod HTTP method for execution, e.g. GET, POST @param modelClass class for automatic parse @return Complete request object for execute or configure method @deprecated Use requestWithMethod:andParameters:modelClass: instead */ + (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters andHttpMethod:(NSString *)httpMethod classOfModel:(Class)modelClass __deprecated; /** Creates new request with parameters. See documentation for methods here https://vk.com/dev/methods @param method API-method name, e.g. audio.get @param parameters method parameters @param modelClass class for automatic parse @return Complete request object for execute or configure method */ + (instancetype)requestWithMethod:(NSString *)method andParameters:(NSDictionary *)parameters modelClass:(Class)modelClass; /** Creates new request for upload image to url @param url url for upload, which was received from special methods @param photoObjects VKPhoto object describes photos @return Complete request object for execute */ + (instancetype)photoRequestWithPostUrl:(NSString *)url withPhotos:(NSArray *)photoObjects; /** Prepares NSURLRequest and returns prepared url request for current vkrequest @return Prepared request used for loading */ - (NSURLRequest *)getPreparedRequest; ///------------------------------- /// @name Execution ///------------------------------- /** Executes that request, and returns result to blocks @param completeBlock called if there were no HTTP or API errors, returns execution result. @param errorBlock called immediately if there was API error, or after <b>attempts</b> tries if there was an HTTP error */ - (void)executeWithResultBlock:(void (^)(VKResponse *response))completeBlock errorBlock:(void (^)(NSError *error))errorBlock; /** Register current request for execute after passed request, if passed request is successful. If it's not, errorBlock will be called. @param request after which request must be called that request @param completeBlock called if there were no HTTP or API errors, returns execution result. @param errorBlock called immediately if there was API error, or after <b>attempts</b> tries if there was an HTTP error */ - (void)executeAfter:(VKRequest *)request withResultBlock:(void (^)(VKResponse *response))completeBlock errorBlock:(void (^)(NSError *error))errorBlock; /** Starts loading of prepared request. You can use it instead of executeWithResultBlock */ - (void)start; /** Creates loading operation for this request */ - (NSOperation *)createExecutionOperation; /** Repeats this request with initial parameters and blocks. Used attempts will be set to 0. */ - (void)repeat; /** Cancel current request. Result will be not passed. errorBlock will be called with error code */ - (void)cancel; ///------------------------------- /// @name Operating with parameters ///------------------------------- /** Adds additional parameters to that request @param extraParameters parameters supposed to be added */ - (void)addExtraParameters:(NSDictionary *)extraParameters; /// Specify language for API request - (void)setPreferredLang:(NSString *)lang; @end |