//
//  UpcomingCountHttpPostCmd+Response.m
//  MobilePortal
//
//  Created by caiyang on 2020/5/6.
//  Copyright © 2020 yin chen. All rights reserved.
//

#import "UpcomingCountHttpPostCmd+Response.h"
#import "UpcomingCountHttpPostCmd.h"
#import "UpcomingCountHttpResult.h"

@protocol UpcomingCountHttpResultDataData;
@interface UpcomingCountHttpResultDataData : JSONModel
//@property NSMutableArray<Optional,UpcomingSystemHttpResultDataData> *data;
@property NSString<Optional>*ytotal;
@property NSString<Optional>*dtotal;
@end
@implementation UpcomingCountHttpResultDataData
@synthesize description;
@end

@protocol UpcomingCountHttpResultData;
@interface UpcomingCountHttpResultData : JSONModel
@property UpcomingCountHttpResultDataData *data;
@property NSString<Optional>*msg;
@property NSString<Optional>*code;
@end
@implementation UpcomingCountHttpResultData
@synthesize description;
@end

@interface UpcomingCountHttpResult()
@property UpcomingCountHttpResultData *data;
@end


@implementation UpcomingCountHttpPostCmd (Response)
- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    UpcomingCountHttpResult *result = [[UpcomingCountHttpResult alloc]init];
    result = (UpcomingCountHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[UpcomingCountHttpResultData 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 UpcomingCountHttpResult
- (NSMutableArray *)getUpcomingCountHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    UpcomingCountModel *model = [[UpcomingCountModel alloc]init];
    model.ytotal = [self getNilString:self.data.data.ytotal];
    model.dtotal = [self getNilString:self.data.data.dtotal];
    [httpArray addObject:model];
    return httpArray;
}
@end
