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

#import "XiaocaiQueryAppXinfoHttpPostCmd+Response.h"
#import "XiaocaiQueryAppXinfoHttpPostCmd.h"
#import "XiaocaiQueryAppXinfoHttpResult.h"

@protocol XiaocaiQueryAppXinfoHttpResultDataData;
@interface XiaocaiQueryAppXinfoHttpResultDataData : JSONModel
@property NSString<Optional>*applicationid;
@property NSString<Optional>*createby;
@property NSString<Optional>*updateby;
@property NSString<Optional>*status;
@property NSString<Optional>*iconurl;
@property NSString<Optional>*partstate;
@property NSString<Optional>*belong;
@property NSString<Optional>*hurl;
@property NSString<Optional>*iosurl;
@property NSString<Optional>*name;
@property NSString<Optional>*hversion;
@property NSString<Optional>*createon;
@property NSString<Optional>*updateon;
@property NSString<Optional>*companystate;
@property NSString<Optional>*androidurl;
@property NSString<Optional>*scope;
@property NSString<Optional>*scopes;
@property NSString<Optional>*androidversion;
@property NSString<Optional>*pointstate;
@property NSString<Optional>*platforms;
@property NSString<Optional>*empuidstate;
@property NSString<Optional>*passstate;
@property NSString<Optional>*iosversion;
@property NSString<Optional>*introduce;
@property NSString<Optional>*htitle;
@property NSString<Optional>*androidname;
@property NSString<Optional>*androidcontent;
@property NSString<Optional>*iosbundieid;
@property NSString<Optional>*iosopenurl;
@property NSString<Optional>*ioscontent;
@property NSString<Optional>*hcontent;


@property NSString<Optional>*value1;
@property NSString<Optional>*value2;
@property NSString<Optional>*value3;
@property NSString<Optional>*value4;
@property NSString<Optional>*value5;
@end
@implementation XiaocaiQueryAppXinfoHttpResultDataData
@synthesize description;
@end


@protocol XiaocaiQueryAppXinfoHttpResultData;
@interface XiaocaiQueryAppXinfoHttpResultData : JSONModel
@property NSMutableArray<Optional,XiaocaiQueryAppXinfoHttpResultDataData> *data;
@property NSString<Optional>*msg;
@property NSString<Optional>*code;
@property NSString<Optional>*success;
@end
@implementation XiaocaiQueryAppXinfoHttpResultData
@synthesize description;
@end

@interface XiaocaiQueryAppXinfoHttpResult()
@property XiaocaiQueryAppXinfoHttpResultData *data;
@end

@implementation XiaocaiQueryAppXinfoHttpPostCmd (Response)

- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    XiaocaiQueryAppXinfoHttpResult *result = [[XiaocaiQueryAppXinfoHttpResult alloc]init];
    result = (XiaocaiQueryAppXinfoHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[XiaocaiQueryAppXinfoHttpResultData 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 XiaocaiQueryAppXinfoHttpResult
- (NSMutableArray *)getXiaocaiQueryAppXinfoHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    for (int index = 0; index < self.data.data.count; index ++) {
        ApplicationHttpListModel *listModel = [[ApplicationHttpListModel alloc]init];
        XiaocaiQueryAppXinfoHttpResultDataData *httpModel = self.data.data[index];
        listModel.applicationid = [self getNilString:httpModel.applicationid];
        listModel.createby = [self getNilString:httpModel.createby];
        listModel.updateby = [self getNilString:httpModel.updateby];
        listModel.status = [self getNilString:httpModel.status];
        listModel.iconurl = [self getNilString:httpModel.iconurl];
        listModel.imageUrl = [self getImageUrl:listModel.iconurl];
        listModel.partstate = [self getNilString:httpModel.partstate];
        listModel.belong = [self getNilString:httpModel.belong];
        //        listModel.belong = [self getNilString:httpModel.tags];
        
        listModel.hurl = [self getNilString:httpModel.hurl];
        listModel.iosurl = [self getNilString:httpModel.iosurl];
        listModel.name = [self getNilString:httpModel.name];
        listModel.name = [self getNilString:httpModel.name];
        //        NSLog(@"%@",listModel.name);
        listModel.hversion = [self getNilString:httpModel.hversion];
        listModel.createon = [self getNilString:httpModel.createon];
        listModel.updateon = [self getNilString:httpModel.updateon];
        listModel.companystate = [self getNilString:httpModel.companystate];
        listModel.androidurl = [self getNilString:httpModel.androidurl];
        listModel.scope = [self getNilString:httpModel.scope];
        listModel.scopes = [self getNilString:httpModel.scopes];
        listModel.androidversion = [self getNilString:httpModel.androidversion];
        listModel.pointstate = [self getNilString:httpModel.pointstate];
        listModel.platforms = [self getNilString:httpModel.platforms];
        listModel.empuidstate = [self getNilString:httpModel.empuidstate];
        listModel.passstate = [self getNilString:httpModel.passstate];
        listModel.iosversion = [self getNilString:httpModel.iosversion];
        listModel.introduce = [self getNilString:httpModel.introduce];
        listModel.ioscontent = [self getNilString:httpModel.ioscontent];
        listModel.iosbundieid = [self getNilString:httpModel.iosbundieid];
        listModel.iosopenurl = [self getNilString:httpModel.iosopenurl];
        if ([listModel.iosopenurl rangeOfString:@"://"].location == NSNotFound && ![listModel.iosopenurl isEqualToString:@""]) {
            listModel.iosopenurl = [NSString stringWithFormat:@"%@://",listModel.iosopenurl];
        }
        listModel.androidname = [self getNilString:httpModel.androidname];
        listModel.androidcontent = [self getNilString:httpModel.androidcontent];
        listModel.hcontent = [self getNilString:httpModel.hcontent];
        listModel.htitle = [self getNilString:httpModel.htitle];
        
        listModel.value1 = [self getNilString:httpModel.value1];
        listModel.value2 = [self getNilString:httpModel.value2];
        listModel.value3 = [self getNilString:httpModel.value3];
        listModel.value4 = [self getNilString:httpModel.value4];
        listModel.value5 = [self getNilString:httpModel.value5];
        [httpArray addObject:listModel];
    }
    
    return httpArray;
}
@end
