my_john_deere_api 0.9.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc1baa5d7a1e28baac2acf6ac893aafe0ca957a8bfd29fa8b3d4594d146915f1
4
- data.tar.gz: 180f63116e4e92c4bc84f4d08f63c10e37c12ff246f4fccada85a72f3fb277b6
3
+ metadata.gz: dbc5856a79f226a02482fdc6356930e675c68b3246395866eee31d848fcc3ae1
4
+ data.tar.gz: b092e23aeea5a8d311e5c05cfa95b091935a3e3bfc16491355408a71e4843d9c
5
5
  SHA512:
6
- metadata.gz: f6357b1fade7debbc4a2f9c5b5f0233c778e655590209d65b170760aa363e9d693bf2677efdde724edad5f7878d4cc4dafb6b0df5df5eb3da46ddf1ee5552255
7
- data.tar.gz: 94402849119f06025969c426d8f528246ed5bf5b26980070f67840f5b5706e660ad3a734be7874c23b097d9e52cf13cc63636c9a8615ed2b775a8b5e7c67f0d4
6
+ metadata.gz: 0503e0df2282864ad2831518bd8ad084b85aab79455f8aff396dc25abf43f798d775394d9633a149f1e4af8cfe64c888e55568258a42f4768671bf23d1e0439c
7
+ data.tar.gz: 0b06fa4efec9e6131ecba5aecee865d01a4d07addc7d8a4df35fd76f81c1088e865f39735b139e6d58eaa3d2d4a799f8de6a54c81e5f7b50b35bacd0621e57d2
@@ -56,6 +56,21 @@ class MyJohnDeereApi::Client
56
56
  end
57
57
  end
58
58
 
59
+ ##
60
+ # generic user-specific DELETE request method
61
+
62
+ def delete resource
63
+ resource = resource.to_s
64
+ resource = "/#{resource}" unless resource =~ /^\//
65
+ response = accessor.delete(resource, post_headers)
66
+
67
+ if response.body && response.body.size > 0
68
+ JSON.parse(response.body)
69
+ else
70
+ {}
71
+ end
72
+ end
73
+
59
74
  ##
60
75
  # organizations associated with this access
61
76
 
@@ -1,3 +1,3 @@
1
1
  module MyJohnDeereApi
2
- VERSION='0.9.4'
2
+ VERSION='0.10.0'
3
3
  end
@@ -95,27 +95,45 @@ describe 'MyJohnDeereApi::Client' do
95
95
  assert_equal Hash.new, response
96
96
  end
97
97
 
98
- # it 'prepends the leading slash if needed' do
99
- # client = JD::Client.new(API_KEY, API_SECRET, environment: :sandbox, access: [ACCESS_TOKEN, ACCESS_SECRET])
100
- # VCR.use_cassette('catalog') { client.send(:accessor) }
101
- # response = VCR.use_cassette('get_organizations') { client.get('organizations') }
102
- #
103
- # assert_kind_of Hash, response
104
- # assert_kind_of Integer, response['total']
105
- # assert response['values'].all?{|value| value['@type'] == 'Organization'}
106
- # assert response['values'].all?{|value| value.has_key?('links')}
107
- # end
108
- #
109
- # it 'allows symbols for simple resources' do
110
- # client = JD::Client.new(API_KEY, API_SECRET, environment: :sandbox, access: [ACCESS_TOKEN, ACCESS_SECRET])
111
- # VCR.use_cassette('catalog') { client.send(:accessor) }
112
- # response = VCR.use_cassette('get_organizations') { client.get(:organizations) }
113
- #
114
- # assert_kind_of Hash, response
115
- # assert_kind_of Integer, response['total']
116
- # assert response['values'].all?{|value| value['@type'] == 'Organization'}
117
- # assert response['values'].all?{|value| value.has_key?('links')}
118
- # end
98
+ it 'prepends the leading slash if needed' do
99
+ client = JD::Client.new(API_KEY, API_SECRET, environment: :sandbox, access: [ACCESS_TOKEN, ACCESS_SECRET])
100
+ VCR.use_cassette('catalog') { client.send(:accessor) }
101
+ response = VCR.use_cassette('get_organizations') { client.get('organizations') }
102
+
103
+ assert_kind_of Hash, response
104
+ assert_kind_of Integer, response['total']
105
+ assert response['values'].all?{|value| value['@type'] == 'Organization'}
106
+ assert response['values'].all?{|value| value.has_key?('links')}
107
+ end
108
+
109
+ it 'allows symbols for simple resources' do
110
+ client = JD::Client.new(API_KEY, API_SECRET, environment: :sandbox, access: [ACCESS_TOKEN, ACCESS_SECRET])
111
+ VCR.use_cassette('catalog') { client.send(:accessor) }
112
+ response = VCR.use_cassette('get_organizations') { client.get(:organizations) }
113
+
114
+ assert_kind_of Hash, response
115
+ assert_kind_of Integer, response['total']
116
+ assert response['values'].all?{|value| value['@type'] == 'Organization'}
117
+ assert response['values'].all?{|value| value.has_key?('links')}
118
+ end
119
+ end
120
+
121
+ describe '#delete' do
122
+ it 'sends the request' do
123
+ client = JD::Client.new(API_KEY, API_SECRET, environment: :sandbox, access: [ACCESS_TOKEN, ACCESS_SECRET])
124
+ VCR.use_cassette('catalog') { client.send(:accessor) }
125
+ response = VCR.use_cassette('delete_asset') { client.delete("/assets/123") }
126
+
127
+ assert_kind_of Hash, response
128
+ end
129
+
130
+ it 'prepends the leading slash if needed' do
131
+ client = JD::Client.new(API_KEY, API_SECRET, environment: :sandbox, access: [ACCESS_TOKEN, ACCESS_SECRET])
132
+ VCR.use_cassette('catalog') { client.send(:accessor) }
133
+ response = VCR.use_cassette('get_organizations') { client.get('organizations') }
134
+
135
+ assert_kind_of Hash, response
136
+ end
119
137
  end
120
138
 
121
139
  describe '#organizations' do
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://sandboxapi.deere.com/platform/assets/123
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/vnd.deere.axiom.v3+json
12
+ Content-Type:
13
+ - application/vnd.deere.axiom.v3+json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ User-Agent:
17
+ - OAuth gem v0.5.4
18
+ Authorization:
19
+ - OAuth oauth_consumer_key="johndeere-wgmADngYCRmfpEbVgSyc709wnyRux5J7PAv8SE7B",
20
+ oauth_nonce="AqcnS0Io0fZd7gvtQWVTN0iXcS3htLzQwz6eYcv4g", oauth_signature="wQO6f89KmUaWXpdqqokQ6K%2BsrNM%3D",
21
+ oauth_signature_method="HMAC-SHA1", oauth_timestamp="1579742355", oauth_token="47bbb9c9-41a8-4bec-8127-e3c5760af2f6",
22
+ oauth_version="1.0"
23
+ response:
24
+ status:
25
+ code: 204
26
+ message: No Content
27
+ headers:
28
+ Date:
29
+ - Thu, 23 Jan 2020 01:19:16 GMT
30
+ X-Deere-Handling-Server:
31
+ - ip-10-214-45-242
32
+ X-Frame-Options:
33
+ - SAMEORIGIN
34
+ X-Deere-Elapsed-Ms:
35
+ - '81'
36
+ body:
37
+ encoding: UTF-8
38
+ string: ''
39
+ http_version:
40
+ recorded_at: Thu, 23 Jan 2020 01:19:16 GMT
41
+ recorded_with: VCR 5.0.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_john_deere_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime. Bellmyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-22 00:00:00.000000000 Z
11
+ date: 2020-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vcr
@@ -166,6 +166,7 @@ files:
166
166
  - test/support/helper.rb
167
167
  - test/support/vcr/app_consumer.yml
168
168
  - test/support/vcr/catalog.yml
169
+ - test/support/vcr/delete_asset.yml
169
170
  - test/support/vcr/get_access_token.yml
170
171
  - test/support/vcr/get_asset_locations.yml
171
172
  - test/support/vcr/get_assets.yml
@@ -173,7 +174,6 @@ files:
173
174
  - test/support/vcr/get_flags.yml
174
175
  - test/support/vcr/get_organizations.yml
175
176
  - test/support/vcr/get_request_token.yml
176
- - test/support/vcr/post_asset_locations-bak.yml
177
177
  - test/support/vcr/post_asset_locations.yml
178
178
  - test/support/vcr/post_assets.yml
179
179
  - test/support/vcr/post_flag_categories.yml
@@ -1,95 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://sandboxapi.deere.com/platform/assets/029c288a-14d9-459f-8ee6-b4e840e672a1/locations
6
- body:
7
- encoding: UTF-8
8
- string: '[{"timestamp":"2020-01-18T00:31:00Z","geometry":"{\"type\":\"Feature\",\"geometry\":{\"geometries\":[{\"coordinates\":[-103.115633,41.670166],\"type\":\"Point\"}],\"type\":\"GeometryCollection\"}}","measurementData":[{"name":"Temperature","value":"68.0","unit":"F"}]}]'
9
- headers:
10
- Accept:
11
- - application/vnd.deere.axiom.v3+json
12
- Content-Type:
13
- - application/vnd.deere.axiom.v3+json
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- User-Agent:
17
- - OAuth gem v0.5.4
18
- Content-Length:
19
- - '181'
20
- Authorization:
21
- - OAuth oauth_body_hash="iiLtEEcE%2B8AM8XC5NLttAeL92i4%3D", oauth_consumer_key="johndeere-wgmADngYCRmfpEbVgSyc709wnyRux5J7PAv8SE7B",
22
- oauth_nonce="hMwIfcVWHIyjE51AQcMztDSCm0AWilBe4LTFZvuI", oauth_signature="ibSHPRsXfeazw1%2F5I%2BZlcipIZRk%3D",
23
- oauth_signature_method="HMAC-SHA1", oauth_timestamp="1579308624", oauth_token="47bbb9c9-41a8-4bec-8127-e3c5760af2f6",
24
- oauth_version="1.0"
25
- response:
26
- status:
27
- code: 201
28
- message: Created
29
- headers:
30
- Date:
31
- - Sat, 18 Jan 2020 00:50:24 GMT
32
- Content-Type:
33
- - application/vnd.deere.axiom.v3+json
34
- X-Deere-Handling-Server:
35
- - ip-10-214-45-182
36
- X-Frame-Options:
37
- - SAMEORIGIN
38
- Location:
39
- - https://sandboxapi.deere.com/platform/assets/029c288a-14d9-459f-8ee6-b4e840e672a1/locations
40
- X-Deere-Elapsed-Ms:
41
- - '59'
42
- Transfer-Encoding:
43
- - chunked
44
- body:
45
- encoding: ASCII-8BIT
46
- string: ''
47
- http_version:
48
- recorded_at: Sat, 18 Jan 2020 00:50:24 GMT
49
- - request:
50
- method: get
51
- uri: https://sandboxapi.deere.com/platform/assets/029c288a-14d9-459f-8ee6-b4e840e672a1/locations?endDate=2020-01-18T00:31:01Z&startDate=2020-01-18T00:30:59Z
52
- body:
53
- encoding: US-ASCII
54
- string: ''
55
- headers:
56
- Accept:
57
- - application/vnd.deere.axiom.v3+json
58
- Content-Type:
59
- - application/vnd.deere.axiom.v3+json
60
- Accept-Encoding:
61
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
62
- User-Agent:
63
- - OAuth gem v0.5.4
64
- Authorization:
65
- - OAuth oauth_consumer_key="johndeere-wgmADngYCRmfpEbVgSyc709wnyRux5J7PAv8SE7B",
66
- oauth_nonce="hStGJCzcb5OY7HwmEsQwNX253TTZ85FurItAwDuxvdQ", oauth_signature="LEKTEGOy%2FmqrsGuEqvASGBYk7gY%3D",
67
- oauth_signature_method="HMAC-SHA1", oauth_timestamp="1579308624", oauth_token="47bbb9c9-41a8-4bec-8127-e3c5760af2f6",
68
- oauth_version="1.0"
69
- response:
70
- status:
71
- code: 200
72
- message: OK
73
- headers:
74
- Date:
75
- - Sat, 18 Jan 2020 00:50:25 GMT
76
- Content-Type:
77
- - application/vnd.deere.axiom.v3+json;charset=UTF-8
78
- X-Deere-Handling-Server:
79
- - ip-10-214-45-182
80
- X-Frame-Options:
81
- - SAMEORIGIN
82
- X-Deere-Elapsed-Ms:
83
- - '44'
84
- Cache-Control:
85
- - no-store
86
- Content-Language:
87
- - en-US
88
- Transfer-Encoding:
89
- - chunked
90
- body:
91
- encoding: ASCII-8BIT
92
- string: '{"links":[{"rel":"self","uri":"https://sandboxapi.deere.com/platform/assets/029c288a-14d9-459f-8ee6-b4e840e672a1/locations?startDate=2020-01-18T00:30:59Z&endDate=2020-01-18T00:31:01Z"}],"total":1,"values":[{"@type":"ContributedAssetLocation","timestamp":"2020-01-18T00:31:00.000Z","geometry":"{\"type\":\"Feature\",\"geometry\":{\"geometries\":[{\"coordinates\":[-103.115633,41.670166],\"type\":\"Point\"}],\"type\":\"GeometryCollection\"}}","measurementData":[{"@type":"BasicMeasurement","name":"Temperature","value":"68.0","unit":"F"}],"links":[]}]}'
93
- http_version:
94
- recorded_at: Sat, 18 Jan 2020 00:50:25 GMT
95
- recorded_with: VCR 5.0.0