CNLiveUserSystemCenter.m 6.73 KB
//
//  CNLiveUserSystemCenter.m
//  CNLiveUserSystemDemo
//
//  Created by iOS on 16/9/12.
//  Copyright © 2016年 zhulin. All rights reserved.
//

#import "CNLiveUserSystemCenter.h"
#import "CNLiveLogin.h"
#import "CNLiveRegister.h"
#import "CNLiveVerificationCode.h"
#import "CNLiveFeedback.h"
#import "CNLiveUserInfo.h"
#import "CNLiveUserSystemTools.h"
#import "CNLiveUserManager.h"
#import "CNLiveUploadIcon.h"

@implementation CNLiveUserSystemCenter

+ (void)setAppId:(NSString *)appId appKey:(NSString *)appKey appSecret:(NSString *)appSecret
{
    [CNLiveUserManager manager].appId = appId;
    [CNLiveUserManager manager].appKey = appKey;
    [CNLiveUserManager manager].appSecret = appSecret;
    
    [[CNLiveUserManager manager] addObserver];
}

/**
 *  注册
 */
+ (void)registerWithUserName:(NSString *)userName password:(NSString *)password verificationCode:(NSString *)verificationCode invitationCode:(NSString *)invitationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveRegister *userRegister = [[CNLiveRegister alloc] init];
    
    [userRegister registerWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey userName:userName password:password verificationCode:verificationCode invitationCode:invitationCode frmId:frmId success:success failure:failure];
}

/**
 *  第三方登录
 */
+ (void)thirdPartyLoginWithThirdPartyPlatType:(NSString *)plat thirdPartyId:(NSString *)thirdPartyId nickName:(NSString *)nickName gender:(NSString *)gender location:(NSString *)location faceUrl:(NSString *)faceUrl frmId:(NSString *)frmId success:(void (^)(id result))success failure:(void (^)(NSError *))failure
{
    CNLiveLogin *thirdLogin = [[CNLiveLogin alloc] init];
    
    [thirdLogin thirdPartyLoginWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey thirdPartyPlatType:plat thirdPartyId:thirdPartyId nickName:nickName gender:gender location:location faceUrl:faceUrl frmId:frmId success:success failure:failure];
}

/**
 *  快捷登录
 */

+ (void)shortcutLoginWithUserName:(NSString *)userName verificationCode:(NSString *)verificationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveLogin *shortcutLogin = [[CNLiveLogin alloc] init];
    
    [shortcutLogin shortcutLoginWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey userName:userName verificationCode:verificationCode frmId:frmId success:success failure:failure];
}

/**
 *  登录
 */
+ (void)loginWithUserName:(NSString *)userName password:(NSString *)password frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveLogin *login = [[CNLiveLogin alloc] init];
    
    [login loginWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey userName:userName password:password frmId:frmId success:success failure:failure];
}

/**
 *  发送验证码
 */
+ (void)verificationCodeType:(VerificationCodeType)type mobile:(NSString *)mobile success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveVerificationCode *verification = [[CNLiveVerificationCode alloc] init];
    
    [verification getVerificationCodeWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey type:type mobile:mobile success:success failure:failure];
}

/**
 *  更新用户附加信息
 */
+ (void)updateOtherInfoWithUid:(NSString *)uid extInfo:(NSString *)extInfo token:(NSString *)token success:(void (^)(id result))success failure:(void (^)(NSError *))failure
{
    CNLiveUserInfo *updateOtherInfo = [[CNLiveUserInfo alloc] init];
    
    [updateOtherInfo updateOtherInfoWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey uid:uid extInfo:extInfo token:token success:success failure:failure];
}

/**
 *  修改用户单项信息
 */
+ (void)modifyUserInfoType:(UserInfoType)type uid:(NSString *)uid modifyInfo:(NSString *)info token:(NSString *)token success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveUserInfo *updateUserInfo = [[CNLiveUserInfo alloc] init];
    
    [updateUserInfo modifyUserInfoWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey type:type uid:uid modifyInfo:info token:token success:success failure:failure];
}

/**
 *  更新手机号
 */
+ (void)updateMobileWithUid:(NSString *)uid mobile:(NSString *)mobile verificationCode:(NSString *)verificationCode token:(NSString *)token success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveUserInfo *updateMobile = [[CNLiveUserInfo alloc] init];
    
    [updateMobile updateMobileWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey uid:uid mobile:mobile verificationCode:verificationCode token:token success:success failure:failure];
}

/**
 *  修改密码
 */
+ (void)changePasswordWithMobile:(NSString *)mobile verificationCode:(NSString *)verificationCode newPassword:(NSString *)newPassword success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveUserInfo *password = [[CNLiveUserInfo alloc] init];
    
    [password changePasswordWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey mobile:mobile verificationCode:verificationCode newPassword:newPassword success:success failure:failure];
}


/**
 *  上传头像
 */
+ (void)uploadIconWithUid:(NSString *)uid token:(NSString *)token icon:(UIImage *)icon success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
    CNLiveUploadIcon *uplodIcon = [[CNLiveUploadIcon alloc] init];
    [uplodIcon uploadIconWithAppId:[CNLiveUserManager manager].appId uid:uid icon:icon token:token secret:[CNLiveUserManager manager].appSecret success:success failure:failure];
}

/**
 *  查询用户信息
 */
+ (void)queryUserInfoWithUid:(NSString *)uid srcUid:(NSString *)srcUid token:(NSString *)token success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveUserInfo *userInfo = [[CNLiveUserInfo alloc] init];
    
    [userInfo queryUserInfoWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey uid:uid srcUid:srcUid token:token success:success failure:failure];
}

/**
 *  用户反馈
 */
+ (void)feedbackWithContentId:(NSString *)contentId message:(NSString *)message success:(void (^)(id result))success failure :(void (^)(NSError *error))failure
{
    CNLiveFeedback *feedback = [[CNLiveFeedback alloc] init];
    
    [feedback feedbackWithAppId:[CNLiveUserManager manager].appId appKey:[CNLiveUserManager manager].appKey contentId:contentId message:message success:success failure:failure];
}

@end