//
//  HTTPDataProcession.h
//  Unity-iPhone
//
//  Created by leon on 2021/2/2.
//

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

#define RequestSerializerType_JSON @"application/json"
#define RequestSerializerType_URLEncoded @"application/x-www-form-urlencoded"
#define RequestSerializerType_FormData @"form-data"

#define CFBundleVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define OS @"2"

////api
//#ifdef DEBUG
//#define BASE_URL @"https://test-shoes-api.funfet.com"//测试环境
//#else
//#define BASE_URL @"https://shoes-api.funfet.com"//正式环境
//#endif

#define GAME_INVITE [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/game/invite",CFBundleVersion,OS]
#define GAME_RECORD [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/gameRecord/addGame",CFBundleVersion,OS]
#define GAME_FRIENDS [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/forum/friends",CFBundleVersion,OS]
#define GAME_RANK [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/rank/game",CFBundleVersion,OS]
#define GAME_START [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/game/start",CFBundleVersion,OS]
#define GAME_END [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/game/end",CFBundleVersion,OS]

typedef void(^SuccessBlock)(id data);
typedef void(^FailBlock)(id errorDes);

typedef void(^UserFriendsDataBlock)(int code,const char * jsonString,NSMutableArray * dataArr);//获取好友列表
typedef void(^RankDataBlock)(const char * jsonString);//游戏榜单
typedef void(^InviteDataBlock)(NSString * jsonString);//邀请好友
typedef void(^GameEndDataBlock)(const char * jsonString);//游戏结束

@interface HTTPDataProcession : NSObject

+ (void)getHTTPDataProcession:(NSString*)urlString token:(NSString*)token success:(SuccessBlock)successBlock fail:(FailBlock)failBlock;

+ (void)postHTTPDataProcession:(NSString *)urlString  withParams:(NSDictionary *)params token:(NSString*)token success:(SuccessBlock)successBlock fail:(FailBlock)failBlock;

//获取服务器baseurl
+(NSString*)getBaseUrl;

/**
发起邀请好友
@param friendid 被邀请人用户id
@param info 附带的信息
*/
+ (void)inviteFriends:(int)friendid inviteInfo:(NSString*)inviteInfo inviteDataBlock:(InviteDataBlock)inviteDataBlock;


/**
获取好友榜单数据
 @param type if (type == 0) "world" else "friend"
*/
+ (void)GetRank:(int)type rankDataBlock:(RankDataBlock)rankDataBlock;


/**
 获取好友列表
 @param type if (type == 0) "world" else "friend"
*/
+(void)getFriendsList:(UserFriendsDataBlock)userFriendsDataBlock;


/**
  上传游戏数据
 @param level 等级
 @param score 分数
 @param record 时间
 @param mode 模式
 @param opponentId opponentId
 @param play_group 时间戳毫秒
*/
+(void)postGameRecord:(int)level
                score:(double)score
               record:(int)record
                 mode:(int)mode
           opponentId:(int)opponentId
     gameEndDataBlock:(GameEndDataBlock)gameEndDataBlock;


/**
 开始游戏
 @param level 等级
*/
+(void)gameStart;


/**
 结束游戏
 @param level 等级
*/
+(void)gameEnd;

//添加游戏记录接口
///gameRecord/addGame
//接口参数增加：play_group 时间戳毫秒
//
//每局游戏开始 gameStart 调用接口
///game/start?id=$gameId
//每局游戏结束 gameEnd 调用接口
///game/end?id=$gameId
//
//用来切换在线状态
//
@end
