Class: MyJohnDeereApi::Consumer
- Inherits:
-
Object
- Object
- MyJohnDeereApi::Consumer
- Defined in:
- lib/my_john_deere_api/consumer.rb
Constant Summary collapse
- URLS =
valid API urls
{ sandbox: 'https://sandboxapi.deere.com', live: 'https://api.soa-proxy.deere.com', }
- DEFAULTS =
{ environment: :live }
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
-
#app_get ⇒ Object
oAuth Consumer which uses just the base url, for app-wide, non user-specific GET requests.
-
#initialize(api_key, api_secret, options = {}) ⇒ Consumer
constructor
A new instance of Consumer.
-
#user_get ⇒ Object
oAuth Consumer which uses the proper url for user-specific GET requests.
Constructor Details
#initialize(api_key, api_secret, options = {}) ⇒ Consumer
Returns a new instance of Consumer.
18 19 20 21 22 23 24 25 26 |
# File 'lib/my_john_deere_api/consumer.rb', line 18 def initialize(api_key, api_secret, ={}) = DEFAULTS.merge() @api_key = api_key @api_secret = api_secret self.environment = [:environment] @base_url = [:base_url] || URLS[@environment] end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/my_john_deere_api/consumer.rb', line 6 def api_key @api_key end |
#api_secret ⇒ Object (readonly)
Returns the value of attribute api_secret.
6 7 8 |
# File 'lib/my_john_deere_api/consumer.rb', line 6 def api_secret @api_secret end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/my_john_deere_api/consumer.rb', line 6 def base_url @base_url end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
6 7 8 |
# File 'lib/my_john_deere_api/consumer.rb', line 6 def environment @environment end |
Instance Method Details
#app_get ⇒ Object
oAuth Consumer which uses just the base url, for app-wide, non user-specific GET requests.
32 33 34 |
# File 'lib/my_john_deere_api/consumer.rb', line 32 def app_get @app_get ||= consumer(base_url) end |
#user_get ⇒ Object
oAuth Consumer which uses the proper url for user-specific GET requests.
39 40 41 |
# File 'lib/my_john_deere_api/consumer.rb', line 39 def user_get @user_get ||= consumer("#{base_url}/platform") end |