my_john_deere_api 0.12.6 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d79f9ae5d1b5b960422791626144c4ef7f5d812668c6b55ac0c08ee75c06ddc3
4
- data.tar.gz: ac5d0b960dfd945dcf4c6a7f70824db56f6592acdf760fd43663b7b9d6506a1a
3
+ metadata.gz: 787e0d84f99384bef23e696a83b3b48e8ac38bc94762082233d109d2ac4dba54
4
+ data.tar.gz: 045ee1bdbd6b5d5e6dc9854610ef6e1fe3fa672a66a15322ea3db418f8646f3c
5
5
  SHA512:
6
- metadata.gz: 758d942d65896071bc7ac6340f83731faa02b53d9d96d56881d1adb0c3b5bc24dd1a613dd1d162a4be07bfcde8b99be3ec2375b476b958472e674bdaed4e6711
7
- data.tar.gz: a21fa3beac2fe3cce6bbb7e33f7eda267fe6bd6f89a4a9e4f235b4106724d2efe73fddb46b9b6b9c1d84983db054bedc19a26b62ca8ec0a69be0abdf43fd71d2
6
+ metadata.gz: ba6bf01d32af62276f36ee5237fd6338eab9eff1aa9f2ae1d44ec0eb207b919df2b2de34067c1afcdd038d4eac64d9bca19758f6cdfa1ad87c3e2f296f54b7db
7
+ data.tar.gz: df6e4e884de36d54d08a6ca5bbcce433522d6436270b5af8f13e2382a2122fd2d6537a0c35f57327692ed74ba40639cf5b6fa6ef432424e55d0ed13294392e95
@@ -15,5 +15,12 @@ module MyJohnDeereApi::Request
15
15
  def model
16
16
  MyJohnDeereApi::Model::Organization
17
17
  end
18
+
19
+ ##
20
+ # Retrieve an organization from JD
21
+
22
+ def find(organization_id)
23
+ Individual::Organization.new(accessor, organization_id).object
24
+ end
18
25
  end
19
26
  end
@@ -0,0 +1,19 @@
1
+ require 'json'
2
+
3
+ module MyJohnDeereApi::Request
4
+ class Individual::Organization < Individual::Base
5
+ ##
6
+ # The resource path for the first page in the collection
7
+
8
+ def resource
9
+ "/organizations/#{id}"
10
+ end
11
+
12
+ ##
13
+ # This is the class used to model the data
14
+
15
+ def model
16
+ MyJohnDeereApi::Model::Organization
17
+ end
18
+ end
19
+ end
@@ -2,4 +2,5 @@ module MyJohnDeereApi::Request::Individual
2
2
  autoload :Base, 'my_john_deere_api/request/individual/base'
3
3
  autoload :Asset, 'my_john_deere_api/request/individual/asset'
4
4
  autoload :ContributionProduct, 'my_john_deere_api/request/individual/contribution_product'
5
+ autoload :Organization, 'my_john_deere_api/request/individual/organization'
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module MyJohnDeereApi
2
- VERSION='0.12.6'
2
+ VERSION='0.13.0'
3
3
  end
@@ -33,6 +33,13 @@ describe 'MyJohnDeereApi::Request::Collection::Organizations' do
33
33
  end
34
34
  end
35
35
 
36
+ describe '#find(organization_id)' do
37
+ it 'retrieves the asset' do
38
+ organization = VCR.use_cassette('get_organization') { collection.find(organization_id) }
39
+ assert_kind_of JD::Model::Organization, organization
40
+ end
41
+ end
42
+
36
43
  describe '#count' do
37
44
  let(:server_response) do
38
45
  contents = File.read('test/support/vcr/get_organizations.yml')
@@ -0,0 +1,32 @@
1
+ require 'support/helper'
2
+ require 'yaml'
3
+ require 'json'
4
+
5
+ describe 'MyJohnDeereApi::Request::Individual::Organization' do
6
+ let(:object) { JD::Request::Individual::Organization.new(accessor, organization_id) }
7
+
8
+ inherits_from JD::Request::Individual::Base
9
+
10
+ describe '#initialize(access_token, asset_id)' do
11
+ it 'accepts an access token' do
12
+ assert_equal accessor, object.accessor
13
+ end
14
+
15
+ it 'accepts organization_id as id' do
16
+ assert_equal organization_id, object.id
17
+ end
18
+ end
19
+
20
+ describe '#resource' do
21
+ it 'returns /organizations/<organization_id>' do
22
+ assert_equal "/organizations/#{organization_id}", object.resource
23
+ end
24
+ end
25
+
26
+ describe '#object' do
27
+ it 'returns all records' do
28
+ organization = VCR.use_cassette('get_organization') { object.object }
29
+ assert_kind_of JD::Model::Organization, organization
30
+ end
31
+ end
32
+ end
@@ -13,5 +13,9 @@ describe 'MyJohnDeereApi::Request::Individual' do
13
13
  it 'loads Request::Individual::ContributionProduct' do
14
14
  assert JD::Request::Individual::ContributionProduct
15
15
  end
16
+
17
+ it 'loads Request::Individual::Organization' do
18
+ assert JD::Request::Individual::Organization
19
+ end
16
20
  end
17
21
  end
@@ -23,15 +23,15 @@ http_interactions:
23
23
  message: OK
24
24
  headers:
25
25
  Date:
26
- - Fri, 07 Feb 2020 04:29:40 GMT
26
+ - Fri, 07 Feb 2020 05:18:35 GMT
27
27
  Content-Type:
28
28
  - application/vnd.deere.axiom.v3+json;charset=UTF-8
29
29
  X-Deere-Handling-Server:
30
- - ip-10-214-44-252
30
+ - ip-10-214-45-143
31
31
  X-Frame-Options:
32
32
  - SAMEORIGIN
33
33
  X-Deere-Elapsed-Ms:
34
- - '9'
34
+ - '16'
35
35
  Cache-Control:
36
36
  - no-store
37
37
  Content-Language:
@@ -42,7 +42,7 @@ http_interactions:
42
42
  encoding: ASCII-8BIT
43
43
  string: '{"@type":"ApiCatalog","links":[{"@type":"Link","rel":"oauthRequestToken","uri":"https://sandboxapi.deere.com/platform/oauth/request_token"},{"@type":"Link","rel":"oauthAuthorizeRequestToken","uri":"https://my.deere.com/consentToUseOfData?oauth_token={token}"},{"@type":"Link","rel":"oauthAccessToken","uri":"https://sandboxapi.deere.com/platform/oauth/access_token"},{"@type":"Link","rel":"agencies","uri":"https://sandboxapi.deere.com/platform/agencies"}]}'
44
44
  http_version:
45
- recorded_at: Fri, 07 Feb 2020 04:29:40 GMT
45
+ recorded_at: Fri, 07 Feb 2020 05:18:41 GMT
46
46
  - request:
47
47
  method: get
48
48
  uri: https://sandboxapi.deere.com/platform/organizations/000000
@@ -67,15 +67,15 @@ http_interactions:
67
67
  message: OK
68
68
  headers:
69
69
  Date:
70
- - Fri, 07 Feb 2020 04:29:44 GMT
70
+ - Fri, 07 Feb 2020 05:18:36 GMT
71
71
  Content-Type:
72
72
  - application/vnd.deere.axiom.v3+json;charset=UTF-8
73
73
  X-Deere-Handling-Server:
74
- - ip-10-214-45-137
74
+ - ip-10-214-45-50
75
75
  X-Frame-Options:
76
76
  - SAMEORIGIN
77
77
  X-Deere-Elapsed-Ms:
78
- - '30'
78
+ - '35'
79
79
  Cache-Control:
80
80
  - no-store
81
81
  Content-Language:
@@ -86,5 +86,5 @@ http_interactions:
86
86
  encoding: ASCII-8BIT
87
87
  string: '{"@type":"Organization","name":"Organization Name","type":"customer","member":true,"id":"000000","links":[{"@type":"Link","rel":"self","uri":"https://sandboxapi.deere.com/platform/organizations/000000"},{"@type":"Link","rel":"machines","uri":"https://sandboxapi.deere.com/platform/organizations/000000/machines"},{"@type":"Link","rel":"wdtCapableMachines","uri":"https://sandboxapi.deere.com/platform/organizations/000000/machines?capability=wdt"},{"@type":"Link","rel":"files","uri":"https://sandboxapi.deere.com/platform/organizations/000000/files"},{"@type":"Link","rel":"transferableFiles","uri":"https://sandboxapi.deere.com/platform/organizations/000000/files?transferable=true"},{"@type":"Link","rel":"uploadFile","uri":"https://sandboxapi.deere.com/platform/organizations/000000/files"},{"@type":"Link","rel":"sendFileToMachine","uri":"https://sandboxapi.deere.com/platform/organizations/000000/fileTransfers"},{"@type":"Link","rel":"addMachine","uri":"https://sandboxapi.deere.com/platform/organizations/000000/machines"},{"@type":"Link","rel":"addField","uri":"https://sandboxapi.deere.com/platform/organizations/000000/fields"},{"@type":"Link","rel":"assets","uri":"https://sandboxapi.deere.com/platform/organizations/000000/assets"},{"@type":"Link","rel":"fields","uri":"https://sandboxapi.deere.com/platform/organizations/000000/fields"},{"@type":"Link","rel":"farms","uri":"https://sandboxapi.deere.com/platform/organizations/000000/farms"},{"@type":"Link","rel":"boundaries","uri":"https://sandboxapi.deere.com/platform/organizations/000000/boundaries"},{"@type":"Link","rel":"clients","uri":"https://sandboxapi.deere.com/platform/organizations/000000/clients"},{"@type":"Link","rel":"flags","uri":"https://sandboxapi.deere.com/platform/organizations/000000/flags"},{"@type":"Link","rel":"flagCategory","uri":"https://sandboxapi.deere.com/platform/organizations/000000/flagCategories"},{"@type":"Link","rel":"controllers","uri":"https://sandboxapi.deere.com/platform/organizations/000000/orgController"}]}'
88
88
  http_version:
89
- recorded_at: Fri, 07 Feb 2020 04:29:44 GMT
89
+ recorded_at: Fri, 07 Feb 2020 05:18:41 GMT
90
90
  recorded_with: VCR 5.0.0
@@ -206,7 +206,7 @@ class VcrSetup
206
206
  end
207
207
 
208
208
  def get_organization
209
- new_client.get("/organizations/#{ENV['ORGANIZATION_ID']}")
209
+ new_client.organizations.find(ENV['ORGANIZATION_ID'])
210
210
  end
211
211
 
212
212
  def get_fields
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_john_deere_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.6
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Bellmyer
@@ -140,6 +140,7 @@ files:
140
140
  - lib/my_john_deere_api/request/individual/asset.rb
141
141
  - lib/my_john_deere_api/request/individual/base.rb
142
142
  - lib/my_john_deere_api/request/individual/contribution_product.rb
143
+ - lib/my_john_deere_api/request/individual/organization.rb
143
144
  - lib/my_john_deere_api/version.rb
144
145
  - test/lib/my_john_deere_api/authorize_test.rb
145
146
  - test/lib/my_john_deere_api/client_test.rb
@@ -176,6 +177,7 @@ files:
176
177
  - test/lib/my_john_deere_api/request/individual/asset_test.rb
177
178
  - test/lib/my_john_deere_api/request/individual/base_test.rb
178
179
  - test/lib/my_john_deere_api/request/individual/contribution_product_test.rb
180
+ - test/lib/my_john_deere_api/request/individual/organization_test.rb
179
181
  - test/lib/my_john_deere_api/request/individual_test.rb
180
182
  - test/lib/my_john_deere_api/request_test.rb
181
183
  - test/lib/my_john_deere_api/version_test.rb