my_john_deere_api 2.3.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -1
  3. data/lib/my_john_deere_api.rb +2 -1
  4. data/lib/my_john_deere_api/authorize.rb +36 -27
  5. data/lib/my_john_deere_api/client.rb +45 -26
  6. data/lib/my_john_deere_api/consumer.rb +46 -35
  7. data/lib/my_john_deere_api/helpers/case_conversion.rb +5 -2
  8. data/lib/my_john_deere_api/helpers/uri_helpers.rb +1 -1
  9. data/lib/my_john_deere_api/model/contribution_definition.rb +1 -1
  10. data/lib/my_john_deere_api/net_http_retry.rb +4 -0
  11. data/lib/my_john_deere_api/net_http_retry/decorator.rb +61 -0
  12. data/lib/my_john_deere_api/net_http_retry/invalid_response_error.rb +23 -0
  13. data/lib/my_john_deere_api/net_http_retry/max_retries_exceeded_error.rb +20 -0
  14. data/lib/my_john_deere_api/request/collection/asset_locations.rb +1 -1
  15. data/lib/my_john_deere_api/request/collection/assets.rb +1 -1
  16. data/lib/my_john_deere_api/request/collection/base.rb +2 -14
  17. data/lib/my_john_deere_api/request/collection/contribution_definitions.rb +1 -1
  18. data/lib/my_john_deere_api/request/collection/contribution_products.rb +1 -1
  19. data/lib/my_john_deere_api/request/collection/fields.rb +1 -1
  20. data/lib/my_john_deere_api/request/collection/flags.rb +1 -1
  21. data/lib/my_john_deere_api/request/collection/organizations.rb +1 -1
  22. data/lib/my_john_deere_api/request/create/asset.rb +8 -11
  23. data/lib/my_john_deere_api/request/create/asset_location.rb +24 -25
  24. data/lib/my_john_deere_api/request/create/base.rb +2 -20
  25. data/lib/my_john_deere_api/request/individual/asset.rb +2 -2
  26. data/lib/my_john_deere_api/request/individual/base.rb +6 -24
  27. data/lib/my_john_deere_api/request/individual/contribution_definition.rb +1 -1
  28. data/lib/my_john_deere_api/request/individual/contribution_product.rb +1 -1
  29. data/lib/my_john_deere_api/request/individual/field.rb +1 -1
  30. data/lib/my_john_deere_api/request/individual/organization.rb +1 -1
  31. data/lib/my_john_deere_api/request/update/asset.rb +2 -2
  32. data/lib/my_john_deere_api/request/update/base.rb +1 -19
  33. data/lib/my_john_deere_api/version.rb +1 -1
  34. data/test/lib/my_john_deere_api/authorize_test.rb +37 -25
  35. data/test/lib/my_john_deere_api/client_test.rb +41 -58
  36. data/test/lib/my_john_deere_api/consumer_test.rb +16 -28
  37. data/test/lib/my_john_deere_api/helpers/uri_helpers_test.rb +0 -10
  38. data/test/lib/my_john_deere_api/model/asset_location_test.rb +0 -4
  39. data/test/lib/my_john_deere_api/model/asset_test.rb +9 -8
  40. data/test/lib/my_john_deere_api/model/base_test.rb +4 -8
  41. data/test/lib/my_john_deere_api/model/contribution_definition_test.rb +3 -7
  42. data/test/lib/my_john_deere_api/model/contribution_product_test.rb +4 -7
  43. data/test/lib/my_john_deere_api/model/field_test.rb +4 -6
  44. data/test/lib/my_john_deere_api/model/flag_test.rb +6 -7
  45. data/test/lib/my_john_deere_api/model/organization_test.rb +3 -5
  46. data/test/lib/my_john_deere_api/net_http_retry/decorator_test.rb +208 -0
  47. data/test/lib/my_john_deere_api/net_http_retry/invalid_response_error_test.rb +39 -0
  48. data/test/lib/my_john_deere_api/net_http_retry/max_retries_exceeded_error_test.rb +13 -0
  49. data/test/lib/my_john_deere_api/request/collection/asset_locations_test.rb +2 -2
  50. data/test/lib/my_john_deere_api/request/collection/assets_test.rb +2 -2
  51. data/test/lib/my_john_deere_api/request/collection/contribution_definitions_test.rb +2 -2
  52. data/test/lib/my_john_deere_api/request/collection/contribution_products_test.rb +2 -2
  53. data/test/lib/my_john_deere_api/request/collection/fields_test.rb +2 -2
  54. data/test/lib/my_john_deere_api/request/collection/flags_test.rb +2 -2
  55. data/test/lib/my_john_deere_api/request/collection/organizations_test.rb +2 -2
  56. data/test/lib/my_john_deere_api/request/create/asset_location_test.rb +3 -2
  57. data/test/lib/my_john_deere_api/request/create/asset_test.rb +5 -4
  58. data/test/lib/my_john_deere_api/request/create/base_test.rb +0 -14
  59. data/test/lib/my_john_deere_api/request/individual/asset_test.rb +2 -3
  60. data/test/lib/my_john_deere_api/request/individual/base_test.rb +0 -1
  61. data/test/lib/my_john_deere_api/request/individual/contribution_definition_test.rb +2 -3
  62. data/test/lib/my_john_deere_api/request/individual/contribution_product_test.rb +2 -3
  63. data/test/lib/my_john_deere_api/request/individual/field_test.rb +2 -3
  64. data/test/lib/my_john_deere_api/request/individual/organization_test.rb +2 -3
  65. data/test/lib/my_john_deere_api/request/update/asset_test.rb +5 -17
  66. data/test/lib/my_john_deere_api/request/update/base_test.rb +0 -14
  67. data/test/support/helper.rb +15 -5
  68. data/test/support/link_helpers.rb +14 -0
  69. data/test/support/response_helpers.rb +18 -0
  70. data/test/support/vcr/accessor/delete_failed.yml +327 -0
  71. data/test/support/vcr/accessor/delete_invalid.yml +39 -0
  72. data/test/support/vcr/accessor/delete_max_failed.yml +615 -0
  73. data/test/support/vcr/accessor/delete_retry.yml +191 -0
  74. data/test/support/vcr/accessor/delete_retry_too_soon.yml +191 -0
  75. data/test/support/vcr/accessor/get_failed.yml +390 -0
  76. data/test/support/vcr/accessor/get_invalid.yml +46 -0
  77. data/test/support/vcr/accessor/get_max_failed.yml +734 -0
  78. data/test/support/vcr/accessor/get_retry.yml +226 -0
  79. data/test/support/vcr/accessor/get_retry_too_soon.yml +226 -0
  80. data/test/support/vcr/accessor/post_failed.yml +417 -0
  81. data/test/support/vcr/accessor/post_invalid.yml +49 -0
  82. data/test/support/vcr/accessor/post_max_failed.yml +785 -0
  83. data/test/support/vcr/accessor/post_retry.yml +241 -0
  84. data/test/support/vcr/accessor/post_retry_too_soon.yml +241 -0
  85. data/test/support/vcr/accessor/put_failed.yml +372 -0
  86. data/test/support/vcr/accessor/put_invalid.yml +44 -0
  87. data/test/support/vcr/accessor/put_max_failed.yml +700 -0
  88. data/test/support/vcr/accessor/put_retry.yml +216 -0
  89. data/test/support/vcr/accessor/put_retry_too_soon.yml +216 -0
  90. data/test/support/vcr/catalog.yml +44 -37
  91. data/test/support/vcr/get_access_token.yml +90 -17
  92. data/test/support/vcr/get_refresh_token.yml +159 -0
  93. data/test/support/vcr/get_request_url.yml +51 -0
  94. data/test/support/vcr_setup.rb +80 -19
  95. metadata +39 -9
  96. data/test/support/vcr/get_request_token.yml +0 -83
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d94f50a7c306efa861fb855b0c8a90d1b070c8ad230e05fc0ba298118b5d91c4
4
- data.tar.gz: f105e3d4c42cc755db700ce5ceeaecd2a9edf2292b8ddb4ff4e559913a68fd89
3
+ metadata.gz: b36f05ba98236dbdddfcab7086fa13c6af8d673dc8c2d2c1f185abcbf0f1ceeb
4
+ data.tar.gz: d5bda4fae253a293fd58b44045eacf2b7eba8dd142560aa3813da3deb334bc7c
5
5
  SHA512:
6
- metadata.gz: d35cdcecd45fef14e1e78f454846a115c29b2c8e20543407540ca5ebd44f82e76a796e01b14fe4c02b70a725b9fad726d97d06f938dd6f00da5dcd5a779d5fe3
7
- data.tar.gz: 8b33a28e57f5e0d08bc71d975be12e7c0fc71fa596a1cceb4b2fe611c31d3a1422ac2d2b7e314a6f6bc692ef5c2a268dbb8c00158daa9eff37893cc4e24233a0
6
+ metadata.gz: 454ac16787a9448ce1fb0d5db1bc4f2b39b9c0c729552fe9c0730093d681dc442fc33b21cdbb8aea79678a1a2e1fd1bdab2ff042b931251818435cbcbd7a54e9
7
+ data.tar.gz: b90f4aa488daa2e0c99c31ede5045769f6d7cd04fce875d92375b369318845737fc5dbf9d9e4824b048980261e6ccc1880e8b4803a01cd9f0be4299d826cd491
data/README.md CHANGED
@@ -600,13 +600,74 @@ field.archived?
600
600
  # => false
601
601
 
602
602
  field.links
603
- # => a hash of API urls related to this asset
603
+ # => a hash of API urls related to this field
604
604
 
605
605
  field.flags
606
606
  # => collection of flags belonging to this field
607
607
  ```
608
608
 
609
609
 
610
+ ### [Flags](https://developer.deere.com/#!documentation&doc=.%2Fmyjohndeere%2Fflags.htm)
611
+
612
+ Handles a field's flags. Flag collections support the following methods. Note, John Deere does not provide an endpoint to retrieve a specific flag by id:
613
+
614
+ * all
615
+ * count
616
+ * first
617
+
618
+ An individual flag supports the following methods and associations:
619
+
620
+ * id
621
+ * notes
622
+ * geometry
623
+ * archived?
624
+ * proximity\_alert\_enabled?
625
+ * links
626
+
627
+ The `count` method only requires loading the first page of results, so it's a relatively cheap call. On the other hand,
628
+ `all` forces the entire collection to be loaded from John Deere's API, so use with caution. Flags can be
629
+ created via the API, but there is no `create` method on this collection yet.
630
+
631
+ ```ruby
632
+ field.flags
633
+ # => collection of flags under this field
634
+
635
+ field.flags.count
636
+ # => 15
637
+
638
+ flag = field.flags.first
639
+ # => an individual flag object
640
+
641
+ flag.notes
642
+ # => 'A big rock on the left after entering the field'
643
+
644
+ flag.geometry
645
+ # => a GeoJSON formatted hash, for example:
646
+ # {
647
+ # "type"=>"Feature",
648
+ # "geometry"=>{
649
+ # "geometries"=>[
650
+ # {
651
+ # "coordinates"=>[-95.123456, 40.123456],
652
+ # "type"=>"Point"
653
+ # }
654
+ # ],
655
+ # "type"=>"GeometryCollection"
656
+ # }
657
+ # }
658
+
659
+
660
+ field.archived?
661
+ # => false
662
+
663
+ field.proximity_alert_enabled?
664
+ # => true
665
+
666
+ field.links
667
+ # => a hash of API urls related to this flag
668
+ ```
669
+
670
+
610
671
  ## Direct API Requests
611
672
 
612
673
  While the goal of the client is to eliminate the need to make/interpret calls to the John Deere API, it's important
@@ -1,4 +1,4 @@
1
- require 'oauth'
1
+ require 'oauth2'
2
2
  require 'uri'
3
3
  require 'json'
4
4
 
@@ -13,4 +13,5 @@ module MyJohnDeereApi
13
13
  autoload :Validators, 'my_john_deere_api/validators'
14
14
 
15
15
  require 'my_john_deere_api/errors'
16
+ require 'my_john_deere_api/net_http_retry'
16
17
  end
@@ -2,10 +2,7 @@ module MyJohnDeereApi
2
2
  class Authorize
3
3
  include Helpers::EnvironmentHelper
4
4
 
5
- attr_reader :api_key, :api_secret,
6
- :request_token, :request_secret,
7
- :access_token, :access_secret,
8
- :environment, :options
5
+ attr_reader :api_key, :api_secret, :environment, :options, :token_hash
9
6
 
10
7
  DEFAULTS = {
11
8
  environment: :live
@@ -23,6 +20,9 @@ module MyJohnDeereApi
23
20
  @api_key = api_key
24
21
  @api_secret = api_secret
25
22
  self.environment = @options[:environment]
23
+
24
+ # This is only set upon verification
25
+ @token_hash = nil
26
26
  end
27
27
 
28
28
  ##
@@ -32,38 +32,47 @@ module MyJohnDeereApi
32
32
  def authorize_url
33
33
  return @authorize_url if defined?(@authorize_url)
34
34
 
35
- request_options = options.slice(:oauth_callback)
35
+ request_options = options.slice(:redirect_uri, :state, :scope)
36
+
37
+ if options.key?(:scopes)
38
+ options[:scopes] << 'offline_access' unless options[:scopes].include?('offline_access')
39
+ request_options[:scope] = options[:scopes].join(' ')
40
+ end
36
41
 
37
- requester = consumer.get_request_token(request_options)
38
- @request_token = requester.token
39
- @request_secret = requester.secret
42
+ # generate a default unique-ish "state" key if not provided
43
+ unless request_options.key?(:state)
44
+ request_options[:state] = (rand(8000) + 1000).to_s
45
+ end
40
46
 
41
- @authorize_url = requester.authorize_url(request_options)
47
+ @authorize_url = oauth_client.auth_code.authorize_url(request_options)
42
48
  end
43
49
 
44
50
  ##
45
- # API consumer that makes non-user-specific GET requests
51
+ # API client that makes authentication requests
46
52
 
47
- def consumer
48
- return @consumer if defined?(@consumer)
49
- @consumer = MyJohnDeereApi::Consumer.new(@api_key, @api_secret, environment: environment).app_get
53
+ def oauth_client
54
+ return @oauth_client if defined?(@oauth_client)
55
+ @oauth_client = MyJohnDeereApi::Consumer.new(@api_key, @api_secret, environment: environment).auth_client
50
56
  end
51
57
 
52
58
  ##
53
- # Turn a verification code into access tokens. If this is
54
- # run from a separate process than the one that created
55
- # the initial RequestToken, the request token/secret
56
- # can be passed in.
57
-
58
- def verify(code, token=nil, secret=nil)
59
- token ||= request_token
60
- secret ||= request_secret
61
-
62
- requester = OAuth::RequestToken.new(consumer, token, secret)
63
- access_object = requester.get_access_token(oauth_verifier: code)
64
- @access_token = access_object.token
65
- @access_secret = access_object.secret
66
- nil
59
+ # Turn a verification code into access token.
60
+
61
+ def verify(code)
62
+ token = oauth_client.auth_code.get_token(code, redirect_uri: options[:redirect_uri])
63
+
64
+ # normalize hash
65
+ @token_hash = JSON.parse(token.to_hash.to_json)
66
+ end
67
+
68
+ ##
69
+ # Use an old token hash to generate a new token hash.
70
+
71
+ def refresh_from_hash(old_token_hash)
72
+ old_token = OAuth2::AccessToken.from_hash(oauth_client, old_token_hash)
73
+ new_token = old_token.refresh!
74
+
75
+ new_token.to_hash
67
76
  end
68
77
  end
69
78
  end
@@ -4,26 +4,26 @@ module MyJohnDeereApi
4
4
  include Helpers::CaseConversion
5
5
 
6
6
  attr_accessor :contribution_definition_id
7
- attr_reader :api_key, :api_secret, :access_token, :access_secret
7
+ attr_reader :api_key, :api_secret, :token_hash, :http_retry_options
8
8
 
9
9
  DEFAULTS = {
10
- environment: :live
10
+ environment: :live,
11
+ http_retry: {}
11
12
  }
12
13
 
13
14
  ##
14
15
  # Creates the client with everything it needs to perform API requests.
15
- # User-specific credentials are optional, but user-specific API
16
- # requests are only possible if they are supplied.
16
+ # User-specific token_hash is optional, but user-specific API
17
+ # requests are only possible if it is supplied.
17
18
  #
18
19
  # options:
19
20
  #
20
21
  # [:environment] :sandbox or :live
21
22
  #
22
23
  # [:contribution_definition_id] optional, but needed for some requests
23
- # like asset create/update.
24
+ # like asset create/update
24
25
  #
25
- # [:access] an array with two elements, the access_token
26
- # and the access_secret of the given user
26
+ # [:token_hash] a hash used to re-create the access token
27
27
 
28
28
  def initialize(api_key, api_secret, options = {})
29
29
  options = DEFAULTS.merge(options)
@@ -31,12 +31,13 @@ module MyJohnDeereApi
31
31
  @api_key = api_key
32
32
  @api_secret = api_secret
33
33
 
34
- if options.has_key?(:access) && options[:access].is_a?(Array)
35
- @access_token, @access_secret = options[:access]
34
+ if options.has_key?(:token_hash) && options[:token_hash].is_a?(Hash)
35
+ @token_hash = options[:token_hash]
36
36
  end
37
37
 
38
38
  self.environment = options[:environment]
39
39
  @contribution_definition_id = options[:contribution_definition_id]
40
+ @http_retry_options = options[:http_retry]
40
41
  end
41
42
 
42
43
  ##
@@ -45,16 +46,40 @@ module MyJohnDeereApi
45
46
 
46
47
  def accessor
47
48
  return @accessor if defined?(@accessor)
48
- @accessor = OAuth::AccessToken.new(consumer.user_get, access_token, access_secret)
49
+
50
+ @accessor = NetHttpRetry::Decorator.new(
51
+ OAuth2::AccessToken.from_hash(oauth_client, token_hash),
52
+ http_retry_options
53
+ )
54
+ end
55
+
56
+ ##
57
+ # Returns the URI for the Contribution Definiton ID, if provided
58
+
59
+ def contribution_definition_uri
60
+ return @contribution_definition_uri if defined?(@contribution_definition_uri)
61
+
62
+ @contribution_definition_uri =
63
+ if contribution_definition_id
64
+ "#{site}/contributionDefinitions/#{contribution_definition_id}"
65
+ else
66
+ nil
67
+ end
68
+ end
69
+
70
+ ##
71
+ # Returns the base url for requests
72
+
73
+ def site
74
+ return @site if defined?(@site)
75
+ @site = accessor.client.site
49
76
  end
50
77
 
51
78
  ##
52
79
  # generic user-specific GET request method that returns JSON
53
80
 
54
81
  def get resource
55
- resource = resource.to_s
56
- resource = "/#{resource}" unless resource =~ /^\//
57
- response = accessor.get(resource, headers)
82
+ response = accessor.get(resource, headers: headers)
58
83
 
59
84
  JSON.parse(response.body)
60
85
  end
@@ -63,9 +88,7 @@ module MyJohnDeereApi
63
88
  # generic user-specific POST request method that returns JSON or response
64
89
 
65
90
  def post resource, body
66
- resource = resource.to_s
67
- resource = "/#{resource}" unless resource =~ /^\//
68
- response = accessor.post(resource, camelize(body).to_json, post_headers)
91
+ response = accessor.post(resource, body: camelize(body).to_json, headers: post_headers)
69
92
 
70
93
  if response.body && response.body.size > 0
71
94
  JSON.parse(response.body)
@@ -78,9 +101,7 @@ module MyJohnDeereApi
78
101
  # generic user-specific PUT request method that returns JSON or response
79
102
 
80
103
  def put resource, body
81
- resource = resource.to_s
82
- resource = "/#{resource}" unless resource =~ /^\//
83
- response = accessor.put(resource, camelize(body).to_json, post_headers)
104
+ response = accessor.put(resource, body: camelize(body).to_json, headers: post_headers)
84
105
 
85
106
  if response.body && response.body.size > 0
86
107
  JSON.parse(response.body)
@@ -93,9 +114,7 @@ module MyJohnDeereApi
93
114
  # generic user-specific DELETE request method that returns JSON or response
94
115
 
95
116
  def delete resource
96
- resource = resource.to_s
97
- resource = "/#{resource}" unless resource =~ /^\//
98
- response = accessor.delete(resource, headers)
117
+ response = accessor.delete(resource, headers: headers)
99
118
 
100
119
  if response.body && response.body.size > 0
101
120
  JSON.parse(response.body)
@@ -123,11 +142,11 @@ module MyJohnDeereApi
123
142
  private
124
143
 
125
144
  ##
126
- # Returns an oAuth consumer which can be used to build requests
145
+ # Returns an oAuth client which can be used to build requests
127
146
 
128
- def consumer
129
- return @consumer if defined?(@consumer)
130
- @consumer = MyJohnDeereApi::Consumer.new(@api_key, @api_secret, environment: environment)
147
+ def oauth_client
148
+ return @oauth_client if defined?(@oauth_client)
149
+ @oauth_client = MyJohnDeereApi::Consumer.new(@api_key, @api_secret, environment: environment).platform_client
131
150
  end
132
151
 
133
152
  def headers
@@ -3,12 +3,12 @@ module MyJohnDeereApi
3
3
  include Helpers::CaseConversion
4
4
  include Helpers::EnvironmentHelper
5
5
 
6
- attr_reader :api_key, :api_secret, :environment, :base_url
6
+ attr_reader :api_key, :api_secret, :environment, :site
7
7
 
8
8
  # valid API urls
9
9
  URLS = {
10
10
  sandbox: 'https://sandboxapi.deere.com',
11
- live: 'https://api.soa-proxy.deere.com',
11
+ live: 'https://partnerapi.deere.com',
12
12
  }
13
13
 
14
14
  DEFAULTS = {
@@ -22,65 +22,76 @@ module MyJohnDeereApi
22
22
  @api_secret = api_secret
23
23
 
24
24
  self.environment = options[:environment]
25
- @base_url = options[:base_url] || URLS[@environment]
25
+ @site = options[:site] || URLS[@environment]
26
26
  end
27
27
 
28
28
  ##
29
- # oAuth Consumer which uses just the base url, for
30
- # app-wide, non user-specific GET requests.
29
+ # oAuth client for platform requests
31
30
 
32
- def app_get
33
- @app_get ||= consumer(base_url)
31
+ def platform_client
32
+ return @platform_client if defined?(@platform_client)
33
+
34
+ @platform_client = OAuth2::Client.new(
35
+ api_key,
36
+ api_secret,
37
+ site: site,
38
+ headers: headers,
39
+ raise_errors: false,
40
+ )
34
41
  end
35
42
 
36
43
  ##
37
- # oAuth Consumer which uses the proper url for user-specific GET requests.
44
+ # oAuth client for user authentication
38
45
 
39
- def user_get
40
- @user_get ||= consumer("#{base_url}/platform")
41
- end
46
+ def auth_client
47
+ return @auth_client if defined?(@auth_client)
42
48
 
43
- private
49
+ # We build this without the `client` method because the authorization links
50
+ # require an extra API call to JD that is only needed for authorization.
44
51
 
45
- def consumer(site)
46
- OAuth::Consumer.new(
52
+ @auth_client = OAuth2::Client.new(
47
53
  api_key,
48
54
  api_secret,
49
55
  site: site,
50
- header: header,
51
- http_method: :get,
52
- request_token_url: links[:request_token],
53
- access_token_url: links[:access_token],
54
- authorize_url: links[:authorize_request_token]
56
+ authorize_url: authorization_links[:authorization],
57
+ token_url: authorization_links[:token],
58
+ raise_errors: false,
55
59
  )
56
60
  end
57
61
 
58
- def links
59
- return @links if defined?(@links)
62
+ private
63
+
64
+ def authorization
65
+ return @authorization if defined?(@authorization)
60
66
 
61
- catalog = OAuth::Consumer.new(api_key, api_secret)
67
+ json = OAuth2::Client.new(api_key, api_secret)
62
68
  .request(
63
69
  :get,
64
- "#{base_url}/platform/",
65
- nil,
66
- {},
67
- header
70
+ 'https://signin.johndeere.com/oauth2/aus78tnlaysMraFhC1t7/.well-known/oauth-authorization-server',
71
+ headers: headers,
72
+ raise_errors: false,
68
73
  ).body
69
74
 
70
- @links = {}
75
+ @authorization = JSON.parse(json)
76
+ end
71
77
 
72
- JSON.parse(catalog)['links'].each do |link|
73
- uri = URI.parse(link['uri'])
74
- uri.query = nil
78
+ def authorization_links
79
+ return @authorization_links if defined?(@authorization_links)
75
80
 
76
- @links[keyify(link['rel'])] = uri.to_s
77
- end
81
+ @authorization_links = {
82
+ authorization: authorization['authorization_endpoint'],
83
+ token: authorization['token_endpoint'],
84
+ organizations: "https://connections.deere.com/connections/#{api_key}/select-organizations",
85
+ }
86
+ end
78
87
 
79
- @links
88
+ def scopes
89
+ return @scopes if defined?(@scopes)
90
+ @scopes = authorization['scopes_supported']
80
91
  end
81
92
 
82
- def header
83
- @header ||= {accept: 'application/vnd.deere.axiom.v3+json'}
93
+ def headers
94
+ @headers ||= {accept: 'application/vnd.deere.axiom.v3+json'}
84
95
  end
85
96
 
86
97
  def keyify key_name