diff options
author | Vitaly Takmazov | 2019-03-20 02:35:23 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-20 02:35:23 +0300 |
commit | 458e55b9cddcadb2bbbe3fb4002f06a5744b84c0 (patch) | |
tree | aa32d167c3a6914b1fd326085e94d2a2cb43b057 /Juick/Model/User.m | |
parent | 1f3e08f107064fa429c6aa2a26702f6e63a791f0 (diff) |
Move all API calls to APIClient
Diffstat (limited to 'Juick/Model/User.m')
-rw-r--r-- | Juick/Model/User.m | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/Juick/Model/User.m b/Juick/Model/User.m index 7f97e34..6d5e818 100644 --- a/Juick/Model/User.m +++ b/Juick/Model/User.m @@ -38,26 +38,4 @@ [view presentViewController:alert animated:YES completion:nil]; } -+(void) checkIsValid:(void (^)(BOOL))callback { - AFHTTPSessionManager *manager = [APIClient sharedClient].manager; - [manager POST:@"post" parameters:nil progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { - NSInteger statusCode = ((NSHTTPURLResponse *)task.response).statusCode; - if (statusCode == 400) { - callback(YES); - } else { - [manager.requestSerializer clearAuthorizationHeader]; - callback(NO); - } - }];} - -+(void) get:(NSString *) name callback:(void(^)(User *))callback { - AFHTTPSessionManager *manager = [APIClient sharedClient].manager; - NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:name, @"uname", nil]; - [manager GET:@"users" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { - callback([User fromJSON:[(NSArray *)responseObject firstObject]]); - } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { - callback(nil); - }]; -} - @end |