diff options
author | Vitaly Takmazov | 2017-12-05 01:40:51 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-12-05 01:40:51 +0300 |
commit | a228ce07cc5413a6ba164c12042ab1e4028aa5b3 (patch) | |
tree | f1e8eafe6ebcf9beebd9a0ebdd4a1f8d591f8698 /Juick/APIClient.m | |
parent | 888cbddb1eaab4f4f343ffd6e0bf8d976b579794 (diff) |
comment
Diffstat (limited to 'Juick/APIClient.m')
-rw-r--r-- | Juick/APIClient.m | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Juick/APIClient.m b/Juick/APIClient.m index ca894d4..bcc4eec 100644 --- a/Juick/APIClient.m +++ b/Juick/APIClient.m @@ -52,18 +52,22 @@ }); } --(void) postReplyToThread:(NSNumber *)mid inReplyTo:(NSNumber *)rid text:(NSString *)text { +-(void) postReplyToThread:(NSNumber *)mid inReplyTo:(NSNumber *)rid text:(NSString *)text result:(void(^)(Message *, NSError *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; NSOperationQueue *operationQueue = [NSOperationQueue new]; [operationQueue addOperationWithBlock:^{ - [manager POST:@"/post" parameters: - @{ - @"mid": mid, - @"rid": rid, - @"body": text - } progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { - NSLog(@"Errrorrr: %@", [error localizedDescription]); - }]; + [manager POST:@"/comment" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { + [formData appendPartWithFormData:[[mid stringValue] dataUsingEncoding:NSUTF8StringEncoding] name:@"mid"]; + [formData appendPartWithFormData:[[rid stringValue] dataUsingEncoding:NSUTF8StringEncoding] name:@"rid"]; + [formData appendPartWithFormData:[text dataUsingEncoding:NSUTF8StringEncoding] name:@"body"]; + } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + NSLog(@"Success!"); + Message *reply = [Message yy_modelWithJSON:responseObject]; + callback(reply, nil); + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + NSLog(@"Error: %@", [error localizedDescription]); + callback(nil, error); + }]; }]; } |