HTTPDataProcession.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // HTTPDataProcession.h
  3. // Unity-iPhone
  4. //
  5. // Created by leon on 2021/2/2.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "MYFactoryManager.h"
  9. #define RequestSerializerType_JSON @"application/json"
  10. #define RequestSerializerType_URLEncoded @"application/x-www-form-urlencoded"
  11. #define RequestSerializerType_FormData @"form-data"
  12. #define CFBundleVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
  13. #define OS @"2"
  14. ////api
  15. //#ifdef DEBUG
  16. //#define BASE_URL @"https://test-shoes-api.funfet.com"//测试环境
  17. //#else
  18. //#define BASE_URL @"https://shoes-api.funfet.com"//正式环境
  19. //#endif
  20. #define GAME_INVITE [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/game/invite",CFBundleVersion,OS]
  21. #define GAME_RECORD [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/gameRecord/addGame",CFBundleVersion,OS]
  22. #define GAME_FRIENDS [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/forum/friends",CFBundleVersion,OS]
  23. #define GAME_RANK [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/rank/game",CFBundleVersion,OS]
  24. #define GAME_START [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/game/start",CFBundleVersion,OS]
  25. #define GAME_END [NSString stringWithFormat:@"%@%@?v=%@&os=%@",[HTTPDataProcession getBaseUrl],@"/game/end",CFBundleVersion,OS]
  26. typedef void(^SuccessBlock)(id data);
  27. typedef void(^FailBlock)(id errorDes);
  28. typedef void(^UserFriendsDataBlock)(int code,const char * jsonString,NSMutableArray * dataArr);//获取好友列表
  29. typedef void(^RankDataBlock)(const char * jsonString);//游戏榜单
  30. typedef void(^InviteDataBlock)(NSString * jsonString);//邀请好友
  31. typedef void(^GameEndDataBlock)(const char * jsonString);//游戏结束
  32. @interface HTTPDataProcession : NSObject
  33. + (void)getHTTPDataProcession:(NSString*)urlString token:(NSString*)token success:(SuccessBlock)successBlock fail:(FailBlock)failBlock;
  34. + (void)postHTTPDataProcession:(NSString *)urlString withParams:(NSDictionary *)params token:(NSString*)token success:(SuccessBlock)successBlock fail:(FailBlock)failBlock;
  35. //获取服务器baseurl
  36. +(NSString*)getBaseUrl;
  37. /**
  38. 发起邀请好友
  39. @param friendid 被邀请人用户id
  40. @param info 附带的信息
  41. */
  42. + (void)inviteFriends:(int)friendid inviteInfo:(NSString*)inviteInfo inviteDataBlock:(InviteDataBlock)inviteDataBlock;
  43. /**
  44. 获取好友榜单数据
  45. @param type if (type == 0) "world" else "friend"
  46. */
  47. + (void)GetRank:(int)type rankDataBlock:(RankDataBlock)rankDataBlock;
  48. /**
  49. 获取好友列表
  50. @param type if (type == 0) "world" else "friend"
  51. */
  52. +(void)getFriendsList:(UserFriendsDataBlock)userFriendsDataBlock;
  53. /**
  54. 上传游戏数据
  55. @param level 等级
  56. @param score 分数
  57. @param record 时间
  58. @param mode 模式
  59. @param opponentId opponentId
  60. @param play_group 时间戳毫秒
  61. */
  62. +(void)postGameRecord:(int)level
  63. score:(double)score
  64. record:(int)record
  65. mode:(int)mode
  66. opponentId:(int)opponentId
  67. gameEndDataBlock:(GameEndDataBlock)gameEndDataBlock;
  68. /**
  69. 开始游戏
  70. @param level 等级
  71. */
  72. +(void)gameStart;
  73. /**
  74. 结束游戏
  75. @param level 等级
  76. */
  77. +(void)gameEnd;
  78. //添加游戏记录接口
  79. ///gameRecord/addGame
  80. //接口参数增加:play_group 时间戳毫秒
  81. //
  82. //每局游戏开始 gameStart 调用接口
  83. ///game/start?id=$gameId
  84. //每局游戏结束 gameEnd 调用接口
  85. ///game/end?id=$gameId
  86. //
  87. //用来切换在线状态
  88. //
  89. @end