NetworkRequestClassManager.h 3.1 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

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

16 17
//上传图片返回当前进度
typedef void (^UploadprogressBlock)(double progress);
曹云霄's avatar
曹云霄 committed
18 19

//定义请求类型
20
typedef NS_ENUM(NSInteger,NetworkRequestType){
21 22
    POST = 0, //POST
    GET,       //GET
23
    NetworkRequestWithDELETE    //DELETE
24
};
曹云霄's avatar
曹云霄 committed
25 26 27 28 29 30 31 32 33


@interface NetworkRequestClassManager : NSObject

/**
 *  网络请求单例
 *
 *  @return NetworkRequestClassManager
 */
34
+ (NetworkRequestClassManager *)manager;
曹云霄's avatar
曹云霄 committed
35 36 37


/**
38
 *  网络请求传入JSONModel对象
曹云霄's avatar
曹云霄 committed
39 40 41
 *
 *  @param requestURLString     网址
 *  @param requestType          请求类型
42
 *  @param parameter            JSONModel对象
曹云霄's avatar
曹云霄 committed
43 44 45 46
 *  @param sueecssBlock         成功回调
 *  @param errorCodeBlock       错误编码回调
 *  @param failureBlock         失败回调
 */
47 48 49 50 51
- (void)networkRequestWithURL:(NSString *) requestURLString
                  withRequestType:(NetworkRequestType) requestType
                    withParameter:(JSONModel *) jastorobject
             withReturnValueBlock:(ReturnValueBlock) successBlock
                 withFailureBlock:(FailureBlock) failureBlock;
曹云霄's avatar
曹云霄 committed
52 53


曹云霄's avatar
曹云霄 committed
54
/**
55
 *  网络请求传入字典对象
曹云霄's avatar
曹云霄 committed
56 57 58 59 60 61 62 63
 *
 *  @param requestURLString     网址
 *  @param requestType          请求类型
 *  @param parameter            字典对象
 *  @param sueecssBlock         成功回调
 *  @param errorCodeBlock       错误编码回调
 *  @param failureBlock         失败回调
 */
64 65 66 67 68
- (void)networkWithDictionaryRequestWithURL:(NSString *) requestURLString
              withRequestType:(NetworkRequestType) requestType
                withParameter:(NSDictionary *) parameter
         withReturnValueBlock:(ReturnValueBlock) successBlock
             withFailureBlock:(FailureBlock) failureBlock;
曹云霄's avatar
曹云霄 committed
69

勾芒's avatar
勾芒 committed
70 71 72 73 74 75 76 77
/**
 *  下载PDF
 *
 *  @param requestURLString 网址
 *  @param successBlock     成功回调
 *  @param errorCodeBlock   错误编码回到
 *  @param failureBlock     失败回调
 */
78 79 80
- (void)downloadPDFdatasWithURL:(NSString *) requestURLString
           withReturnValueBlock:(ReturnValueBlock) successBlock
               withFailureBlock:(FailureBlock) failureBlock;
曹云霄's avatar
曹云霄 committed
81

82 83 84 85 86 87 88 89 90 91 92 93
/**
 *  上传分享图片
 *
 *  @param requestURLString 网址
 *  @param requestType      请求类型
 *  @param parameter        参数
 *  @param successBlock     成功回调
 *  @param progressBlock    上传进度
 *  @param errorCodeBlock   错误编码回调
 *  @param failureBlock     失败回调
 */

94 95 96 97 98 99 100
- (void)uploadImageWithURL:(NSString *) requestURLString
           withRequestType:(NetworkRequestType) requestType
            withImageDatas:(NSData *) imagedata
             withParameter:(NSDictionary *) parameter
      withReturnValueBlock:(ReturnValueBlock) successBlock
         withprogressBlock:(UploadprogressBlock) progressBlock
          withFailureBlock:(FailureBlock) failureBlock;
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120




















曹云霄's avatar
曹云霄 committed
121 122

@end