Class: Openphoto::Client
- Inherits:
-
Object
- Object
- Openphoto::Client
- Defined in:
- lib/openphoto-ruby.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#access_token_secret ⇒ Object
Returns the value of attribute access_token_secret.
-
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
Instance Method Summary collapse
- #connect(method, path, params = {}) ⇒ Object
-
#initialize(hostname, consumer_key, consumer_secret, access_token, access_token_secret) ⇒ Client
constructor
A new instance of Client.
-
#prepare_access_token ⇒ Object
Exchange your oauth_token and oauth_token_secret for an AccessToken instance.
Constructor Details
#initialize(hostname, consumer_key, consumer_secret, access_token, access_token_secret) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 |
# File 'lib/openphoto-ruby.rb', line 14 def initialize(hostname, consumer_key, consumer_secret, access_token, access_token_secret) @hostname = hostname @consumer_key = consumer_key @consumer_secret = consumer_secret @access_token = access_token @access_token_secret = access_token_secret end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
12 13 14 |
# File 'lib/openphoto-ruby.rb', line 12 def access_token @access_token end |
#access_token_secret ⇒ Object
Returns the value of attribute access_token_secret.
12 13 14 |
# File 'lib/openphoto-ruby.rb', line 12 def access_token_secret @access_token_secret end |
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
12 13 14 |
# File 'lib/openphoto-ruby.rb', line 12 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
12 13 14 |
# File 'lib/openphoto-ruby.rb', line 12 def consumer_secret @consumer_secret end |
#hostname ⇒ Object
Returns the value of attribute hostname.
12 13 14 |
# File 'lib/openphoto-ruby.rb', line 12 def hostname @hostname end |
Instance Method Details
#connect(method, path, params = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/openphoto-ruby.rb', line 22 def connect(method,path,params={}) params["photo"] = Base64.encode64(File.read(params["photo"])) if params.keys.index("photo") access_token = prepare_access_token response = access_token.request(method.to_sym, path, params) response.extend Openphoto::Response return response end |
#prepare_access_token ⇒ Object
Exchange your oauth_token and oauth_token_secret for an AccessToken instance.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/openphoto-ruby.rb', line 31 def prepare_access_token consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, { :site => @hostname, :scheme => :header, :access_token_path=>"/v1/oauth/token/access", :authorize_path => "/v1/oauth/authorize", :request_token_path => "/v1/oauth/token/request" }) access_token = OAuth::AccessToken.from_hash(consumer, :oauth_token => @access_token, :oauth_token_secret => @access_token_secret) return access_token end |