//
// NetUtils.h
// GotoBus
//
// Created by haibara on 1/4/15.
//
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFHTTPSessionManager.h>
#import <AFNetworking/AFURLResponseSerialization.h>

#define NetworkSettingErrorDomain AFURLResponseSerializationErrorDomain

FOUNDATION_EXTERN NSString *const NetworkSettingRequestDataType;
FOUNDATION_EXTERN NSString *const NetworkSettingRequestEncoding;
FOUNDATION_EXTERN NSString *const NetworkSettingRequestTimeout;
FOUNDATION_EXTERN NSString *const NetworkSettingResponseDataType;
FOUNDATION_EXTERN NSString *const NetworkSettingResponseDecoding;

@interface AFEncodedTEXTResponseSerializer : AFHTTPResponseSerializer
@end

@interface AFEncodedJSONResponseSerializer : AFJSONResponseSerializer
@end

@interface NetUtils : NSObject

+ (void)beginTransation;
+ (void)adviceSettings:(NSDictionary *)settings;

// SOAP
+ (id)performRequest:(NSURLRequest *)request settings:(NSDictionary *)settings done:(void (^)(id responseObject)) done fail:(void (^)(NSError *error)) fail always:(void (^)(void))always;
+ (id)performRequestWithMethod:(NSString *)method url:(NSString *)url parameters:(NSDictionary *)parameters settings:(NSDictionary *)settings done:(void (^)(id responseObject)) done fail:(void (^)(NSError *error)) fail always:(void (^)(void))always;
+ (id)performUploadMultipartRequestConstructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData)) block progress:(void (^)(CGFloat uploadProgress)) uploadProgressBlock url:(NSString *)url parameters:(id)parameters settings:(NSDictionary *)settings done:(void (^)(id responseObject)) done fail:(void (^)(NSError *error)) fail always:(void (^)(void))always;
+ (void)performBatchOf:(NSArray *)array completion:(void (^)(void))completion;

@end
