summaryrefslogtreecommitdiff
path: root/Juick/APIClient.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-08 23:17:47 +0300
committerGravatar Vitaly Takmazov2018-04-08 23:17:47 +0300
commitf6fed5b2374c7d847c68efccce363f9513aa2efb (patch)
tree74021a451bd5cfb1df1a7771a32dbc121a7163c6 /Juick/APIClient.m
parent6f8855ce3b83cc50583b62b4a1960c27fdf66bb3 (diff)
PM posts
Diffstat (limited to 'Juick/APIClient.m')
-rw-r--r--Juick/APIClient.m19
1 files changed, 19 insertions, 0 deletions
diff --git a/Juick/APIClient.m b/Juick/APIClient.m
index 079db5a..1b3fb6e 100644
--- a/Juick/APIClient.m
+++ b/Juick/APIClient.m
@@ -102,6 +102,25 @@
}];
}];
}
+-(void) postPMToUser:(NSString *)uname text:(NSString *)text result:(void (^)(NSError *))callback {
+ AFHTTPSessionManager *manager = [APIClient sharedClient].manager;
+ [self.backgroundQueue addOperationWithBlock:^{
+ [manager POST:@"/pm" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
+ [formData appendPartWithFormData:[text dataUsingEncoding:NSUTF8StringEncoding] name:@"body"];
+ [formData appendPartWithFormData:[uname dataUsingEncoding:NSUTF8StringEncoding] name:@"uname"];
+ } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ callback(nil);
+ }];
+ } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
+ NSLog(@"Error: %@", [error localizedDescription]);
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ callback(error);
+ }];
+ }];
+ }];
+}
+
-(void) fetchChats:(void (^)(NSArray *, NSError *))callback {
AFHTTPSessionManager *manager = [APIClient sharedClient].manager;
[self.backgroundQueue addOperationWithBlock:^{