Permalink
Browse files

single user mode: set global OAuth credentials, so you don't have to …

…specify on every call
  • Loading branch information...
1 parent a2209dd commit a79fc67969a56ea57109eb9a1689fb42fda99439 @plainlystated committed Feb 25, 2012
Showing with 14 additions and 2 deletions.
  1. +12 −0 lib/etsy.rb
  2. +2 −2 lib/etsy/request.rb
View
@@ -143,6 +143,18 @@ def self.verification_url
verification_request.url
end
+ def self.single_user(access_token, access_secret)
+ @credentials = {
+ :access_token => access_token,
+ :access_secret => access_secret
+ }
+ nil
+ end
+
+ def self.credentials
+ @credentials || {}
+ end
+
private
def self.verification_request
View
@@ -20,8 +20,8 @@ def self.post(resource_path, parameters = {})
# Create a new request for the resource with optional parameters
def initialize(resource_path, parameters = {})
- @token = parameters.delete(:access_token)
- @secret = parameters.delete(:access_secret)
+ @token = parameters.delete(:access_token) || Etsy.credentials[:access_token]
+ @secret = parameters.delete(:access_secret) || Etsy.credentials[:access_secret]
raise("Secure connection required. Please provide your OAuth credentials via :access_token and :access_secret in the parameters") if parameters.delete(:require_secure) && !secure?
@resource_path = resource_path
@resources = parameters.delete(:includes)

0 comments on commit a79fc67

Please sign in to comment.