123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- //
- // XYAnchorAPIManager.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2019/12/25.
- // Copyright © 2019 翟玉磊. All rights reserved.
- //
- #import "XYAnchorAPIManager.h"
- /// 发起主播认证
- static NSString * const ANCHOR_ADD_APPLY = @"api-app/v1/anchor/addApply";
- /// 最近一次认证记录
- static NSString * const ANCHOR_GET_LAST_APPLY_RECORD = @"api-app/v1/anchor/getLastApplyRecord";
- /// 获取置顶推荐直播
- static NSString * const ANCHOR_GET_TOP_SUGGEST = @"api-app/v1/live/getTopSuggest";
- /// 获取直播详情
- static NSString * const ANCHOR_GET_LIVE_INFO = @"api-app/v1/live/getLiveInfo";
- /// 获取房管列表
- static NSString * const ANCHOR_GET_MASTERS = @"api-app/v1/anchor/getMasters";
- /// 删除房管
- static NSString * const ANCHOR_REMOVE_MASTER = @"api-app/v1/anchor/removeMaster";
- /// 申请签约公会
- static NSString * const ANCHOR_APPLY_AGENT = @"api-app/v1/anchor/applyAgent";
- /// 获取公会列表
- static NSString * const ANCHOR_APPLY_PAGE_LIST = @"api-app/v1/anchor/getAgentPageList";
- /// 获取公会详情
- static NSString * const ANCHOR_GET_AGENT_DETAIL = @"api-app/v1/anchor/getAgentDetail";
- /// 申请解约公会
- static NSString * const ANCHOR_CANCLE_AGENT = @"api-app/v1/anchor/cancelAgent";
- /// 获取最近一次入会申请信息
- static NSString * const ANCHOR_GET_LAST_APPLY_INFO = @"api-app/v1/anchor/getLastApplyInfo";
- /// 设置粉丝团名称
- static NSString * const ANCHOR_SET_FANS_NAME = @"api-app/v1/anchor/setFansName";
- /// 获取主播基础信息(订阅、粉丝等)
- static NSString * const ANCHOR_GET_INFO = @"api-app/v1/anchor/getInfo";
- /// 获取粉丝团成员列表
- static NSString * const ANCHOR_GET_FANS_LIST = @"api-app/v1/anchor/getFansList";
- /// 使用道具
- static NSString * const PROPS_USE_PROPS = @"api-app/v1/props/useProps";
- /// 兑换靓号
- static NSString * const PROPS_EXCHANGE_NICE_NO = @"api-app/v1/props/exchangeNiceNo";
- /// pk-获取主播pk列表
- static NSString * const ANCHOR_GET_ANCHOR_PK_LIST = @"api-app/v1/anchor/getAnchorPkList";
- /// pk-获取主播列表(搜索)
- static NSString * const ANCHOR_GET_ANCHOR_LIST = @"api-app/v1/anchor/getAnchorList";
- /// Ta的房间
- static NSString * const ANCHOR_GET_ROOM = @"api-app/v1/anchor/getRoom";
- @implementation XYAnchorAPIManager
- /// 发起主播认证
- /// @param idCardHoldImg 手持身份证照片
- /// @param idCardFaceImg 身份证正面照片
- /// @param idCardNationImg 身份证反面照片
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)addApplyWithIdCardHoldImg:(NSString *)idCardHoldImg idCardFaceImg:(NSString *)idCardFaceImg idCardNationImg:(NSString *)idCardNationImg SuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_ADD_APPLY copy];
- config.instructions = @"发起主播认证";
- config.requestParameters = @{@"idCardHoldImg":idCardHoldImg, @"idCardFaceImg":idCardFaceImg, @"idCardNationImg":idCardNationImg};
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 最近一次认证记录
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getLastApplyRecordSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_LAST_APPLY_RECORD copy];
- config.instructions = @"最近一次认证记录";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取置顶推荐直播
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getTopSuggestSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_TOP_SUGGEST copy];
- config.instructions = @"获取置顶推荐直播";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取直播详情
- /// @param userId 主播id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getLiveInfoWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_LIVE_INFO copy];
- config.instructions = @"获取直播详情";
- config.requestType = ZYLNetworkRequestTypeGet;
- config.requestParameters = @{@"userId":userId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取房管列表
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getMastersSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_MASTERS copy];
- config.instructions = @"获取房管列表";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 取消房管
- /// @param userId 要取消的用户 id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)removeMasterWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_REMOVE_MASTER copy];
- config.instructions = @"取消房管";
- config.requestParameters = @{@"userId":userId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 申请签约公会
- /// @param agentId 公会id
- /// @param applyMsg 申请时备注
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)applyAgentWithAgentId:(NSString *)agentId applyMsg:(NSString *)applyMsg successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_APPLY_AGENT copy];
- config.instructions = @"申请签约公会";
- if (StringIsEmpty(applyMsg)) {
- config.requestParameters = @{@"agentId":agentId};
- }else {
- config.requestParameters = @{@"agentId":agentId, @"applyMsg":applyMsg};
- }
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取公会列表
- /// @param content 公会编号或名称
- /// @param pageNum 当前页码
- /// @param pageSize 分页大小
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getAgentPageListWithContent:(NSString *)content pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_APPLY_PAGE_LIST copy];
- config.instructions = @"获取公会列表";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- config.requestParameters = @{@"content":content, @"pageNum":@(pageNum), @"pageSize":@(pageSize)};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取公会详情
- /// @param agentId 公会id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getAgentDetailWithAgentId:(NSString *)agentId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_AGENT_DETAIL copy];
- config.instructions = @"获取公会详情";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- config.requestParameters = @{@"agentId":agentId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 申请解约公会
- /// @param agentId 公会id
- /// @param applyMsg 申请时备注
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)cancelAgentWithAgentId:(NSString *)agentId applyMsg:(NSString *)applyMsg successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_CANCLE_AGENT copy];
- config.instructions = @"申请解约公会";
-
- if (StringIsEmpty(applyMsg)) {
- config.requestParameters = @{@"agentId":agentId};
- }else {
- config.requestParameters = @{@"agentId":agentId, @"applyMsg":applyMsg};
- }
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取最近一次入会申请信息
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getLastApplyInfoSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_LAST_APPLY_INFO copy];
- config.instructions = @"获取最近一次入会申请信息";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 设置粉丝团名称
- /// @param fansName 粉丝团名称
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)setFansNameWithFansName:(NSString *)fansName successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_SET_FANS_NAME copy];
- config.instructions = @"设置粉丝团名称";
-
- config.requestParameters = @{@"fansName":fansName};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取主播基础信息(订阅、粉丝等)
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getInfoSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_INFO copy];
- config.instructions = @"获取主播基础信息(订阅、粉丝等)";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:^(ZYLResponseModel *responseModel) {
- if (responseModel.codeState) {
- NSDictionary *anchorInfo = responseModel.data[@"anchorInfo"];
-
- [XYUserInfoManager nowUser].fansName = [anchorInfo objectForKey:@"fansName"];
- [XYUserInfoManager commitUserData];
- }
-
- successHandler ? successHandler(responseModel) : nil;
- } failureHandler:failureHandler];
- }
- /// 获取粉丝团成员列表
- /// @param pageIndex 页码
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getFansListWithPageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_FANS_LIST copy];
- config.instructions = @"设置粉丝团名称";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- config.requestParameters = @{@"pageIndex":@(pageIndex)};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 使用道具
- /// @param bagId 物品id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)usePropsBagId:(NSString *)bagId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [PROPS_USE_PROPS copy];
- config.instructions = @"使用道具";
-
- config.requestParameters = @{@"bagId":bagId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 兑换靓号
- /// @param bagId 背包靓号卡 id
- /// @param niceNo 靓号
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)exchangeNiceNoWithBagId:(NSString *)bagId niceNo:(NSString *)niceNo successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [PROPS_EXCHANGE_NICE_NO copy];
- config.instructions = @"兑换靓号";
-
- config.requestParameters = @{@"bagId":bagId, @"niceNo":niceNo};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// pk-获取主播pk列表
- /// @param type 1:全部 2:公会 3:关注
- /// @param pageIndex 当前页码
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getAnchorPkListWithType:(NSInteger)type pageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_ANCHOR_PK_LIST copy];
- config.instructions = @"pk-获取主播pk列表";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- config.requestParameters = @{@"type":@(type), @"pageIndex":@(pageIndex)};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// pk-获取主播列表(搜索)
- /// @param text 搜索的关键字
- /// @param pageIndex 当前页码
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getAnchorListWithSearchText:(NSString *)text pageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_ANCHOR_LIST copy];
- config.instructions = @"pk-获取主播列表(搜索)";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- if (StringIsEmpty(text)) {
- config.requestParameters = @{@"pageIndex":@(pageIndex)};
- }else {
- config.requestParameters = @{@"content":text, @"pageIndex":@(pageIndex)};
- }
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// Ta的房间
- /// @param userId 用户id 不传查自己
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getRoomWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [ANCHOR_GET_ROOM copy];
- config.instructions = @"Ta的房间";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- if (StringIsNotEmpty(userId)) {
- config.requestParameters = @{@"userId":userId};
- }
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- @end
|