/Ref_Classes/AFNetworkingQueue.m

https://gitlab.com/pqhuy1987/Mahaikum · Objective C · 431 lines · 280 code · 86 blank · 65 comment · 3 complexity · ad82e42cb9b16e3b3ab0ca7b0933b0e1 MD5 · raw file

  1. //
  2. // AFNetworkingQueue.m
  3. // SampleProject
  4. //
  5. // Created by Rupen Makhecha on 19/01/13.
  6. //
  7. //
  8. #import "AFNetworkingQueue.h"
  9. #import "AFHTTPClient.h"
  10. @implementation AFNetworkingQueue
  11. @synthesize queue;
  12. +(AFNetworkingQueue*) sharedSingleton {
  13. static AFNetworkingQueue* theInstance = nil;
  14. if (theInstance == nil) {
  15. theInstance = [[self alloc] init];
  16. [theInstance initQueue];
  17. }
  18. return theInstance;
  19. }
  20. -(void)initQueue {
  21. self.queue = [[NSOperationQueue alloc] init];
  22. }
  23. -(void)queueItems :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params {
  24. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  25. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  26. [httpClient defaultValueForHeader:@"Accept"];
  27. NSMutableURLRequest *requesting = [httpClient requestWithMethod:@"POST" path:requestUrl parameters:params];
  28. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:requesting];
  29. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  30. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  31. //NSString *response = [operation responseString];
  32. // NSLog(@"response: [%@]",response);
  33. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  34. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  35. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  36. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  37. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  38. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  39. NSLog(@"error: %@", [operation error]);
  40. }];
  41. // [operation start];
  42. [self.queue addOperation:operation];
  43. }
  44. -(void)putQueueItems :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params {
  45. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  46. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  47. [httpClient defaultValueForHeader:@"Accept"];
  48. NSMutableURLRequest *requesting = [httpClient requestWithMethod:@"PUT" path:requestUrl parameters:params];
  49. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:requesting];
  50. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  51. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  52. //NSString *response = [operation responseString];
  53. //NSLog(@"response: [%@]",response);
  54. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  55. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  56. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  57. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  58. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  59. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  60. NSLog(@"error: %@", [operation error]);
  61. }];
  62. // [operation start];
  63. [self.queue addOperation:operation];
  64. }
  65. -(void)deleteQueueItems :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params {
  66. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  67. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  68. [httpClient defaultValueForHeader:@"Accept"];
  69. NSMutableURLRequest *requesting = [httpClient requestWithMethod:@"DELETE" path:requestUrl parameters:params];
  70. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:requesting];
  71. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  72. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  73. //NSString *response = [operation responseString];
  74. //NSLog(@"response: [%@]",response);
  75. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  76. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  77. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  78. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  79. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  80. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  81. NSLog(@"error: %@", [operation error]);
  82. }];
  83. // [operation start];
  84. [self.queue addOperation:operation];
  85. }
  86. -(void)getQueueItems :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params {
  87. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  88. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  89. [httpClient defaultValueForHeader:@"Accept"];
  90. NSMutableURLRequest *requesting = [httpClient requestWithMethod:@"GET" path:requestUrl parameters:params];
  91. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:requesting];
  92. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  93. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  94. // NSString *response = [operation responseString];
  95. // NSLog(@"response: [%@]",response);
  96. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  97. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  98. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  99. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  100. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  101. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  102. NSLog(@"error: %@", [operation error]);
  103. }];
  104. // [operation start];
  105. [self.queue addOperation:operation];
  106. }
  107. -(void)uploadImageDrawing :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params :(NSData *)imageData {
  108. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  109. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  110. [httpClient defaultValueForHeader:@"Accept"];
  111. NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
  112. [DateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  113. NSLog(@"%@",[DateFormatter stringFromDate:[NSDate date]]);
  114. NSString *fName=[NSString stringWithFormat:@"test.xml"];
  115. NSMutableURLRequest *myRequest = [httpClient multipartFormRequestWithMethod:@"POST" path:requestUrl parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
  116. [formData appendPartWithFileData:imageData name:@"image" fileName:fName mimeType:@"text/xml"];
  117. }];
  118. NSLog(@"myRequest:%@",myRequest);
  119. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:myRequest];
  120. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  121. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  122. NSString *response = [operation responseString];
  123. NSLog(@"response: [%@]",response);
  124. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  125. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  126. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  127. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  128. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  129. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  130. NSLog(@"error: %@", [operation error]);
  131. }];
  132. [self.queue addOperation:operation];
  133. }
  134. -(void)uploadImageAndData :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params :(NSData *)imageData {
  135. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  136. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  137. [httpClient defaultValueForHeader:@"Accept"];
  138. NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
  139. [DateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  140. NSLog(@"%@",[DateFormatter stringFromDate:[NSDate date]]);
  141. NSString *fName=[NSString stringWithFormat:@"img.png"];
  142. NSMutableURLRequest *myRequest = [httpClient multipartFormRequestWithMethod:@"POST" path:requestUrl parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
  143. [formData appendPartWithFileData:imageData name:@"image" fileName:fName mimeType:@"image/jpeg"];
  144. }];
  145. NSLog(@"myRequest:%@",myRequest);
  146. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:myRequest];
  147. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  148. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  149. NSString *response = [operation responseString];
  150. NSLog(@"response: [%@]",response);
  151. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  152. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  153. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  154. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  155. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  156. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  157. NSLog(@"error: %@", [operation error]);
  158. }];
  159. [self.queue addOperation:operation];
  160. }
  161. -(void)uploadImageAndDataViaPUT :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params :(NSData *)imageData {
  162. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  163. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  164. [httpClient defaultValueForHeader:@"Accept"];
  165. NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
  166. [DateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  167. NSLog(@"%@",[DateFormatter stringFromDate:[NSDate date]]);
  168. NSString *fName=[NSString stringWithFormat:@"%@img.png",[DateFormatter stringFromDate:[NSDate date]]];
  169. NSMutableURLRequest *myRequest = [httpClient multipartFormRequestWithMethod:@"PUT" path:requestUrl parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
  170. [formData appendPartWithFileData:imageData name:@"product[image]" fileName:fName mimeType:@"image/jpeg"];
  171. }];
  172. NSLog(@"myRequest:%@",myRequest);
  173. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:myRequest];
  174. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  175. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  176. NSString *response = [operation responseString];
  177. NSLog(@"response: [%@]",response);
  178. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  179. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  180. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  181. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  182. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  183. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  184. NSLog(@"error: %@", [operation error]);
  185. }];
  186. [self.queue addOperation:operation];
  187. }
  188. -(void)uploadImageAndDataViaPUTPost :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params :(NSData *)imageData {
  189. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  190. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  191. [httpClient defaultValueForHeader:@"Accept"];
  192. NSMutableURLRequest *myRequest = [httpClient multipartFormRequestWithMethod:@"POST" path:requestUrl parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
  193. // [formData appendPartWithFileData:imageData name:@"seller_settings[profile_picture]" fileName:@"HomeBackground1.png" mimeType:@"image/jpeg"];
  194. NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
  195. [DateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  196. NSLog(@"%@",[DateFormatter stringFromDate:[NSDate date]]);
  197. NSString *fName=[NSString stringWithFormat:@"%@img.png",[DateFormatter stringFromDate:[NSDate date]]];
  198. [formData appendPartWithFileData:imageData name:@"seller_settings[seller_profile_picture]" fileName:fName mimeType:@"image/jpeg"];
  199. }];
  200. NSLog(@"myRequest:%@",myRequest);
  201. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:myRequest];
  202. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  203. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  204. NSString *response = [operation responseString];
  205. NSLog(@"response: [%@]",response);
  206. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  207. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  208. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  209. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  210. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  211. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  212. NSLog(@"error: %@", [operation error]);
  213. }];
  214. [self.queue addOperation:operation];
  215. }
  216. -(void)uploadImageForSignUp :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params :(NSData *)imageData {
  217. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  218. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  219. [httpClient defaultValueForHeader:@"Accept"];
  220. NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
  221. [DateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  222. NSLog(@"%@",[DateFormatter stringFromDate:[NSDate date]]);
  223. NSString *fName=[NSString stringWithFormat:@"%@img.png",[DateFormatter stringFromDate:[NSDate date]]];
  224. NSMutableURLRequest *myRequest = [httpClient multipartFormRequestWithMethod:@"POST" path:requestUrl parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
  225. [formData appendPartWithFileData:imageData name:@"user[profile_picture]" fileName:fName mimeType:@"image/jpeg"];
  226. }];
  227. NSLog(@"myRequest:%@",myRequest);
  228. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:myRequest];
  229. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  230. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  231. NSString *response = [operation responseString];
  232. NSLog(@"response: [%@]",response);
  233. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  234. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  235. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  236. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  237. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  238. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  239. NSLog(@"error: %@", [operation error]);
  240. }];
  241. [self.queue addOperation:operation];
  242. }
  243. -(void)uploadImageForViaPUTInAccountSetting :(NSString *)requestUrl :(NSString *)_tag :(NSDictionary *)params :(NSData *)imageData {
  244. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  245. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  246. [httpClient defaultValueForHeader:@"Accept"];
  247. NSDateFormatter *DateFormatter=[[NSDateFormatter alloc] init];
  248. [DateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
  249. NSLog(@"%@",[DateFormatter stringFromDate:[NSDate date]]);
  250. NSString *fName=[NSString stringWithFormat:@"%@img.png",[DateFormatter stringFromDate:[NSDate date]]];
  251. NSMutableURLRequest *myRequest = [httpClient multipartFormRequestWithMethod:@"PUT" path:requestUrl parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
  252. [formData appendPartWithFileData:imageData name:@"user[profile_picture]" fileName:fName mimeType:@"image/jpeg"];
  253. }];
  254. NSLog(@"myRequest:%@",myRequest);
  255. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:myRequest];
  256. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  257. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  258. NSString *response = [operation responseString];
  259. NSLog(@"response: [%@]",response);
  260. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  261. [[NSNotificationCenter defaultCenter] postNotificationName:_tag object:self userInfo:dict];
  262. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  263. NSString *tStr=[NSString stringWithFormat:@"-%@",_tag];
  264. NSDictionary* dict = [NSDictionary dictionaryWithObject: operation forKey:@"index"];
  265. [[NSNotificationCenter defaultCenter] postNotificationName:tStr object:self userInfo:dict];
  266. NSLog(@"error: %@", [operation error]);
  267. }];
  268. [self.queue addOperation:operation];
  269. }
  270. -(void)cancelAllQueueOperation {
  271. [self.queue cancelAllOperations];
  272. }
  273. //- (AFHTTPSessionManager*)getAFHTTPSessionManager
  274. //{
  275. // AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
  276. // manager.responseSerializer = [AFJSONResponseSerializer serializer];
  277. // manager.requestSerializer = [AFJSONRequestSerializer serializer];
  278. // [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  279. // [manager.requestSerializer setValue:@"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36" forHTTPHeaderField:@"User-Agent"];
  280. // [manager.requestSerializer setValue:@"*/*" forHTTPHeaderField:@"Accept"];
  281. // [manager.securityPolicy setAllowInvalidCertificates:YES];
  282. //
  283. // return manager;
  284. //}
  285. #pragma mark - APIs
  286. - (void)postRequest:(NSDictionary *)parameters requestUrl:(NSString *)requestUrl success:(void (^)(id responseObject))success failure:(void (^)(NSString *errorString))failure
  287. {
  288. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  289. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  290. [httpClient defaultValueForHeader:@"Accept"];
  291. NSMutableURLRequest *requesting = [httpClient requestWithMethod:@"POST" path:requestUrl parameters:parameters];
  292. AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:requesting];
  293. [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
  294. [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
  295. NSError *error = nil;
  296. NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseObject
  297. options:kNilOptions
  298. error:&error];
  299. if (!error)
  300. {
  301. success(json);
  302. }
  303. else
  304. {
  305. failure(@"error");
  306. }
  307. } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
  308. failure(error.localizedDescription);
  309. }];
  310. [operation start];
  311. }
  312. //- (void)getRequest:(NSDictionary *)parameters requestUrl:(NSString *)requestUrl success:(void (^)(id responseObject))success
  313. // failure:(void (^)(NSString *errorString))failure
  314. //{
  315. // AFHTTPSessionManager *manager = [self getAFHTTPSessionManager];
  316. // manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
  317. //
  318. // [manager GET:requestUrl parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) {
  319. //
  320. // } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  321. // success(responseObject);
  322. // } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
  323. // failure(error.localizedDescription);
  324. // }];
  325. //}
  326. /*
  327. -(void)temp:(NSString *) requestUrl:(int) _tag :(NSDictionary *)params {
  328. NSURL *baseURL = [NSURL URLWithString:requestUrl];
  329. AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
  330. [httpClient defaultValueForHeader:@"Accept"];
  331. NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:requestUrl parameters:params];
  332. AFHTTPRequestOperation *operation = [AFHTTPRequestOperation operationWithRequest:request
  333. completion:^(NSURLRequest *req, NSHTTPURLResponse *response, NSData *data, NSError *error) {
  334. BOOL HTTPStatusCodeIsAcceptable = [[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)] containsIndex:[response statusCode]];
  335. if (HTTPStatusCodeIsAcceptable) {
  336. NSLog(@"Request Successful");
  337. } else {
  338. NSLog(@"[Error]: (%@ %@) %@", [request HTTPMethod], [[request URL] relativePath], error);
  339. }
  340. }];
  341. }
  342. */
  343. @end