Class: GSimpleApi::Manager
- Inherits:
-
Object
- Object
- GSimpleApi::Manager
- Defined in:
- lib/g_simple_api/manager.rb
Instance Attribute Summary collapse
-
#authorizer ⇒ Object
readonly
Returns the value of attribute authorizer.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#authorize_url(callback_url = nil) ⇒ String
Builds an URL that will be used by users to allow access to the apis.
-
#execute(action, parameters = {}) ⇒ Object
Executes call for the loaded api.
-
#get_token(code, refresh_token = false) ⇒ Hash
Processes code param and returns a valid access_token.
-
#initialize(settings, access_token = nil) ⇒ Manager
constructor
A new instance of Manager.
Constructor Details
#initialize(settings, access_token = nil) ⇒ Manager
Returns a new instance of Manager.
19 20 21 22 23 |
# File 'lib/g_simple_api/manager.rb', line 19 def initialize(settings, access_token = nil) @settings = settings @authorizer = GSimpleApi::Authorizer.new(settings) @authorizer.access_token = access_token if access_token end |
Instance Attribute Details
#authorizer ⇒ Object (readonly)
Returns the value of attribute authorizer.
17 18 19 |
# File 'lib/g_simple_api/manager.rb', line 17 def @authorizer end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
17 18 19 |
# File 'lib/g_simple_api/manager.rb', line 17 def settings @settings end |
Instance Method Details
#authorize_url(callback_url = nil) ⇒ String
Builds an URL that will be used by users to allow access to the apis.
29 30 31 32 |
# File 'lib/g_simple_api/manager.rb', line 29 def (callback_url=nil) @authorizer.callback=(callback_url) @authorizer...to_s end |
#execute(action, parameters = {}) ⇒ Object
Executes call for the loaded api.
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/g_simple_api/manager.rb', line 53 def execute(action, parameters = {}) methods = split_method(action) discovered_api = settings.discovered_api api_client = settings.api_client params = { :api_method => chained_method_calls(methods, discovered_api), :parameters => parameters } api_client.execute(params).data end |
#get_token(code, refresh_token = false) ⇒ Hash
Processes code param and returns a valid access_token.
39 40 41 42 43 44 45 46 47 |
# File 'lib/g_simple_api/manager.rb', line 39 def get_token(code, refresh_token=false) if refresh_token .refresh_token=(code) else .code= code end ..fetch_access_token! end |