//
//  SaveApplicationListHttpCmd+Response.m
//  MobilePortal
//
//  Created by xiejiangbo on 2019/10/28.
//  Copyright © 2019 yin chen. All rights reserved.
//

#import "SaveApplicationListHttpCmd+Response.h"
#import "SaveApplicationListHttpCmd.h"
#import "SaveApplicationListHttpResult.h"

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


@interface SaveApplicationListHttpResult()
@property SaveApplicationListHttpResultData *data;
@end

@implementation SaveApplicationListHttpCmd (Response)
- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    SaveApplicationListHttpResult *result = [[SaveApplicationListHttpResult alloc]init];
    result = (SaveApplicationListHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[SaveApplicationListHttpResultData 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 SaveApplicationListHttpResult
- (NSMutableArray *)getSaveApplicationListHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    if ([[self getNilString:self.data.msg] isEqualToString:@"保存成功"]) {
        [httpArray addObject:[self getNilString:self.data.msg]];
    }
    return httpArray;
}
@end
