78 lines
2.7 KiB
Plaintext
78 lines
2.7 KiB
Plaintext
//
|
|
// EPMineAPIHelper.m
|
|
// YuMi
|
|
//
|
|
// Created by AI on 2025-10-10.
|
|
//
|
|
|
|
#import "EPMineAPIHelper.h"
|
|
#import "Api+Mine.h"
|
|
#import "UserInfoModel.h"
|
|
#import "BaseModel.h"
|
|
#import "AccountInfoStorage.h"
|
|
|
|
@implementation EPMineAPIHelper
|
|
|
|
- (void)getUserInfoWithUid:(NSString *)uid
|
|
completion:(void (^)(UserInfoModel * _Nullable userInfo))completion
|
|
failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure {
|
|
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200 && data.data) {
|
|
UserInfoModel *userInfo = [UserInfoModel modelWithDictionary:data.data];
|
|
if (completion) completion(userInfo);
|
|
} else {
|
|
if (failure) failure(code, msg);
|
|
}
|
|
} uid:uid];
|
|
}
|
|
|
|
- (void)getUserDetailInfoWithUid:(NSString *)uid
|
|
completion:(void (^)(UserInfoModel * _Nullable userInfo))completion
|
|
failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure {
|
|
[Api userDetailInfoCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200 && data.data) {
|
|
UserInfoModel *userInfo = [UserInfoModel modelWithDictionary:data.data];
|
|
if (completion) completion(userInfo);
|
|
} else {
|
|
if (failure) failure(code, msg);
|
|
}
|
|
} uid:uid page:@"1" pageSize:@"20"];
|
|
}
|
|
|
|
- (void)updateAvatarWithUrl:(NSString *)avatarUrl
|
|
completion:(void (^)(void))completion
|
|
failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure {
|
|
[Api userV2UploadAvatar:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
if (completion) completion();
|
|
} else {
|
|
if (failure) failure(code, msg);
|
|
}
|
|
} avatarUrl:avatarUrl needPay:@NO];
|
|
}
|
|
|
|
- (void)updateNicknameWithNick:(NSString *)nickname
|
|
completion:(void (^)(void))completion
|
|
failure:(void (^)(NSInteger code, NSString * _Nullable msg))failure {
|
|
NSString *uid = [[AccountInfoStorage instance] getUid];
|
|
NSString *ticket = [[AccountInfoStorage instance] getTicket];
|
|
|
|
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
|
if (nickname.length > 0) {
|
|
[params setValue:nickname forKey:@"nick"];
|
|
}
|
|
[params setObject:uid forKey:@"uid"];
|
|
[params setObject:ticket forKey:@"ticket"];
|
|
|
|
[Api completeUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
if (completion) completion();
|
|
} else {
|
|
if (failure) failure(code, msg);
|
|
}
|
|
} userInfo:params];
|
|
}
|
|
|
|
@end
|
|
|