123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // RQHTTPResponse.m
- // RQCommon
- //
- // Created by 张嵘 on 2018/11/16.
- // Copyright © 2018 张嵘. All rights reserved.
- //
- #import "RQHTTPResponse.h"
- #import "RQHTTPServiceConstant.h"
- @interface RQHTTPResponse ()
- /// The parsed RQObject object corresponding to the API response.
- /// The developer need care this data
- @property (nonatomic, readwrite, strong) id parsedResult;
- /// 自己服务器返回的状态码
- @property (nonatomic, readwrite, assign) RQHTTPResponseCode code;
- /// 自己服务器返回的信息
- @property (nonatomic, readwrite, copy) NSString *msg;
- @end
- @implementation RQHTTPResponse
- - (instancetype)initWithResponseObject:(id)responseObject parsedResult:(id)parsedResult {
- self = [super init];
- if (self) {
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- NSDictionary *dic = responseObject;
- NSMutableDictionary *mydic = dic.mutableCopy;
- if ([mydic.allKeys containsObject:@"path"]) {
- self.parsedResult = parsedResult ?:NSNull.null;
- self.code = [responseObject[RQHTTPServiceResponseCodeKey] integerValue];
- self.msg = responseObject[RQHTTPServiceResponseMsgKey];
-
- } else {
- self.parsedResult = parsedResult ?:NSNull.null;
- self.code = [responseObject[RQHTTPServiceResponseCodeKey] integerValue];
- self.msg = responseObject[RQHTTPServiceResponseMsgKey];
- }
- } else {
- self.parsedResult = parsedResult ?:NSNull.null;
- self.code = [responseObject[RQHTTPServiceResponseCodeKey] integerValue];
- self.msg = responseObject[RQHTTPServiceResponseMsgKey];
- }
-
- }
- return self;
- }
- @end
|