//
//  ServerAPI.h
//  LifeLog
//
//  Created by Nguyen Van Phong on 7/30/17.
//  Copyright © 2017 PhongNV. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Entities.h"

extern NSString *const kServerAddress;
extern NSString *const kUser;
extern NSString *const kToken;
extern NSString *const kNotificationToken;

@interface ServerAPI : NSObject
+ (instancetype) server;
@property (nonatomic, assign) NSTimeInterval timeOutInterval;

#pragma mark - Login and Register
- (void)loginWithEmail:(NSString *)email Password:(NSString *)password CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion;
- (void)registerUserWithParams:(NSDictionary *)params CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion;
- (void)uploadImage:(NSString *)token andImageData:(NSData *)data CompletionHandler:(void (^)(NSString *, NSError *)) completion;
- (void)forgetPass:(NSString *)email CompletionHandler:(void (^)(NSError *)) completion;
- (void)confirmForgetPass:(NSString *)email withConfirm:(NSString *)confirm CompletionHandler:(void (^)(NSError *)) completion;

#pragma mark - Home Screen Function
- (void)requestTopWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(TopObject *, NSError *)) completion;
- (void)requestCreateLog:(int)mode withStep:(int)numStep startDate:(NSString *)startDate endDate:(NSString *)endDate CompletionHandler:(void (^)(NSError *))completion;
- (void)requestHomeWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(HomeObject *, NSError *)) completion;

#pragma mark - History Screen Function
- (void) requestHistory:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
- (void) requestHistoryList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
- (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion;
-(void) requestCreateGroup:(NSString *)token withGroup:(GroupObject *)group CompletionHandler:(void (^)(GroupObject *, NSError *)) completion;
- (void) requestGroupList:(NSString *)token CompletionHandler:(void (^)(NSArray *, NSError *)) completion;

#pragma mark - SNS Screen Function
/*
    Get tweet of group and get recent tweet is same API
    If groupID equal -1, it will request recent tweet. Otherwise will request tweet of group
*/
- (void) requestTweetsList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
- (void) searchGroup:(NSString *)token withKey:(NSString *)key andPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;

#pragma mark - Group Function
- (void) getGroupDetail:(NSString *)token withGroupID:(int)groupID CompletionHandler:(void (^)(GroupObject *, NSError *)) completion;
- (void) requestMemberList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;

#pragma mark - Ranking API
- (void) requestRankingList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate mode:(int) mode page:(int) page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;

#pragma mark - Common API
- (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion;
#pragma mark - Get Notice
- (void)getNoticeByDate: (NSString *)date CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
@end
