Class: VerticalResponse::API::OAuth

Inherits:
Client
  • Object
show all
Defined in:
lib/oauth.rb

Instance Attribute Summary

Attributes inherited from Client

#response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

add_default_query_param, build_params, build_query_params, config, default_query_params, embed_resource, resource_uri

Constructor Details

#initialize(access_token) ⇒ OAuth

Returns a new instance of OAuth.



15
16
17
# File 'lib/oauth.rb', line 15

def initialize(access_token)
  @access_token = access_token
end

Class Method Details

.access_token(auth_code, redirect_uri = "", client_id = "", client_secret = "") ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/oauth.rb', line 50

def access_token(auth_code,
                 redirect_uri = "",
                 client_id = "",
                 client_secret = "")
  get(
    resource_uri('access_token'),
    build_query_params({
      :client_id => client_id,
      :client_secret => client_secret,
      :code => auth_code,
      :redirect_uri => redirect_uri
    })
  )
end

.assign_headers(*args) ⇒ Object

Overwrite this method as we don’t need to setup headers for OAuth calls



34
35
# File 'lib/oauth.rb', line 34

def assign_headers(*args)
end

.authorize(redirect_uri = "", client_id = "") ⇒ Object

client_id is the application key



43
44
45
46
47
48
# File 'lib/oauth.rb', line 43

def authorize(redirect_uri = "", client_id = "")
  get(
    resource_uri('authorize'),
    build_query_params({ :client_id => client_id, :redirect_uri => redirect_uri })
  )
end

.base_uri(*args) ⇒ Object

Base URI for the OAuth calls



38
39
40
# File 'lib/oauth.rb', line 38

def base_uri(*args)
  @base_uri ||= File.join(super.to_s, 'oauth')
end

Instance Method Details

#contactsObject



23
24
25
# File 'lib/oauth.rb', line 23

def contacts
  VerticalResponse::API::Contact.all({"access_token" => @access_token})
end

#get_list(list_id) ⇒ Object



27
28
29
# File 'lib/oauth.rb', line 27

def get_list(list_id)
  VerticalResponse::API::List.find(list_id, {"access_token" => @access_token})
end

#listsObject



19
20
21
# File 'lib/oauth.rb', line 19

def lists
  VerticalResponse::API::List.all({"access_token" => @access_token})
end