//
//  DeactivateEnableHttpPostCmd+Response.m
//  MobilePortal
//
//  Created by caiyang on 2021/1/29.
//  Copyright © 2021 yin chen. All rights reserved.
//

#import "DeactivateEnableHttpPostCmd+Response.h"
#import "DeactivateEnableHttpPostCmd.h"
#import "DeactivateEnableHttpResult.h"




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

@interface DeactivateEnableHttpResult()
@property DeactivateEnableHttpResultData *data;
@end


@implementation DeactivateEnableHttpPostCmd (Response)

- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    DeactivateEnableHttpResult *result = [[DeactivateEnableHttpResult alloc]init];
    result = (DeactivateEnableHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[DeactivateEnableHttpResultData 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 DeactivateEnableHttpResult
- (NSMutableArray *)getDeactivateEnableHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    if ([self.data.code isEqualToString:@"200"] && [self.data.data isEqualToString:@"1"]) {
        httpArray = [NSMutableArray array];
    } else {
        [httpArray addObject:self.data.msg];
    }
    return httpArray;
}
@end
