Class: TroveOAuth::Client
- Inherits:
-
Object
- Object
- TroveOAuth::Client
- Defined in:
- lib/trove_oauth/client.rb,
lib/trove_oauth/photos.rb,
lib/trove_oauth/account.rb,
lib/trove_oauth/services.rb
Instance Method Summary collapse
- #access_token ⇒ Object
- #add_photo(photo) ⇒ Object
- #authentication_request_token(options = {}) ⇒ Object
- #authorize(token, secret, options = {}) ⇒ Object
- #evil_send(method, params) ⇒ Object
- #info ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #list_photos(params = {}) ⇒ Object
- #request_token(options = {}) ⇒ Object
- #service(service) ⇒ Object
- #service_bounceback_url(service, redirect_url) ⇒ Object
- #services ⇒ Object
- #show(username) ⇒ Object
-
#test ⇒ Object
Returns the string “ok” in the requested format with a 200 OK HTTP status code.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 10 |
# File 'lib/trove_oauth/client.rb', line 4 def initialize( = {}) @consumer_key = [:consumer_key] @consumer_secret = [:consumer_secret] @token = [:token] @secret = [:secret] @proxy = [:proxy] end |
Instance Method Details
#access_token ⇒ Object
42 43 44 |
# File 'lib/trove_oauth/client.rb', line 42 def access_token @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret) end |
#add_photo(photo) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/trove_oauth/photos.rb', line 4 def add_photo(photo) raise InternalError.new("Supplied photo must be of type TroveOAuth::Photo") unless photo.is_a? Photo end |
#authentication_request_token(options = {}) ⇒ Object
35 36 37 38 |
# File 'lib/trove_oauth/client.rb', line 35 def authentication_request_token(={}) consumer.[:authorize_path] = '/oauth/authenticate' request_token() end |
#authorize(token, secret, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/trove_oauth/client.rb', line 12 def (token, secret, = {}) request_token = OAuth::RequestToken.new( consumer, token, secret ) @access_token = request_token.get_access_token() @token = @access_token.token @secret = @access_token.secret @access_token end |
#evil_send(method, params) ⇒ Object
7 8 9 |
# File 'lib/trove_oauth/account.rb', line 7 def evil_send(method, params) self.send(method, *params) end |
#info ⇒ Object
3 4 5 |
# File 'lib/trove_oauth/account.rb', line 3 def info get("/v2/user/") end |
#list_photos(params = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/trove_oauth/photos.rb', line 11 def list_photos(params = {}) if params[:query_object] else params[:tags] = params[:tags].join(',') if params[:tags].is_a? Array params[:services] = params[:services].join(',') if params[:services].is_a? Array query_string = params.map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}.join("&") get("/v2/content/photos/?#{query_string}") end end |
#request_token(options = {}) ⇒ Object
31 32 33 |
# File 'lib/trove_oauth/client.rb', line 31 def request_token(={}) consumer.get_request_token() end |
#service(service) ⇒ Object
7 8 9 |
# File 'lib/trove_oauth/services.rb', line 7 def service(service) get("/v2/services/#{service}/") end |
#service_bounceback_url(service, redirect_url) ⇒ Object
11 12 13 |
# File 'lib/trove_oauth/services.rb', line 11 def service_bounceback_url(service, redirect_url) SITE + get_without_json("/v2/services/#{service}/bounceback") end |
#services ⇒ Object
3 4 5 |
# File 'lib/trove_oauth/services.rb', line 3 def services get("/v2/services/") end |
#show(username) ⇒ Object
22 23 24 |
# File 'lib/trove_oauth/client.rb', line 22 def show(username) get("/users/show/#{username}.json") end |
#test ⇒ Object
Returns the string “ok” in the requested format with a 200 OK HTTP status code.
27 28 29 |
# File 'lib/trove_oauth/client.rb', line 27 def test get("/help/test.json") end |