XYChatAPIManager.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. //
  2. // XYChatAPIManager.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/3/23.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYChatAPIManager.h"
  9. /// 发送视频单聊请求
  10. static NSString * const CHAT_SEND_SINGLE_CHAT_REQUEST = @"api-app/v1/chat/sendSingleChatRequest";
  11. /// 取消视频单聊请求
  12. static NSString * const CHAT_CANCEL_SINGLE_CHAT_REQUEST = @"api-app/v1/chat/cancelSingleChatRequest";
  13. /// 处理视频单聊请求
  14. static NSString * const CHAT_DECIDE_SINGLE_CHAT_REQUEST = @"api-app/v1/chat/decideSingleChatRequest";
  15. /// 获取单聊推荐列表
  16. static NSString * const CHAT_GET_SINGLE_CHAT_SUGGEST_LIST = @"api-app/v1/chat/getSingleChatSuggestList";
  17. /// 获取单聊主播列表
  18. static NSString * const CHAT_GET_SINGLE_CHAT_LIST = @"api-app/v1/chat/getSingleChatList";
  19. /// 中止单聊
  20. static NSString * const CHAT_STOP_SINGLE_CHAT = @"api-app/v1/chat/stopSingleChat";
  21. /// 单聊结束评价
  22. static NSString * const CHAT_EVALUATE_SINGLE_CHAT = @"api-app/v1/chat/evaluateSingleChat";
  23. /// 获取单聊评价标签
  24. static NSString * const CHAT_GET_SINGLE_CHAT_EVALUATE_TAGS = @"api-app/v1/config/getSingleChatEvaluateTags";
  25. /// 随机获取单聊主播列表
  26. static NSString * const CHAT_GET_SINGLE_CHAT_RANDOM = @"api-app/v1/chat/getSingleChatRandom";
  27. /// 获取单聊记录详情
  28. static NSString * const CHAT_GET_SINGLE_CHAT_HIS_INFO = @"api-app/v1/chat/getSingleChatHisInfo";
  29. /// 刷新单聊提醒
  30. static NSString * const CHAT_REFRESH_SINGLE_CHAT_REMIND = @"api-app/v1/chat/refreshSingleChatRemind";
  31. /// 获取单聊主播详情
  32. static NSString * const CHAT_GET_SINGLE_CHAT_ANCHOR_INFO = @"api-app/v1/chat/getSingleChatAnchorInfo";
  33. /// 获取关注的单聊主播列表
  34. static NSString * const CHAT_GET_SINGLE_CHAT_FOLLOW_LIST = @"api-app/v1/chat/getSingleChatFollowList";
  35. /// vip单聊主播搜索
  36. static NSString * const CHAT_GET_VIPSINGLE_CHAT_LIST = @"api-app/v1/chat/getVipSingleChatList";
  37. /// 语音速配-发起
  38. static NSString * const CHAT_SEND_VOICE_MATCH = @"api-app/v1/chat/sendVoiceMatch";
  39. /// 语音速配-同意或拒绝
  40. static NSString * const CHAT_DECIDE_VOICE_MATCH = @"api-app/v1/chat/decideVoiceMatch";
  41. /// 语音速配-暂停
  42. static NSString * const CHAT_CANCEL_VOICE_CHAT = @"api-app/v1/chat/cancelVoiceChat";
  43. /// 语音速配-结束
  44. static NSString * const CHAT_STOP_VOICE_CHAT = @"api-app/v1/chat/stopVoiceChat";
  45. /// 语音速配-获取免费时长
  46. static NSString * const CHAT_GET_VOICE_CHAT_FREE_TIME = @"api-app/v1/chat/getVoiceChatFreeTime";
  47. /// 语音速配-详情
  48. static NSString * const CHAT_GET_VOICE_CHAT_DETAIL = @"api-app/v1/chat/getVoiceChatDetail";
  49. /// 语音速配-获取配置
  50. static NSString * const CHAT_GET_VOICE_CHAT_CONFIG = @"api-app/v1/chat/getVoiceChatConfig";
  51. /// 语音速配-获取token
  52. static NSString * const CHAT_GET_VOICE_CHAT_TOKEN = @"api-app/v1/chat/getVoiceChatToken";
  53. /// 赠送语音速配礼物
  54. static NSString * const CHAT_SENDVOICE_GIFT = @"api-app/v1/gift/sendVoiceGift";
  55. /// 语音速配-列表
  56. static NSString * const CHAT_GET_VOICE_CHAT_LIST = @"api-app/v1/chat/getVoiceChatList";
  57. /// 获取匹配成功记录
  58. static NSString * const CHAT_GET_MATCH_SUCCESS_LIST = @"api-app/v1/chat/getMatchSuccessList";
  59. /// 获取符合条件用户(头像信息)
  60. static NSString * const CHAT_GET_MATCH_USER_LIST = @"api-app/v1/chat/getMatchUserList";
  61. @implementation XYChatAPIManager
  62. /// 发送视频单聊请求
  63. /// @param targetUserId 主播 id
  64. /// @param matchId 主播发起请求的话 需要传
  65. /// @param successHandler 请求成功
  66. /// @param failureHandler 请求失败
  67. - (NSNumber *)sendSingleChatRequest:(NSString *)targetUserId matchId:(NSString *)matchId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  68. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  69. config.urlPath = [CHAT_SEND_SINGLE_CHAT_REQUEST copy];
  70. config.instructions = @"发送视频单聊请求";
  71. NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
  72. if (StringIsNotEmpty(targetUserId)) {
  73. [parameters addEntriesFromDictionary:@{@"targetUserId":targetUserId}];
  74. }
  75. if (StringIsNotEmpty(matchId)) {
  76. [parameters addEntriesFromDictionary:@{@"matchId":matchId}];
  77. }
  78. config.requestParameters = parameters;
  79. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  80. }
  81. /// 取消视频单聊请求
  82. /// @param hisId 请求记录 id
  83. /// @param successHandler 请求成功
  84. /// @param failureHandler 请求失败
  85. - (NSNumber *)cancelSingleChatRequest:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  86. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  87. config.urlPath = [CHAT_CANCEL_SINGLE_CHAT_REQUEST copy];
  88. config.instructions = @"取消视频单聊请求";
  89. config.requestParameters = @{@"hisId":hisId};
  90. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  91. }
  92. /// 处理视频单聊请求
  93. /// @param hisId 请求记录 id
  94. /// @param decision 1 接受 -1 拒绝
  95. /// @param successHandler 请求成功
  96. /// @param failureHandler 请求失败
  97. - (NSNumber *)decideSingleChatRequest:(NSString *)hisId decision:(NSInteger)decision successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  98. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  99. config.urlPath = [CHAT_DECIDE_SINGLE_CHAT_REQUEST copy];
  100. config.instructions = @"处理视频单聊请求";
  101. config.requestParameters = @{@"hisId":hisId};
  102. if (decision) {
  103. config.requestParameters = @{@"hisId":hisId, @"decision":@(decision)};
  104. }else {
  105. config.requestParameters = @{@"hisId":hisId};
  106. }
  107. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  108. }
  109. /// 获取单聊推荐列表
  110. /// @param query 暂时不用
  111. /// @param successHandler 请求成功
  112. /// @param failureHandler 请求失败
  113. - (NSNumber *)getSingleChatSuggestListWithQuery:(NSInteger)query successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  114. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  115. config.urlPath = [CHAT_GET_SINGLE_CHAT_SUGGEST_LIST copy];
  116. config.instructions = @"获取单聊推荐列表";
  117. config.requestType = ZYLNetworkRequestTypeGet;
  118. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  119. }
  120. /// 获取单聊主播列表
  121. /// @param pageIndex 页码
  122. /// @param successHandler 请求成功
  123. /// @param failureHandler 请求失败
  124. - (NSNumber *)getSingleChatListWithPageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  125. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  126. config.urlPath = [CHAT_GET_SINGLE_CHAT_LIST copy];
  127. config.instructions = @"获取单聊主播列表";
  128. config.requestType = ZYLNetworkRequestTypeGet;
  129. config.requestParameters = @{@"pageIndex":@(pageIndex)};
  130. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  131. }
  132. /// 获取单聊主播列表
  133. /// @param pageIndex 页码
  134. /// @param userSex 性别筛选
  135. /// @param categoryId 类目id
  136. /// @param successHandler 请求成功
  137. /// @param failureHandler 请求失败
  138. - (NSNumber *)getSingleChatListWithPageIndex:(NSInteger)pageIndex userSex:(NSInteger)userSex categoryId:(NSString *)categoryId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  139. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  140. config.urlPath = [CHAT_GET_SINGLE_CHAT_LIST copy];
  141. config.instructions = @"获取单聊主播列表";
  142. config.requestType = ZYLNetworkRequestTypeGet;
  143. NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
  144. [parameters addEntriesFromDictionary:@{@"pageIndex":@(pageIndex)}];
  145. if (userSex != 0) {
  146. [parameters addEntriesFromDictionary:@{@"userSex":@(userSex)}];
  147. }
  148. if (StringIsNotEmpty(categoryId)) {
  149. [parameters addEntriesFromDictionary:@{@"categoryId":categoryId}];
  150. }
  151. config.requestParameters = parameters;
  152. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  153. }
  154. /// 中止单聊
  155. /// @param hisId 记录 id
  156. /// @param successHandler 请求成功
  157. /// @param failureHandler 请求失败
  158. - (NSNumber *)stopSingleChatWithHisId:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  159. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  160. config.urlPath = [CHAT_STOP_SINGLE_CHAT copy];
  161. config.instructions = @"中止单聊";
  162. config.requestParameters = @{@"hisId":hisId};
  163. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  164. }
  165. /// 单聊结束评价
  166. /// @param hisId 记录 id
  167. /// @param scoreValue 评分 1-5
  168. /// @param tagIds 评价标签id 英文逗号分隔
  169. /// @param successHandler 请求成功
  170. /// @param failureHandler 请求失败
  171. - (NSNumber *)evaluateSingleChatWithhHsId:(NSString *)hisId scoreValue:(NSInteger)scoreValue tagIds:(NSString *)tagIds successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  172. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  173. config.urlPath = [CHAT_EVALUATE_SINGLE_CHAT copy];
  174. config.instructions = @"单聊结束评价";
  175. if (StringIsEmpty(tagIds)) {
  176. config.requestParameters = @{@"hisId":hisId, @"scoreValue":@(scoreValue)};
  177. }else {
  178. config.requestParameters = @{@"hisId":hisId, @"scoreValue":@(scoreValue), @"tagIds":tagIds};
  179. }
  180. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  181. }
  182. /// 获取单聊评价标签
  183. /// @param tagType 标签类型 1 用户标签 2 主播标签
  184. /// @param successHandler 请求成功
  185. /// @param failureHandler 请求失败
  186. - (NSNumber *)getSingleChatEvaluateTagsTagType:(NSInteger)tagType successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  187. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  188. config.urlPath = [CHAT_GET_SINGLE_CHAT_EVALUATE_TAGS copy];
  189. config.instructions = @"获取单聊评价标签";
  190. config.requestType = ZYLNetworkRequestTypeGet;
  191. config.requestParameters = @{@"tagType":@(tagType)};
  192. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  193. }
  194. /// 随机获取单聊主播列表
  195. /// @param userSex 性别筛选
  196. /// @param categoryId 类目筛选
  197. /// @param successHandler 请求成功
  198. /// @param failureHandler 请求失败
  199. - (NSNumber *)getSingleChatRandomWithUserSex:(NSInteger)userSex categoryId:(NSString *)categoryId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  200. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  201. config.urlPath = [CHAT_GET_SINGLE_CHAT_RANDOM copy];
  202. config.instructions = @"随机获取单聊主播列表";
  203. config.requestType = ZYLNetworkRequestTypeGet;
  204. NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
  205. if (userSex) {
  206. [parameters addEntriesFromDictionary:@{@"userSex":@(userSex)}];
  207. }
  208. if (StringIsNotEmpty(categoryId)) {
  209. [parameters addEntriesFromDictionary:@{@"categoryId":categoryId}];
  210. }
  211. config.requestParameters = parameters;
  212. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  213. }
  214. /// 获取单聊记录详情
  215. /// @param hisId 记录 id
  216. /// @param successHandler 请求成功
  217. /// @param failureHandler 请求失败
  218. - (NSNumber *)getSingleChatHisInfoWithHisId:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  219. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  220. config.urlPath = [CHAT_GET_SINGLE_CHAT_HIS_INFO copy];
  221. config.instructions = @"获取单聊记录详情";
  222. config.requestType = ZYLNetworkRequestTypeGet;
  223. config.requestParameters = @{@"hisId":hisId};
  224. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  225. }
  226. /// 刷新单聊提醒
  227. /// @param hisId 记录 id
  228. /// @param successHandler 请求成功
  229. /// @param failureHandler 请求失败
  230. - (NSNumber *)refreshSingleChatRemindWithHisId:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  231. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  232. config.urlPath = [CHAT_REFRESH_SINGLE_CHAT_REMIND copy];
  233. config.instructions = @"刷新单聊提醒";
  234. config.requestParameters = @{@"hisId":hisId};
  235. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  236. }
  237. /// 获取单聊主播详情
  238. /// @param userId 主播 id
  239. /// @param successHandler 请求成功
  240. /// @param failureHandler 请求失败
  241. - (NSNumber *)getSingleChatAnchorInfoWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  242. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  243. config.urlPath = [CHAT_GET_SINGLE_CHAT_ANCHOR_INFO copy];
  244. config.instructions = @"获取单聊主播详情";
  245. config.requestType = ZYLNetworkRequestTypeGet;
  246. config.requestParameters = @{@"userId":userId};
  247. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  248. }
  249. /// 获取关注的单聊主播列表
  250. /// @param pageIndex 0是不分页 大于0则是分页
  251. /// @param successHandler 请求成功
  252. /// @param failureHandler 请求失败
  253. - (NSNumber *)getSingleChatFollowListWithPageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  254. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  255. config.urlPath = [CHAT_GET_SINGLE_CHAT_FOLLOW_LIST copy];
  256. config.instructions = @"获取关注的单聊主播列表";
  257. config.requestType = ZYLNetworkRequestTypeGet;
  258. if (pageIndex > 0) {
  259. config.requestParameters = @{@"pageIndex":@(pageIndex)};
  260. }
  261. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  262. }
  263. /// vip单聊主播搜索
  264. /// @param pageIndex 页码
  265. /// @param parameters 参数
  266. /// @param successHandler 请求成功
  267. /// @param failureHandler 请求失败
  268. - (NSNumber *)getVipSingleChatListWithPageIndex:(NSInteger)pageIndex parameters:(NSDictionary *)parameters successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  269. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  270. config.urlPath = [CHAT_GET_VIPSINGLE_CHAT_LIST copy];
  271. config.instructions = @"vip单聊主播搜索";
  272. config.requestType = ZYLNetworkRequestTypeGet;
  273. NSMutableDictionary *tempParameters = [NSMutableDictionary dictionary];
  274. [tempParameters addEntriesFromDictionary:@{@"pageIndex":@(pageIndex)}];
  275. if (parameters) {
  276. [tempParameters addEntriesFromDictionary:parameters];
  277. }
  278. config.requestParameters = tempParameters;
  279. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  280. }
  281. /// 语音速配-发起
  282. /// @param userSex 用户性别 1男 2女 0全部
  283. /// @param successHandler 请求成功
  284. /// @param failureHandler 请求失败
  285. - (NSNumber *)sendVoiceMatchWithUserSex:(NSInteger)userSex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  286. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  287. config.urlPath = [CHAT_SEND_VOICE_MATCH copy];
  288. config.instructions = @"语音速配-发起";
  289. config.requestParameters = @{@"userSex":@(userSex)};
  290. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  291. }
  292. /// 语音速配-同意或拒绝
  293. /// @param hisId 匹配记录id
  294. /// @param decision 是否同意 1同意 0拒绝
  295. /// @param round 轮次
  296. /// @param successHandler 请求成功
  297. /// @param failureHandler 请求失败
  298. - (NSNumber *)decideVoiceMatchWithHisId:(NSString *)hisId decision:(NSInteger)decision round:(NSInteger)round successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  299. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  300. config.urlPath = [CHAT_DECIDE_VOICE_MATCH copy];
  301. config.instructions = @"语音速配-同意或拒绝";
  302. config.requestParameters = @{@"hisId":hisId, @"decision":@(decision), @"round":@(round)};
  303. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  304. }
  305. /// 语音速配-暂停
  306. /// @param hisId 匹配记录id
  307. /// @param successHandler 请求成功
  308. /// @param failureHandler 请求失败
  309. - (NSNumber *)cancelVoiceChatWithHisId:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  310. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  311. config.urlPath = [CHAT_CANCEL_VOICE_CHAT copy];
  312. config.instructions = @"语音速配-暂停";
  313. config.requestParameters = @{@"hisId":hisId};
  314. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  315. }
  316. /// 语音速配-结束
  317. /// @param hisId 语音速配记录id
  318. /// @param successHandler 请求成功
  319. /// @param failureHandler 请求失败
  320. - (NSNumber *)stopVoiceChatWithHisId:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  321. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  322. config.urlPath = [CHAT_STOP_VOICE_CHAT copy];
  323. config.instructions = @"语音速配-结束";
  324. config.requestParameters = @{@"hisId":hisId};
  325. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  326. }
  327. /// 语音速配-获取免费时长
  328. /// @param successHandler 请求成功
  329. /// @param failureHandler 请求失败
  330. - (NSNumber *)getVoiceChatFreeTimeSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  331. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  332. config.urlPath = [CHAT_GET_VOICE_CHAT_FREE_TIME copy];
  333. config.instructions = @"语音速配-获取免费时长";
  334. config.requestType = ZYLNetworkRequestTypeGet;
  335. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  336. }
  337. /// 语音速配-详情
  338. /// @param hisId 匹配记录id
  339. /// @param successHandler 请求成功
  340. /// @param failureHandler 请求失败
  341. - (NSNumber *)getVoiceChatDetailWithHisId:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  342. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  343. config.urlPath = [CHAT_GET_VOICE_CHAT_DETAIL copy];
  344. config.instructions = @"语音速配-详情";
  345. config.requestType = ZYLNetworkRequestTypeGet;
  346. config.requestParameters = @{@"hisId":hisId};
  347. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  348. }
  349. /// 语音速配-获取配置
  350. /// @param successHandler 请求成功
  351. /// @param failureHandler 请求失败
  352. - (NSNumber *)getVoiceChatConfigSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  353. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  354. config.urlPath = [CHAT_GET_VOICE_CHAT_CONFIG copy];
  355. config.instructions = @"语音速配-详情";
  356. config.requestType = ZYLNetworkRequestTypeGet;
  357. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  358. }
  359. /// 语音速配-获取token
  360. /// @param hisId 匹配记录id
  361. /// @param successHandler 请求成功
  362. /// @param failureHandler 请求失败
  363. - (NSNumber *)getVoiceChatTokenWithHisId:(NSString *)hisId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  364. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  365. config.urlPath = [CHAT_GET_VOICE_CHAT_TOKEN copy];
  366. config.instructions = @"语音速配-获取token";
  367. config.requestType = ZYLNetworkRequestTypeGet;
  368. config.requestParameters = @{@"hisId":hisId};
  369. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  370. }
  371. //赠送语音速配礼物
  372. //Body hisId 语音速配id Long
  373. //Body userId 收礼物人id Long
  374. //Body giftId 礼物id Long
  375. //Body quantity 数量 Integer
  376. //Body isFromBag 是否来自背包 Boolean
  377. - (NSNumber *)sendVoiceGift:(NSDictionary *__nullable)paramDict successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler{
  378. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  379. config.urlPath = [CHAT_SENDVOICE_GIFT copy];
  380. config.instructions = @"赠送语音速配礼物";
  381. config.requestType = ZYLNetworkRequestTypePost;
  382. config.requestParameters = paramDict;
  383. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  384. }
  385. /// 语音速配-列表
  386. /// @param pageIndex 当前页码
  387. /// @param hisStatus 聊天状态
  388. /// /** * 呼叫中 */ Ringing(101, "呼叫中"), /** * 通话中 */ Calling(201, "通话中"), /** * 已结束 */ Closed(301, "已结束"), /** * 已取消 */ Canceled(302, "已取消"), /** * 已拒绝 */ Rejected(303, "已拒绝"),
  389. /// @param successHandler 请求成功
  390. /// @param failureHandler 请求失败
  391. - (NSNumber *)getVoiceChatListWithPageIndex:(NSInteger)pageIndex hisStatus:(NSInteger)hisStatus successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
  392. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  393. config.urlPath = [CHAT_GET_VOICE_CHAT_LIST copy];
  394. config.instructions = @"语音速配-列表";
  395. config.requestType = ZYLNetworkRequestTypeGet;
  396. if (hisStatus == 0) {
  397. config.requestParameters = @{@"pageIndex":@(pageIndex)};
  398. }else {
  399. config.requestParameters = @{@"pageIndex":@(pageIndex), @"hisStatus":@(hisStatus)};
  400. }
  401. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  402. }
  403. //获取符合条件用户(头像信息)
  404. //Query userSex 性别 Integer 1男 2女 0全部
  405. - (NSNumber *)getMatchUserList:(NSDictionary *__nullable)paramDict successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler{
  406. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  407. config.urlPath = [CHAT_GET_MATCH_USER_LIST copy];
  408. config.instructions = @"获取符合条件用户(头像信息)";
  409. config.requestType = ZYLNetworkRequestTypeGet;
  410. config.requestParameters = paramDict;
  411. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  412. }
  413. //获取匹配成功记录
  414. - (NSNumber *)getMatchSuccessList:(NSDictionary *__nullable)paramDict successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler{
  415. ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
  416. config.urlPath = [CHAT_GET_MATCH_SUCCESS_LIST copy];
  417. config.instructions = @"获取匹配成功记录";
  418. config.requestType = ZYLNetworkRequestTypeGet;
  419. config.requestParameters = paramDict;
  420. return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
  421. }
  422. @end