From ed792a9217e4f156210d032cd9d23eeafb70e7c5 Mon Sep 17 00:00:00 2001 From: Dai Hovey Date: Thu, 18 Feb 2016 11:19:12 +1100 Subject: [PATCH 1/2] Added request TimeoutInterval variable. --- Example/coinbase/CoinbaseCurrenciesViewController.swift | 2 ++ Pod/Classes/Client/Coinbase.h | 3 +++ Pod/Classes/Client/Coinbase.m | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Example/coinbase/CoinbaseCurrenciesViewController.swift b/Example/coinbase/CoinbaseCurrenciesViewController.swift index dbc914a..ad65e02 100644 --- a/Example/coinbase/CoinbaseCurrenciesViewController.swift +++ b/Example/coinbase/CoinbaseCurrenciesViewController.swift @@ -11,6 +11,8 @@ class CoinbaseCurrenciesViewController: UITableViewController { override func viewDidAppear(animated: Bool) { + Coinbase.setRequestTimeoutInterval(NSNumber(double: 15)) + // Load currencies Coinbase().getSupportedCurrencies() { (response: Array?, error: NSError?) in diff --git a/Pod/Classes/Client/Coinbase.h b/Pod/Classes/Client/Coinbase.h index 48fb1a2..6231c2a 100644 --- a/Pod/Classes/Client/Coinbase.h +++ b/Pod/Classes/Client/Coinbase.h @@ -52,6 +52,9 @@ typedef NS_ENUM(NSUInteger, CoinbaseRequestType) { /// Base URL that will be used when making API requests. Defaults to "https://api.coinbase.com/" @property (nonatomic, strong) NSURL *baseURL; +/// Set the API request's timeout interval. Defaults to 10 seconds. ++ (void)setRequestTimeoutInterval:(NSNumber *)timeoutInterval; + /// Make a GET request to the Coinbase API. - (void)doGet:(NSString *)path parameters:(NSDictionary *)parameters diff --git a/Pod/Classes/Client/Coinbase.m b/Pod/Classes/Client/Coinbase.m index 020c19b..9900e2f 100644 --- a/Pod/Classes/Client/Coinbase.m +++ b/Pod/Classes/Client/Coinbase.m @@ -35,6 +35,8 @@ @interface Coinbase () @end +static NSNumber * __strong requestTimeoutInterval; + @implementation Coinbase + (Coinbase *)coinbaseWithOAuthAccessToken:(NSString *)accessToken { @@ -83,6 +85,10 @@ - (instancetype)initWithApiKey:(NSString *)key secret:(NSString *)secret { return self; } ++ (void)setRequestTimeoutInterval:(NSNumber *)timeoutInterval { + requestTimeoutInterval = timeoutInterval; +} + - (void)requestSuccess:(NSHTTPURLResponse *)operation response:(NSData *)data completion:(CoinbaseCompletionBlock)completion { @@ -284,7 +290,8 @@ - (void)doRequestType:(CoinbaseRequestType)type NSURL *baseURL = [NSURL URLWithString:@"v1/" relativeToURL:(self.baseURL == nil ? [NSURL URLWithString:@"https://api.coinbase.com/"] : self.baseURL)]; NSURL *URL = [[NSURL URLWithString:path relativeToURL:baseURL] absoluteURL]; - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10]; + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:(requestTimeoutInterval == nil ? 10.0f : requestTimeoutInterval.doubleValue)]; + if (body) { [request setHTTPBody:body]; } From 1fbb788906c1e5ac195ddab85a3ffee72d1b8279 Mon Sep 17 00:00:00 2001 From: Dai Hovey Date: Thu, 18 Feb 2016 11:21:42 +1100 Subject: [PATCH 2/2] Bumped version to 3.2.2 --- coinbase-official.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coinbase-official.podspec b/coinbase-official.podspec index c08d5d3..275b378 100644 --- a/coinbase-official.podspec +++ b/coinbase-official.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "coinbase-official" - s.version = "3.2.1" + s.version = "3.2.2" s.summary = "Integrate bitcoin into your iOS application." s.description = <<-DESC Integrate bitcoin into your iOS application with Coinbase's fully featured bitcoin payments API. Coinbase allows all major operations in bitcoin through one API. For more information, visit https://coinbase.com/docs/api/overview.