//
//  SaveApplicationsHttpCmd+Response.m
//  MobilePortal
//
//  Created by xiejiangbo on 2019/3/26.
//  Copyright © 2019 yin chen. All rights reserved.
//

#import "SaveApplicationsHttpCmd+Response.h"
#import "SaveApplicationsHttpResult.h"

@protocol SaveApplicationsHttpResultData;
@interface SaveApplicationsHttpResultData : JSONModel
@property NSString<Optional>*result;
@property NSString<Optional>*message;
@end
@implementation SaveApplicationsHttpResultData
@synthesize description;
@end


@interface SaveApplicationsHttpResult()
@property SaveApplicationsHttpResultData *data;
@end


@implementation SaveApplicationsHttpCmd (Response)
- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    SaveApplicationsHttpResult *result = [[SaveApplicationsHttpResult alloc]init];
    result = (SaveApplicationsHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[SaveApplicationsHttpResultData 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 SaveApplicationsHttpResult
- (NSMutableArray *)getSaveApplicationsHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    if ([[self getNilString:self.data.result] isEqualToString:@"1"]) {
        [httpArray addObject:[self getNilString:self.data.result]];
    }
    return httpArray;
}
@end

