//
//  ClickRateHttpCmd+Response.m
//  MobilePortal
//
//  Created by xiejiangbo on 2020/1/15.
//  Copyright © 2020 yin chen. All rights reserved.
//

#import "ClickRateHttpCmd+Response.h"
#import "ClickRateHttpCmd.h"
#import "ClickRateHttpResult.h"

@protocol ClickRateHttpResultData;
@interface ClickRateHttpResultData : JSONModel
@property NSString<Optional>*isLastPage;
@property NSString<Optional>*pageNum;
@property NSString<Optional>*pages;
@property NSString<Optional>*pageSize;
@property NSString<Optional>*size;
@property NSString<Optional>*status;
@end
@implementation ClickRateHttpResultData
@synthesize description;
@end


@interface ClickRateHttpResult()
@property ClickRateHttpResultData *data;
@end


@implementation ClickRateHttpCmd (Response)

- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    ClickRateHttpResult *result = [[ClickRateHttpResult alloc]init];
    result = (ClickRateHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[ClickRateHttpResultData alloc]initWithDictionary:dic error:(NSError **)&error];
        if(error){
            [self onRequestFailed:error];
            return;
        }
    }else{
        NSString *memo = [dic objectForKey:@"error_description"];
        [self.result setResultState:kRequestResultFail];
        [self.result setErrMsg:memo];
        NSLog(@"code :%ld errormsg:%@",(long)code,memo);
    }
}

- (void)onRequestFailed:(NSError *)error{
    NSLog(@"Error===%@",error);
    [self.result setErrMsg:[error localizedDescription]];
    [self.result setResultState:kRequestResultFail];
}


@end
@implementation ClickRateHttpResult
- (NSMutableArray *)getClickRateHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    
    return httpArray;
}
@end
