Class: TroveOAuth::Client

Inherits:
Object
  • Object
show all
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

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(options = {})
  @consumer_key = options[:consumer_key]
  @consumer_secret = options[:consumer_secret]
  @token = options[:token]
  @secret = options[:secret]
  @proxy = options[:proxy]
end

Instance Method Details

#access_tokenObject



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

Raises:



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(options={})
  consumer.options[:authorize_path] = '/oauth/authenticate'
  request_token(options)
end

#authorize(token, secret, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/trove_oauth/client.rb', line 12

def authorize(token, secret, options = {})
  request_token = OAuth::RequestToken.new(
    consumer, token, secret
  )
  @access_token = request_token.get_access_token(options)
  @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

#infoObject



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(options={})
  consumer.get_request_token(options)
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

#servicesObject



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

#testObject

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