133 lines
5.3 KiB
Objective-C
133 lines
5.3 KiB
Objective-C
//
|
||
// Api.m
|
||
// xplan-ios
|
||
//
|
||
// Created by zu on 2021/9/6.
|
||
//
|
||
|
||
#import "Api.h"
|
||
|
||
@implementation Api
|
||
|
||
+ (void)makeRequest:(NSString *)route method:(DDRequestToolMethod)method completion:(DDRequestToolCompletion)completion, ... {
|
||
va_list arg_lists;
|
||
va_start(arg_lists, completion);
|
||
|
||
// 获取第一个参数 __FUNCTION__ ,然后解析出来 key 。
|
||
const char *functionName = va_arg(arg_lists, const char *);
|
||
NSString *fn = [[NSString alloc] initWithUTF8String:functionName];
|
||
// NSLog 一下 __FUNCTION__ 就知道为什么这么截取了。
|
||
NSRange blankRange = [fn rangeOfString:@":"];
|
||
NSUInteger start = blankRange.location + 1;
|
||
NSUInteger length;
|
||
if ((start + 2) < fn.length) {
|
||
length = fn.length - start - 2;
|
||
} else if ((start + 1) < fn.length) {
|
||
length = fn.length -start - 1;
|
||
} else {
|
||
length = fn.length -start;
|
||
}
|
||
|
||
NSString *fromatParamKeys = [fn substringWithRange:NSMakeRange(start, length)];
|
||
// 构造请求的 NSMutableDictionary *params 。
|
||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||
|
||
NSArray *paramKeys = [fromatParamKeys componentsSeparatedByString:@":"];
|
||
NSEnumerator *enumerator = [paramKeys objectEnumerator];
|
||
NSString *value = nil;
|
||
while((value = va_arg(arg_lists, NSString*))){
|
||
[params setValue:value forKey:enumerator.nextObject];
|
||
};
|
||
va_end(arg_lists);
|
||
|
||
[DDRequestTool DD_Request:route method:method params:params completion:completion];
|
||
}
|
||
|
||
+ (void)getUserInfo:(DDRequestToolCompletion)completion uid:(NSString *)uid {
|
||
/// user/get
|
||
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"Nq7kd0ySV5Mtz5opiSWmFw=="];
|
||
[self makeRequest:url method:DDRequestToolMethodGET completion:completion, __FUNCTION__, uid, nil];
|
||
}
|
||
|
||
/// 获取手机号的验证码
|
||
/// @param completion 请求完成
|
||
/// @param mobile 手机号
|
||
/// @param type 类型 请看XPEunm中的枚举
|
||
+ (void)phoneSmsCode:(DDRequestToolCompletion)completion mobile:(NSString *)mobile type:(NSString *)type {
|
||
/// sms/getCode
|
||
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"PuB7oi7TobImxHTR/ubaIA=="];
|
||
[self makeRequest:url method:DDRequestToolMethodPOST completion:completion, __FUNCTION__, mobile, type, nil];
|
||
}
|
||
|
||
/// 校验手机号码
|
||
/// @param complection 完成
|
||
/// @param mobile 手机号
|
||
/// @param code 验证码
|
||
/// @param uid 用户的uid
|
||
/// @param ticket ticket
|
||
+ (void)checkMoblieCode:(DDRequestToolCompletion)complection
|
||
mobile:(NSString *)mobile
|
||
code:(NSString *)code
|
||
uid:(NSString *)uid
|
||
ticket:(NSString *)ticket {
|
||
/// sms/verify
|
||
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"y/v8AKtK6n5dUdTbSlzlBg=="];
|
||
[self makeRequest:url method:DDRequestToolMethodPOST completion:complection, __FUNCTION__, mobile, code, uid, ticket,nil];
|
||
}
|
||
|
||
/// 补全用户资料
|
||
/// @param complection 完成
|
||
/// @param userInfo 需要更新的用户信息
|
||
+ (void)completeUserInfo:(DDRequestToolCompletion)complection
|
||
userInfo:(NSDictionary *)userInfo {
|
||
/// user/v2/update
|
||
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"czMeGys+NUO+k7yaGaXljg=="];
|
||
[DDRequestTool DD_Request:url method:DDRequestToolMethodPOST params:userInfo completion:complection];
|
||
}
|
||
|
||
|
||
/// 获取用户钱包余额信息
|
||
/// @param complection 完成
|
||
/// @param uid 用户uid
|
||
/// @param ticket ticketg
|
||
+ (void)getUserWalletInfo:(DDRequestToolCompletion)complection uid:(NSString *)uid ticket:(NSString *)ticket {
|
||
[self makeRequest:@"purse/query" method:DDRequestToolMethodGET completion:complection, __FUNCTION__, uid, ticket,nil];
|
||
}
|
||
|
||
/// 批量验证
|
||
/// @param complection 完成
|
||
/// @param transcationIdStr 需要验证的数据
|
||
+ (void)requestCheckTranscationIds:(DDRequestToolCompletion)complection
|
||
transcationIdStr:(NSString *)transcationIdStr {
|
||
/// verify/checkIOSChargeRecord
|
||
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"txQqEPo8Jap4SvoIAw/+fgleOC8ui2US+VDuEKM16TM="];
|
||
[self makeRequest:url method:DDRequestToolMethodPOST completion:complection, __FUNCTION__,transcationIdStr, nil];
|
||
}
|
||
|
||
/// 锁麦/开麦
|
||
/// @param complection 完成
|
||
/// @param roomUid 房主的uid
|
||
/// @param state 0 开麦 1 锁麦
|
||
/// @param position 坑位
|
||
/// @param ticket 用户的ticket
|
||
/// @param uid uid
|
||
+ (void)microMuteCompletion:(DDRequestToolCompletion)complection roomUid:(NSString *)roomUid state:(NSString *)state position:(NSString *)position ticket:(NSString *)ticket uid:(NSString *)uid {
|
||
/// room/mic/lockmic
|
||
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"SlsZ8qw3HETylhX+Fo0LEsTuX8veT6MsPI8GVCbS7C8="];
|
||
[self makeRequest:url method:DDRequestToolMethodPOST completion:complection, __FUNCTION__, roomUid, state, position, ticket, uid, nil];
|
||
}
|
||
|
||
/// 锁坑/开锁
|
||
/// @param complection 完成
|
||
/// @param roomUid 房主的uid
|
||
/// @param state 1锁坑位,0取消锁(即取消锁坑位)
|
||
/// @param position 坑位
|
||
/// @param ticket 用户的ticket
|
||
/// @param uid uid
|
||
+ (void)microLockCompletion:(DDRequestToolCompletion)complection roomUid:(NSString *)roomUid state:(NSString *)state position:(NSString *)position ticket:(NSString *)ticket uid:(NSString *)uid {
|
||
/// room/mic/lockpos
|
||
NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"3ylbyxDfEkAFNIIkdSmbAJu34/lxuxkwno0OeTX8DUw="];
|
||
[self makeRequest:url method:DDRequestToolMethodPOST completion:complection, __FUNCTION__, roomUid, state, position, ticket, uid, nil];
|
||
}
|
||
@end
|