Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #39 from coinbase/timeout-variable
Browse files Browse the repository at this point in the history
Added request TimeoutInterval variable.
  • Loading branch information
janechung committed Feb 18, 2016
2 parents 3038776 + 1fbb788 commit 5763716
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Example/coinbase/CoinbaseCurrenciesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions Pod/Classes/Client/Coinbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion Pod/Classes/Client/Coinbase.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ @interface Coinbase ()

@end

static NSNumber * __strong requestTimeoutInterval;

@implementation Coinbase

+ (Coinbase *)coinbaseWithOAuthAccessToken:(NSString *)accessToken {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion coinbase-official.podspec
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 5763716

Please sign in to comment.