//
//  IdmLogSaveHttpPostCmd+Response.m
//  MobilePortal
//
//  Created by caiyang on 2020/12/1.
//  Copyright © 2020 yin chen. All rights reserved.
//

#import "IdmLogSaveHttpPostCmd+Response.h"
#import "IdmLogSaveHttpPostCmd.h"
#import "IdmLogSaveHttpResult.h"

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

@interface IdmLogSaveHttpResult()
@property IdmLogSaveHttpResultData *data;
@end



@implementation IdmLogSaveHttpPostCmd (Response)

- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    IdmLogSaveHttpResult *result = [[IdmLogSaveHttpResult alloc]init];
    result = (IdmLogSaveHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[IdmLogSaveHttpResultData 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 IdmLogSaveHttpResult
- (NSMutableArray *)getIdmLogSaveHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
   
    return httpArray;
}
@end
