Skip to content

Latest commit

 

History

History
103 lines (67 loc) · 3.01 KB

README.md

File metadata and controls

103 lines (67 loc) · 3.01 KB

RCSceneNetworkKit

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Minimum iOS Target:iOS 11.0

Installation

RCSceneNetworkKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RCSceneNetworkKit'

Usage

通过添加 RCSNetworkConfig 分类配置请求信息,和添加 RCSNetworkDataHandler 分类发起请求

/// 可添加全局网络配置
[RCSNetworkConfig configWithBaseUrl:@"" bussinessToken:@""];
    
/// 通过 RCSNetworkDataHandler 实例对象发起请求
[[RCSNetworkDataHandler new] sendCodeWithParams:@{} completionBlock:^(RCSResponseModel * _Nonnull model) {
    NSLog(@"%@", model.description);
}];



//  RCSNetworkConfig+Login.h
@interface RCSNetworkConfig (Login)

/// 获取登录验证码
+ (RCSNetworkConfig *)sendCodeUrlConfigWith:(NSDictionary *)params;


@end

//  RCSNetworkConfig+Login.m
@implementation RCSNetworkConfig (Login)

/// 获取登录验证码
+ (RCSNetworkConfig *)sendCodeUrlConfigWith:(NSDictionary *)params {
    return [self configWithUrl:[[RCSLoginConfig baseUrl] stringByAppendingPathComponent:@"user/sendCode"]
                  rspClassName:nil
                        method:RCSHTTPRequestMethodPOST
                        params:params
                       headers:[self login_commonHeaders]];
}

+ (NSDictionary *)login_commonHeaders{
    NSMutableDictionary *header = @{@"Content-Type":@"application/json"}.mutableCopy;
    if ([RCSLoginConfig bussinessToken].length != 0) {
        [header addEntriesFromDictionary:@{@"BusinessToken":[RCSLoginConfig bussinessToken]}];
    }
    return header.copy;
}

@end


//  RCSNetworkDataHandler+Login.h
@interface RCSNetworkDataHandler (Login)

/// 登录验证码
- (void)sendCodeWithParams:(NSDictionary * _Nullable)params
           completionBlock:(RCSNetworkCompletion _Nullable)completionBlock;


@end

//  RCSNetworkDataHandler+Login.m
@implementation RCSNetworkDataHandler (Login)

/// 登录验证码
- (void)sendCodeWithParams:(NSDictionary * _Nullable)params
           completionBlock:(RCSNetworkCompletion _Nullable)completionBlock {
    RCSNetworkConfig *config = [RCSNetworkConfig sendCodeUrlConfigWith:params];
    [self requestWithUrlConfig:config completion:completionBlock];
}

@end

Author

彭蕾, [email protected]

License

RCSceneNetworkKit is available under the MIT license. See the LICENSE file for more info.