summaryrefslogtreecommitdiff
path: root/Juick/API.h
blob: ad1433b27f65b4e1299c3f065dadf14c7f7f725b (plain) (blame)
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
//
//  APIClient.h
//  Juick
//
//  Created by Vitaly Takmazov on 22/08/16.
//  Copyright © 2016 com.juick. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Message.h"
#import "DeviceRegistration.h"

extern NSString * const JuickErrorDomain;

@protocol JuickAuthorizationDelegate
-(void) unauthorized;
@end

@interface API : NSObject<NSURLSessionDelegate, NSURLSessionTaskDelegate>

@property (nonatomic, strong) id<JuickAuthorizationDelegate> delegate;

-(void) pullNextFromPath:(NSString *)path params:(NSDictionary *)params callback:(void(^)(NSArray<Message *>*, NSError *))callback;
-(void) postMessage:(NSString *)text result:(void(^)(Message *, NSError *))callback;
-(void) postReplyToThread:(NSNumber *)mid inReplyTo:(NSNumber *)rid text:(NSString *)text result:(void(^)(Message *, NSError *))callback;
-(void) postPMToUser:(NSString *)uname text:(NSString *)text result:(void(^)(NSError *))callback;
-(void) fetchChats:(void(^)(NSArray *, NSError *))callback;
-(void) fetchChatWithUser:(NSString *)uname callback:(void(^)(NSArray *, NSError *))callback;
-(void) authenticateWithUser:(NSString *)username password:(NSString *)password callback:(void(^)(BOOL))completed;
-(void) signout;
-(void) me:(void(^)(User *, NSError *))callback;
-(void) refreshDeviceRegistration:(DeviceRegistration *)registrationData callback:(void(^)(BOOL))callback;
-(void) getUserByName:(NSString *) name callback:(void(^)(User *))callback;
-(void) getUserByUri:(NSString *) uri callback:(void(^)(User *))callback;
-(void) fetchImageWithURL:(NSURL *) url callback:(void(^)(NSData *))callback;
@property (nonatomic, strong) User * currentUser;

+(NSString *) messagesUrl;
+(NSString *) threadUrl;
+(NSString *) feedUrl;
+(NSString *) discussionsUrl;
+(NSString *) defaultAvatarUrl;

@end