新增获取客服接口

This commit is contained in:
2026-02-24 20:45:15 +08:00
parent 0a16a4f240
commit 1c9013bede
6 changed files with 67 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ typedef void(^KBDeleteThemesCompletion)(BOOL success, NSError *_Nullable error);
typedef void(^KBSubmitFeedbackCompletion)(BOOL success, NSError *_Nullable error);
typedef void(^KBMyPurchaseRecordCompletion)(NSArray<KBConsumptionRecord *> *_Nullable records, NSError *_Nullable error);
typedef void(^KBMyInviteCodeCompletion)(KBInviteCodeModel *_Nullable inviteCode, NSError *_Nullable error);
typedef void(^KBMyCustomerMailCompletion)(NSString *_Nullable customerMail, NSError *_Nullable error);
@interface KBMyVM : NSObject
@@ -37,6 +38,8 @@ typedef void(^KBMyInviteCodeCompletion)(KBInviteCodeModel *_Nullable inviteCode,
- (void)fetchUserDetailWithCompletion:(KBMyUserDetailCompletion)completion;
/// 查询邀请码(/user/inviteCode
- (void)fetchInviteCodeWithCompletion:(KBMyInviteCodeCompletion)completion;
/// 获取客服邮箱(/user/customerMail
- (void)fetchCustomerMailWithCompletion:(KBMyCustomerMailCompletion)completion;
/// 用户人设列表(/character/listByUser
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion;

View File

@@ -83,6 +83,35 @@ NSString * const KBUserCharacterDeletedNotification = @"KBUserCharacterDeletedNo
}];
}
- (void)fetchCustomerMailWithCompletion:(KBMyCustomerMailCompletion)completion {
[[KBNetworkManager shared] GET:API_USER_CUSTOMER_MAIL
parameters:nil
headers:nil
autoShowBusinessError:NO
completion:^(NSDictionary *jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
if (completion) completion(nil, error);
return;
}
// { "message":"ok", "data":"123@mail.com", "code":0 }
id dataObj = jsonOrData[@"data"];
NSString *customerMail = [dataObj isKindOfClass:[NSString class]]
? [(NSString *)dataObj stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
: @"";
if (customerMail.length == 0) {
NSError *e = [NSError errorWithDomain:KBNetworkErrorDomain
code:KBNetworkErrorInvalidResponse
userInfo:@{NSLocalizedDescriptionKey: KBLocalized(@"Invalid response")}];
if (completion) completion(nil, e);
return;
}
if (completion) completion(customerMail, nil);
}];
}
- (void)fetchCharacterListByUserWithCompletion:(KBCharacterListCompletion)completion{
[[KBNetworkManager shared] GET:KB_API_CHARACTER_LISTBYUSER
parameters:nil