samhuri.net-ios/Blog/JSONHTTPClient.h
2015-03-29 23:42:04 -07:00

33 lines
1 KiB
Objective-C

//
// JSONHTTPClient.h
// Blog
//
// Created by Sami Samhuri on 2014-11-23.
// Copyright (c) 2014 Guru Logic Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <PromiseKit/PromiseKit.h>
extern NSString * const JSONHTTPClientErrorDomain;
typedef enum : NSUInteger {
JSONHTTPClientErrorCodeWTF,
JSONHTTPClientErrorCodeInvalidResponse,
JSONHTTPClientErrorCodeRequestFailed
} JSONHTTPClientErrorCode;
@interface JSONHTTPClient : NSObject
@property (nonatomic, strong) NSDictionary *defaultHeaders;
- (instancetype)initWithSession:(NSURLSession *)session;
- (PMKPromise *)request:(NSURLRequest *)request;
- (PMKPromise *)get:(NSURL *)url headers:(NSDictionary *)headers;
- (PMKPromise *)putJSON:(NSURL *)url headers:(NSDictionary *)headers fields:(NSDictionary *)fields;
- (PMKPromise *)postJSON:(NSURL *)url headers:(NSDictionary *)headers fields:(NSDictionary *)fields;
- (PMKPromise *)post:(NSURL *)url headers:(NSDictionary *)headers;
- (PMKPromise *)delete:(NSURL *)url headers:(NSDictionary *)headers;
@end