XYAnchorAPIManager.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. //
  2. // XYAnchorAPIManager.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2019/12/25.
  6. // Copyright © 2019 翟玉磊. All rights reserved.
  7. //
  8. #import "XYAnchorAPIManager.h"
  9. /// 发起主播认证
  10. static NSString * const ANCHOR_ADD_APPLY = @"api-app/v1/anchor/addApply";
  11. /// 最近一次认证记录
  12. static NSString * const ANCHOR_GET_LAST_APPLY_RECORD = @"api-app/v1/anchor/getLastApplyRecord";
  13. /// 获取置顶推荐直播
  14. static NSString * const ANCHOR_GET_TOP_SUGGEST = @"api-app/v1/live/getTopSuggest";
  15. /// 获取直播详情
  16. static NSString * const ANCHOR_GET_LIVE_INFO = @"api-app/v1/live/getLiveInfo";
  17. /// 获取房管列表
  18. static NSString * const ANCHOR_GET_MASTERS = @"api-app/v1/anchor/getMasters";
  19. /// 删除房管
  20. static NSString * const ANCHOR_REMOVE_MASTER = @"api-app/v1/anchor/removeMaster";
  21. /// 申请签约公会
  22. static NSString * const ANCHOR_APPLY_AGENT = @"api-app/v1/anchor/applyAgent";
  23. /// 获取公会列表
  24. static NSString * const ANCHOR_APPLY_PAGE_LIST = @"api-app/v1/anchor/getAgentPageList";
  25. /// 获取公会详情
  26. static NSString * const ANCHOR_GET_AGENT_DETAIL = @"api-app/v1/anchor/getAgentDetail";
  27. /// 申请解约公会
  28. static NSString * const ANCHOR_CANCLE_AGENT = @"api-app/v1/anchor/cancelAgent";
  29. /// 获取最近一次入会申请信息
  30. static NSString * const ANCHOR_GET_LAST_APPLY_INFO = @"api-app/v1/anchor/getLastApplyInfo";
  31. /// 设置粉丝团名称
  32. static NSString * const ANCHOR_SET_FANS_NAME = @"api-app/v1/anchor/setFansName";
  33. /// 获取主播基础信息(订阅、粉丝等)
  34. static NSString * const ANCHOR_GET_INFO = @"api-app/v1/anchor/getInfo";
  35. /// 获取粉丝团成员列表
  36. static NSString * const ANCHOR_GET_FANS_LIST = @"api-app/v1/anchor/getFansList";
  37. /// 使用道具
  38. static NSString * const PROPS_USE_PROPS = @"api-app/v1/props/useProps";
  39. /// 兑换靓号
  40. static NSString * const PROPS_EXCHANGE_NICE_NO = @"api-app/v1/props/exchangeNiceNo";
  41. /// pk-获取主播pk列表
  42. static NSString * const ANCHOR_GET_ANCHOR_PK_LIST = @"api-app/v1/anchor/getAnchorPkList";
  43. /// pk-获取主播列表(搜索)
  44. static NSString * const ANCHOR_GET_ANCHOR_LIST = @"api-app/v1/anchor/getAnchorList";
  45. /// Ta的房间
  46. static NSString * const ANCHOR_GET_ROOM = @"api-app/v1/anchor/getRoom";
  47. @implementation XYAnchorAPIManager
  48. /// 发起主播认证
  49. /// @param idCardHoldImg 手持身份证照片
  50. /// @param idCardFaceImg 身份证正面照片
  51. /// @param idCardNationImg 身份证反面照片
  52. /// @param successHandler 请求成功
  53. /// @param failureHandler 请求失败
  54. - (NSNumber *)addApplyWithIdCardHoldImg:(NSString *)idCardHoldImg idCardFaceImg:(NSString *)idCardFaceImg idCardNationImg:(NSString *)idCardNationImg SuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  55. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  56. config.urlPath = [ANCHOR_ADD_APPLY copy];
  57. config.instructions = @"发起主播认证";
  58. config.requestParameters = @{@"idCardHoldImg":idCardHoldImg, @"idCardFaceImg":idCardFaceImg, @"idCardNationImg":idCardNationImg};
  59. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  60. }
  61. /// 最近一次认证记录
  62. /// @param successHandler 请求成功
  63. /// @param failureHandler 请求失败
  64. - (NSNumber *)getLastApplyRecordSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  65. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  66. config.urlPath = [ANCHOR_GET_LAST_APPLY_RECORD copy];
  67. config.instructions = @"最近一次认证记录";
  68. config.requestType = ZYLNetworkRequestTypeGet;
  69. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  70. }
  71. /// 获取置顶推荐直播
  72. /// @param successHandler 请求成功
  73. /// @param failureHandler 请求失败
  74. - (NSNumber *)getTopSuggestSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  75. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  76. config.urlPath = [ANCHOR_GET_TOP_SUGGEST copy];
  77. config.instructions = @"获取置顶推荐直播";
  78. config.requestType = ZYLNetworkRequestTypeGet;
  79. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  80. }
  81. /// 获取直播详情
  82. /// @param userId 主播id
  83. /// @param successHandler 请求成功
  84. /// @param failureHandler 请求失败
  85. - (NSNumber *)getLiveInfoWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  86. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  87. config.urlPath = [ANCHOR_GET_LIVE_INFO copy];
  88. config.instructions = @"获取直播详情";
  89. config.requestType = ZYLNetworkRequestTypeGet;
  90. config.requestParameters = @{@"userId":userId};
  91. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  92. }
  93. /// 获取房管列表
  94. /// @param successHandler 请求成功
  95. /// @param failureHandler 请求失败
  96. - (NSNumber *)getMastersSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  97. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  98. config.urlPath = [ANCHOR_GET_MASTERS copy];
  99. config.instructions = @"获取房管列表";
  100. config.requestType = ZYLNetworkRequestTypeGet;
  101. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  102. }
  103. /// 取消房管
  104. /// @param userId 要取消的用户 id
  105. /// @param successHandler 请求成功
  106. /// @param failureHandler 请求失败
  107. - (NSNumber *)removeMasterWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  108. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  109. config.urlPath = [ANCHOR_REMOVE_MASTER copy];
  110. config.instructions = @"取消房管";
  111. config.requestParameters = @{@"userId":userId};
  112. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  113. }
  114. /// 申请签约公会
  115. /// @param agentId 公会id
  116. /// @param applyMsg 申请时备注
  117. /// @param successHandler 请求成功
  118. /// @param failureHandler 请求失败
  119. - (NSNumber *)applyAgentWithAgentId:(NSString *)agentId applyMsg:(NSString *)applyMsg successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  120. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  121. config.urlPath = [ANCHOR_APPLY_AGENT copy];
  122. config.instructions = @"申请签约公会";
  123. if (StringIsEmpty(applyMsg)) {
  124. config.requestParameters = @{@"agentId":agentId};
  125. }else {
  126. config.requestParameters = @{@"agentId":agentId, @"applyMsg":applyMsg};
  127. }
  128. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  129. }
  130. /// 获取公会列表
  131. /// @param content 公会编号或名称
  132. /// @param pageNum 当前页码
  133. /// @param pageSize 分页大小
  134. /// @param successHandler 请求成功
  135. /// @param failureHandler 请求失败
  136. - (NSNumber *)getAgentPageListWithContent:(NSString *)content pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  137. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  138. config.urlPath = [ANCHOR_APPLY_PAGE_LIST copy];
  139. config.instructions = @"获取公会列表";
  140. config.requestType = ZYLNetworkRequestTypeGet;
  141. config.requestParameters = @{@"content":content, @"pageNum":@(pageNum), @"pageSize":@(pageSize)};
  142. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  143. }
  144. /// 获取公会详情
  145. /// @param agentId 公会id
  146. /// @param successHandler 请求成功
  147. /// @param failureHandler 请求失败
  148. - (NSNumber *)getAgentDetailWithAgentId:(NSString *)agentId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  149. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  150. config.urlPath = [ANCHOR_GET_AGENT_DETAIL copy];
  151. config.instructions = @"获取公会详情";
  152. config.requestType = ZYLNetworkRequestTypeGet;
  153. config.requestParameters = @{@"agentId":agentId};
  154. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  155. }
  156. /// 申请解约公会
  157. /// @param agentId 公会id
  158. /// @param applyMsg 申请时备注
  159. /// @param successHandler 请求成功
  160. /// @param failureHandler 请求失败
  161. - (NSNumber *)cancelAgentWithAgentId:(NSString *)agentId applyMsg:(NSString *)applyMsg successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  162. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  163. config.urlPath = [ANCHOR_CANCLE_AGENT copy];
  164. config.instructions = @"申请解约公会";
  165. if (StringIsEmpty(applyMsg)) {
  166. config.requestParameters = @{@"agentId":agentId};
  167. }else {
  168. config.requestParameters = @{@"agentId":agentId, @"applyMsg":applyMsg};
  169. }
  170. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  171. }
  172. /// 获取最近一次入会申请信息
  173. /// @param successHandler 请求成功
  174. /// @param failureHandler 请求失败
  175. - (NSNumber *)getLastApplyInfoSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  176. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  177. config.urlPath = [ANCHOR_GET_LAST_APPLY_INFO copy];
  178. config.instructions = @"获取最近一次入会申请信息";
  179. config.requestType = ZYLNetworkRequestTypeGet;
  180. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  181. }
  182. /// 设置粉丝团名称
  183. /// @param fansName 粉丝团名称
  184. /// @param successHandler 请求成功
  185. /// @param failureHandler 请求失败
  186. - (NSNumber *)setFansNameWithFansName:(NSString *)fansName successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  187. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  188. config.urlPath = [ANCHOR_SET_FANS_NAME copy];
  189. config.instructions = @"设置粉丝团名称";
  190. config.requestParameters = @{@"fansName":fansName};
  191. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  192. }
  193. /// 获取主播基础信息(订阅、粉丝等)
  194. /// @param successHandler 请求成功
  195. /// @param failureHandler 请求失败
  196. - (NSNumber *)getInfoSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  197. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  198. config.urlPath = [ANCHOR_GET_INFO copy];
  199. config.instructions = @"获取主播基础信息(订阅、粉丝等)";
  200. config.requestType = ZYLNetworkRequestTypeGet;
  201. return [super dispatchDataTaskWithConfiguration:config successHandler:^(ZYLResponseModel *responseModel) {
  202. if (responseModel.codeState) {
  203. NSDictionary *anchorInfo = responseModel.data[@"anchorInfo"];
  204. [XYUserInfoManager nowUser].fansName = [anchorInfo objectForKey:@"fansName"];
  205. [XYUserInfoManager commitUserData];
  206. }
  207. successHandler ? successHandler(responseModel) : nil;
  208. } failureHandler:failureHandler];
  209. }
  210. /// 获取粉丝团成员列表
  211. /// @param pageIndex 页码
  212. /// @param successHandler 请求成功
  213. /// @param failureHandler 请求失败
  214. - (NSNumber *)getFansListWithPageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  215. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  216. config.urlPath = [ANCHOR_GET_FANS_LIST copy];
  217. config.instructions = @"设置粉丝团名称";
  218. config.requestType = ZYLNetworkRequestTypeGet;
  219. config.requestParameters = @{@"pageIndex":@(pageIndex)};
  220. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  221. }
  222. /// 使用道具
  223. /// @param bagId 物品id
  224. /// @param successHandler 请求成功
  225. /// @param failureHandler 请求失败
  226. - (NSNumber *)usePropsBagId:(NSString *)bagId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  227. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  228. config.urlPath = [PROPS_USE_PROPS copy];
  229. config.instructions = @"使用道具";
  230. config.requestParameters = @{@"bagId":bagId};
  231. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  232. }
  233. /// 兑换靓号
  234. /// @param bagId 背包靓号卡 id
  235. /// @param niceNo 靓号
  236. /// @param successHandler 请求成功
  237. /// @param failureHandler 请求失败
  238. - (NSNumber *)exchangeNiceNoWithBagId:(NSString *)bagId niceNo:(NSString *)niceNo successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  239. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  240. config.urlPath = [PROPS_EXCHANGE_NICE_NO copy];
  241. config.instructions = @"兑换靓号";
  242. config.requestParameters = @{@"bagId":bagId, @"niceNo":niceNo};
  243. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  244. }
  245. /// pk-获取主播pk列表
  246. /// @param type 1:全部 2:公会 3:关注
  247. /// @param pageIndex 当前页码
  248. /// @param successHandler 请求成功
  249. /// @param failureHandler 请求失败
  250. - (NSNumber *)getAnchorPkListWithType:(NSInteger)type pageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  251. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  252. config.urlPath = [ANCHOR_GET_ANCHOR_PK_LIST copy];
  253. config.instructions = @"pk-获取主播pk列表";
  254. config.requestType = ZYLNetworkRequestTypeGet;
  255. config.requestParameters = @{@"type":@(type), @"pageIndex":@(pageIndex)};
  256. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  257. }
  258. /// pk-获取主播列表(搜索)
  259. /// @param text 搜索的关键字
  260. /// @param pageIndex 当前页码
  261. /// @param successHandler 请求成功
  262. /// @param failureHandler 请求失败
  263. - (NSNumber *)getAnchorListWithSearchText:(NSString *)text pageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  264. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  265. config.urlPath = [ANCHOR_GET_ANCHOR_LIST copy];
  266. config.instructions = @"pk-获取主播列表(搜索)";
  267. config.requestType = ZYLNetworkRequestTypeGet;
  268. if (StringIsEmpty(text)) {
  269. config.requestParameters = @{@"pageIndex":@(pageIndex)};
  270. }else {
  271. config.requestParameters = @{@"content":text, @"pageIndex":@(pageIndex)};
  272. }
  273. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  274. }
  275. /// Ta的房间
  276. /// @param userId 用户id 不传查自己
  277. /// @param successHandler 请求成功
  278. /// @param failureHandler 请求失败
  279. - (NSNumber *)getRoomWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  280. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  281. config.urlPath = [ANCHOR_GET_ROOM copy];
  282. config.instructions = @"Ta的房间";
  283. config.requestType = ZYLNetworkRequestTypeGet;
  284. if (StringIsNotEmpty(userId)) {
  285. config.requestParameters = @{@"userId":userId};
  286. }
  287. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  288. }
  289. @end