NetworkRequestClassManager.h 3.51 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1 2 3 4 5 6 7 8 9
//
//  NetworkRequestClassManager.h
//  Lighting
//
//  Created by 曹云霄 on 16/4/28.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import <Foundation/Foundation.h>
10
#import "opple_objc_json_client.h"
曹云霄's avatar
曹云霄 committed
11 12 13 14

//定义返回数据的block类型
typedef void (^ReturnValueBlock) (id returnValue);
typedef void (^ErrorCodeBlock) (id errorCodeValue);
15
typedef void (^FailureBlock)(NSError *error);
曹云霄's avatar
曹云霄 committed
16

17 18
//上传图片返回当前进度
typedef void (^UploadprogressBlock)(double progress);
曹云霄's avatar
曹云霄 committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

//定义请求类型
typedef enum {
    
    NetworkRequestWithPOST = 0, //POST
    NetworkRequestWithGET       //GET
    
}NetworkRequestType;


@interface NetworkRequestClassManager : NSObject

/**
 *  网络请求单例
 *
 *  @return NetworkRequestClassManager
 */
+ (NetworkRequestClassManager *)Manager;


/**
40
 *  网络请求传入JSONModel对象
曹云霄's avatar
曹云霄 committed
41 42 43
 *
 *  @param requestURLString     网址
 *  @param requestType          请求类型
44
 *  @param parameter            JSONModel对象
曹云霄's avatar
曹云霄 committed
45 46 47 48 49
 *  @param sueecssBlock         成功回调
 *  @param errorCodeBlock       错误编码回调
 *  @param failureBlock         失败回调
 */
- (void)NetworkRequestWithURL:(NSString *) requestURLString
50
                WithCallClass:(BaseViewController *)object
曹云霄's avatar
曹云霄 committed
51
                  WithRequestType:(NetworkRequestType) requestType
曹云霄's avatar
曹云霄 committed
52
                    WithParameter:(JSONModel *) jastorobject
曹云霄's avatar
曹云霄 committed
53 54 55 56 57 58 59 60 61
             WithReturnValueBlock:(ReturnValueBlock) successBlock
              WithErrorCodeBlock:(ErrorCodeBlock) errorCodeBlock
                 WithFailureBlock:(FailureBlock) failureBlock;






曹云霄's avatar
曹云霄 committed
62
/**
63
 *  网络请求传入字典对象
曹云霄's avatar
曹云霄 committed
64 65 66 67 68 69 70 71 72
 *
 *  @param requestURLString     网址
 *  @param requestType          请求类型
 *  @param parameter            字典对象
 *  @param sueecssBlock         成功回调
 *  @param errorCodeBlock       错误编码回调
 *  @param failureBlock         失败回调
 */
- (void)NetworkWithDictionaryRequestWithURL:(NSString *) requestURLString
73
                WithCallClass:(BaseViewController *)object
曹云霄's avatar
曹云霄 committed
74 75 76 77 78
              WithRequestType:(NetworkRequestType) requestType
                WithParameter:(NSDictionary *) parameter
         WithReturnValueBlock:(ReturnValueBlock) successBlock
           WithErrorCodeBlock:(ErrorCodeBlock) errorCodeBlock
             WithFailureBlock:(FailureBlock) failureBlock;
曹云霄's avatar
曹云霄 committed
79 80 81



勾芒's avatar
勾芒 committed
82 83 84 85 86 87 88 89 90 91 92 93
/**
 *  下载PDF
 *
 *  @param requestURLString 网址
 *  @param successBlock     成功回调
 *  @param errorCodeBlock   错误编码回到
 *  @param failureBlock     失败回调
 */
- (void)DownloadPDFdatasWithURL:(NSString *) requestURLString
           WithReturnValueBlock:(ReturnValueBlock) successBlock
             WithErrorCodeBlock:(ErrorCodeBlock) errorCodeBlock
               WithFailureBlock:(FailureBlock) failureBlock;
曹云霄's avatar
曹云霄 committed
94 95 96 97




98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138

/**
 *  上传分享图片
 *
 *  @param requestURLString 网址
 *  @param requestType      请求类型
 *  @param parameter        参数
 *  @param successBlock     成功回调
 *  @param progressBlock    上传进度
 *  @param errorCodeBlock   错误编码回调
 *  @param failureBlock     失败回调
 */

- (void)UploadImageWithURL:(NSString *) requestURLString
           WithRequestType:(NetworkRequestType) requestType
            WithImageDatas:(NSData *) imagedata
             WithParameter:(NSDictionary *) parameter
      WithReturnValueBlock:(ReturnValueBlock) successBlock
         WithprogressBlock:(UploadprogressBlock) progressBlock
        WithErrorCodeBlock:(ErrorCodeBlock) errorCodeBlock
          WithFailureBlock:(FailureBlock) failureBlock;




















曹云霄's avatar
曹云霄 committed
139 140

@end