// // GiGaAPIRequest.h // GIGA // // Created by lianxiang on 2018/8/15. // Copyright © 2018年 com.giga.ios. All rights reserved. // #import #import "GiGaAPIResult.h" @class GiGaAPIRequest; #define DEFALUT_APIREQUEST_TIMEOUT 20 typedef enum GiGaRequestType { kRequestTypeGet, kRequestTypePost, kRequestTypeUpload, kRequestTypeMultiUpload }GiGaRequestTyp; typedef enum ApiResultFormat { kApiResultJson, kApiResultXml, }ApiResultFormat; @protocol GiGaApiRquestDelegate @optional - (void)serverApiFinishedSuccessed:(GiGaAPIRequest *)api result:(GiGaAPIResult *)result; - (void)serverApiRequestFailed:(GiGaAPIRequest *)api error:(NSError *)error; - (void)serverApiFinishedFailed:(GiGaAPIRequest *)api result:(GiGaAPIResult *)result; @end @interface GiGaAPIRequest : NSObject #pragma mark - porperty /** 请求类型 */ @property (nonatomic, readonly) GiGaRequestTyp requestType; /** 请求返回的格式 */ @property (nonatomic, readonly) ApiResultFormat resultFormat; /** 请求超时时间 */ @property (nonatomic, readonly) NSTimeInterval timeout; /** 服务器地址 */ @property (nonatomic, readonly) NSString *serviceUrl; /** 请求路径 */ @property (nonatomic, readonly) NSString *fullUrl; /** 代理 */ @property (nonatomic, weak) id delegate; /** 请求参数数组 */ @property (nonatomic, strong) NSMutableArray *params; #pragma mark - Method - (id)initWithDelegate:(id)delegate; /** * 拼接公共参数 */ - (void)appendBaseParams; #pragma mark - APIRequestDelegate /** * 返回数据调用方法 */ - (void)callBackFinishedWithDictionary:(NSDictionary *)dic; /** * 返回数据错误 */ - (void)callBackFailed:(NSError *)error; @end