my_john_deere_api 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/my_john_deere_api/client.rb +2 -1
- data/lib/my_john_deere_api/version.rb +1 -1
- data/test/lib/my_john_deere_api/client_test.rb +12 -0
- data/test/support/vcr_setup.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73e95842d21ef2ed1ebf798feb07b69328e1554f42695b60c4caa755da34ee7f
|
4
|
+
data.tar.gz: 5c438391b2565e2c050abdbbd6b04610f7427141c3d1eb3115a616dfdf649784
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b09a10a8add71b254f67864f04e472cce3c6c72db7805e152f64967e14ae20f36327c686560ab5e7e7d8686860290b2b2b17cd350ce164c2008f47f669e38b97
|
7
|
+
data.tar.gz: 9e8fadcf86385d040574343441a724d21db5e408381b55045149b459a76e3d8da6c482c4850787564866200a17da63922169e01cb80392cc31c3b7ca750cbadb
|
data/README.md
CHANGED
@@ -127,6 +127,11 @@ This client is a work in progress. You can currently do the following things wit
|
|
127
127
|
|
128
128
|
```
|
129
129
|
client
|
130
|
+
├── contribution_products
|
131
|
+
├── count
|
132
|
+
├── all
|
133
|
+
├── first
|
134
|
+
└── find(contribution_product_id)
|
130
135
|
└── organizations
|
131
136
|
├── count
|
132
137
|
├── all
|
@@ -154,6 +159,7 @@ client
|
|
154
159
|
└── first
|
155
160
|
```
|
156
161
|
|
162
|
+
|
157
163
|
#### [Organizations](https://developer.deere.com/#!documentation&doc=myjohndeere%2Forganizations.htm)
|
158
164
|
|
159
165
|
Organization collections act like a list. In addition to all the methods included via Ruby's
|
@@ -228,7 +234,7 @@ This is much nicer than working with the raw API response:
|
|
228
234
|
But the real power comes from daisy-chaining associations together.
|
229
235
|
|
230
236
|
|
231
|
-
|
237
|
+
#### [Assets](https://developer.deere.com/#!documentation&doc=.%2Fmyjohndeere%2Fassets.htm)
|
232
238
|
|
233
239
|
Handles an organization's assets. Supported methods:
|
234
240
|
|
@@ -102,7 +102,8 @@ module MyJohnDeereApi
|
|
102
102
|
# contribution products associated with this app (not user-specific)
|
103
103
|
|
104
104
|
def contribution_products
|
105
|
-
|
105
|
+
return @contribution_products if defined?(@contribution_products)
|
106
|
+
@contribution_products = MyJohnDeereApi::Request::Collection::ContributionProducts.new(accessor)
|
106
107
|
end
|
107
108
|
|
108
109
|
private
|
@@ -140,6 +140,18 @@ describe 'MyJohnDeereApi::Client' do
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
+
describe '#contribution_products' do
|
144
|
+
it 'returns a collection of contribution products for this account' do
|
145
|
+
contribution_products = VCR.use_cassette('get_contribution_products') { client.contribution_products.all; client.contribution_products }
|
146
|
+
|
147
|
+
assert_kind_of JD::Request::Collection::ContributionProducts, contribution_products
|
148
|
+
|
149
|
+
contribution_products.each do |contribution_product|
|
150
|
+
assert_kind_of JD::Model::ContributionProduct, contribution_product
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
143
155
|
describe '#consumer' do
|
144
156
|
it 'receives the api key/secret and environment of the client' do
|
145
157
|
environment = :sandbox
|
data/test/support/vcr_setup.rb
CHANGED
@@ -194,6 +194,10 @@ class VcrSetup
|
|
194
194
|
new_client.get('/contributionProducts?clientControlled=true')
|
195
195
|
end
|
196
196
|
|
197
|
+
def get_contribution_product
|
198
|
+
new_client.get("/contributionProducts/#{ENV['CONTRIBUTION_PRODUCT_ID']}")
|
199
|
+
end
|
200
|
+
|
197
201
|
def get_organizations
|
198
202
|
new_client.organizations.all
|
199
203
|
end
|
@@ -214,10 +218,6 @@ class VcrSetup
|
|
214
218
|
@temporary_field.flags.all
|
215
219
|
end
|
216
220
|
|
217
|
-
def get_contribution_product
|
218
|
-
new_client.get("/contributionProducts/#{ENV['CONTRIBUTION_PRODUCT_ID']}")
|
219
|
-
end
|
220
|
-
|
221
221
|
def post_assets
|
222
222
|
@temporary_asset_id = find_organization(ENV['ORGANIZATION_ID']).assets.create(asset_attributes).id
|
223
223
|
placeholders[@temporary_asset_id] = asset_id
|