my_john_deere_api 0.15.4 → 0.15.5

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: fb000ae1403d9597e7880a972c46f5e2a9f9ca9326107d11e0ea1da2489a6ec6
4
- data.tar.gz: e0f861b52d8a82465fd12eafcf8071779d5a72c05fc29d33ae46e8a1599b22cb
3
+ metadata.gz: 50683e3b5739e473385b52c3ff9e7bcdabb74410c004fa13e9349de03c7eca43
4
+ data.tar.gz: f7b612049d14d825bbf78831e2a2f4b19370df18ddde3a114b277494d4ba45c6
5
5
  SHA512:
6
- metadata.gz: 199148536c1277155460eea6b33f197496a9d88be2413beeace1d4ae3eedc4c12d8a5bd7c837e50749a03ac0f0df0243d97641415fadf89c0d5acef63ce87698
7
- data.tar.gz: 0b3273dc344198c2e05ca41257b623a6e919c84e219e162a35c3a9a6368fc8ae61f1ecfa828708fad25ec96e7d8a8a95085221331d9169ea35e6eafac7f19379
6
+ metadata.gz: 506973aa4c9aaaf172e6767b4dfb6668002a65754ee798fa86039d65b45c90e52a93c41a392fa3dac6d0d782bf124bcfef38538ae43bc559349874b0c6105ac3
7
+ data.tar.gz: adff5451e37aeb001d4b2fd309ee9f8363944e96f887b884f9fcd44b2492136bed4e2148da8033b21a261e078a38ad7e8b62c041efb421082fecf26174fa3508
data/README.md CHANGED
@@ -13,75 +13,84 @@ This client allows you to connect the MyJohnDeere API without having to code you
13
13
  We provide RDoc documentation, but here is a helpful guide for getting started. Because the gem name is long, all examples are going
14
14
  to assume this shortcut:
15
15
 
16
- JD = MyJohnDeereApi
16
+ ```ruby
17
+ JD = MyJohnDeereApi
18
+ ```
17
19
 
18
20
  So that when you see:
19
21
 
20
- JD::Authorize
21
-
22
+ ```ruby
23
+ JD::Authorize
24
+ ```
22
25
  It really means:
23
26
 
24
- MyJohnDeereApi::Authorize
25
-
27
+ ```ruby
28
+ MyJohnDeereApi::Authorize
29
+ ```
26
30
 
27
31
  ### Authorizing with John Deere via Auth 1.0
28
32
 
29
33
  This is the simplest path to authorization, though your user has to jump through an extra hoop of giving you the verification code:
30
34
 
31
- # Create an authorize object, using your app's API key and secret. You can
32
- # pass an environment (`:live` or `:sandbox`), which default to `:live`.
33
- authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
34
-
35
- # Retrieve a valid authorization url from John Deere, where you can send
36
- # your user for authorizing your app to the JD platform.
37
- url = authorize.authorize_url
38
-
39
- # Verify the code given to the user during the authorization process, and
40
- # turn this into access credentials for your user.
41
- authorize.verify(code)
35
+ ```ruby
36
+ # Create an authorize object, using your app's API key and secret. You can
37
+ # pass an environment (`:live` or `:sandbox`), which default to `:live`.
38
+ authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
39
+
40
+ # Retrieve a valid authorization url from John Deere, where you can send
41
+ # your user for authorizing your app to the JD platform.
42
+ url = authorize.authorize_url
43
+
44
+ # Verify the code given to the user during the authorization process, and
45
+ # turn this into access credentials for your user.
46
+ authorize.verify(code)
47
+ ```
42
48
 
43
49
  In reality, you will likely need to re-instantiate the authorize object when the user returns, and that works without issue:
44
50
 
45
- # Create an authorize object, using your app's API key and secret.
46
- authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
47
-
48
- # Retrieve a valid authorization url from John Deere.
49
- url = authorize.authorize_url
50
-
51
- # Queue elevator music while your app serves other users...
52
-
53
- # Re-create the authorize instance in a different process
54
- authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
55
-
56
- # Proceed as normal
57
- authorize.verify(code)
51
+ ```ruby
52
+ # Create an authorize object, using your app's API key and secret.
53
+ authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
54
+
55
+ # Retrieve a valid authorization url from John Deere.
56
+ url = authorize.authorize_url
57
+
58
+ # Queue elevator music while your app serves other users...
59
+
60
+ # Re-create the authorize instance in a different process
61
+ authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
62
+
63
+ # Proceed as normal
64
+ authorize.verify(code)
65
+ ```
58
66
 
59
67
  In a web app, you're prefer that your user doesn't have to copy/paste verification codes. So you can pass in an :oauth_callback url.
60
68
  When the user authorizes your app with John Deere, they are redirected to the url you provide, with the paraameter 'oauth_verifier'
61
69
  that contains the verification code so the user doesn't have to provide it.
62
70
 
63
- # Create an authorize object, using your app's API key and secret.
64
- authorize = JD::Authorize.new(
65
- API_KEY,
66
- API_SECRET,
67
- environment: :sandbox,
68
- oauth_callback: 'https://example.com'
69
- )
70
-
71
- # Retrieve a valid authorization url from John Deere.
72
- # This will contain the callback url encoded into the
73
- # query string for you.
74
- url = authorize.authorize_url
75
-
76
- # Queue elevator music while your app serves other users...
77
-
78
- # Re-create the authorize instance in a different process.
79
- # It's not necessary to re-initialize with the callback url.
80
- authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
81
-
82
- # Inside a Rails controller, you might do this:
83
- authorize.verify(params[:oauth_verifier])
71
+ ```ruby
72
+ # Create an authorize object, using your app's API key and secret.
73
+ authorize = JD::Authorize.new(
74
+ API_KEY,
75
+ API_SECRET,
76
+ environment: :sandbox,
77
+ oauth_callback: 'https://example.com'
78
+ )
84
79
 
80
+ # Retrieve a valid authorization url from John Deere.
81
+ # This will contain the callback url encoded into the
82
+ # query string for you.
83
+ url = authorize.authorize_url
84
+
85
+ # Queue elevator music while your app serves other users...
86
+
87
+ # Re-create the authorize instance in a different process.
88
+ # It's not necessary to re-initialize with the callback url.
89
+ authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
90
+
91
+ # Inside a Rails controller, you might do this:
92
+ authorize.verify(params[:oauth_verifier])
93
+ ```
85
94
 
86
95
  ### Interacting with the user's John Deere account
87
96
 
@@ -89,20 +98,21 @@ After authorization is complete, the `Client` object will provide most of the in
89
98
  be used with or without user credentials, because some API calls are specific to your application's relationship
90
99
  with John Deere, not your user's. But most interactions will involve user data. Here's how to instantiate a client:
91
100
 
92
- client = JD::Client.new(
93
- # the application's API key
94
- API_KEY,
95
-
96
- # the application's API secret
97
- API_SECRET,
98
-
99
- # the chosen environment (:sandbox or :live)
100
- environment: :sandbox,
101
-
102
- # the user's access credentials
103
- access: [ACCESS_TOKEN, ACCESS_SECRET]
104
- )
105
-
101
+ ```ruby
102
+ client = JD::Client.new(
103
+ # the application's API key
104
+ API_KEY,
105
+
106
+ # the application's API secret
107
+ API_SECRET,
108
+
109
+ # the chosen environment (:sandbox or :live)
110
+ environment: :sandbox,
111
+
112
+ # the user's access credentials
113
+ access: [ACCESS_TOKEN, ACCESS_SECRET]
114
+ )
115
+ ```
106
116
 
107
117
  ### Direct API Requests
108
118
 
@@ -115,23 +125,25 @@ to be able to make calls that are not yet fully supported by the client. Or some
115
125
 
116
126
  GET requests require only a resource path.
117
127
 
118
- client.get('/organizations')
119
-
120
- # Abbreviated sample response:
128
+ ```ruby
129
+ client.get('/organizations')
130
+
131
+ # Abbreviated sample response:
132
+ {
133
+ "links": [...],
134
+ "total": 1,
135
+ "values": [
121
136
  {
122
- "links": [...],
123
- "total": 1,
124
- "values": [
125
- {
126
- "@type": "Organization",
127
- "name": "ABC Farms",
128
- "type": "customer",
129
- "member": true,
130
- "id": "123123",
131
- "links": [...]
132
- },
133
- ]
134
- }
137
+ "@type": "Organization",
138
+ "name": "ABC Farms",
139
+ "type": "customer",
140
+ "member": true,
141
+ "id": "123123",
142
+ "links": [...]
143
+ },
144
+ ]
145
+ }
146
+ ```
135
147
 
136
148
  This won't provide any client goodies like pagination or validation, but it does parse the returned JSON.
137
149
 
@@ -140,22 +152,24 @@ This won't provide any client goodies like pagination or validation, but it does
140
152
 
141
153
  POST requests require a resource path, and a hash for the request body. The client will camelize the keys, and convert to JSON.
142
154
 
143
- client.post(
144
- '/organizations/123123/assets',
155
+ ```ruby
156
+ client.post(
157
+ '/organizations/123123/assets',
158
+ {
159
+ "title"=>"i like turtles",
160
+ "assetCategory"=>"DEVICE",
161
+ "assetType"=>"SENSOR",
162
+ "assetSubType"=>"ENVIRONMENTAL",
163
+ "links"=>[
145
164
  {
146
- "title"=>"i like turtles",
147
- "assetCategory"=>"DEVICE",
148
- "assetType"=>"SENSOR",
149
- "assetSubType"=>"ENVIRONMENTAL",
150
- "links"=>[
151
- {
152
- "@type"=>"Link",
153
- "rel"=>"contributionDefinition",
154
- "uri"=>"https://sandboxapi.deere.com/platform/contributionDefinitions/CONTRIBUTION_DEFINITION_ID"
155
- }
156
- ]
157
- }
158
- )
165
+ "@type"=>"Link",
166
+ "rel"=>"contributionDefinition",
167
+ "uri"=>"https://sandboxapi.deere.com/platform/contributionDefinitions/CONTRIBUTION_DEFINITION_ID"
168
+ }
169
+ ]
170
+ }
171
+ )
172
+ ```
159
173
 
160
174
  John Deere's standard response is a 201 HTTP status code, with the message "Created". This method returns the full Net::HTTP response.
161
175
 
@@ -164,22 +178,24 @@ John Deere's standard response is a 201 HTTP status code, with the message "Crea
164
178
 
165
179
  PUT requests require a resource path, and a hash for the request body. The client will camelize the keys, and convert to JSON.
166
180
 
167
- client.put(
168
- '/assets/123123',
181
+ ```ruby
182
+ client.put(
183
+ '/assets/123123',
184
+ {
185
+ "title"=>"i REALLY like turtles",
186
+ "assetCategory"=>"DEVICE",
187
+ "assetType"=>"SENSOR",
188
+ "assetSubType"=>"ENVIRONMENTAL",
189
+ "links"=>[
169
190
  {
170
- "title"=>"i REALLY like turtles",
171
- "assetCategory"=>"DEVICE",
172
- "assetType"=>"SENSOR",
173
- "assetSubType"=>"ENVIRONMENTAL",
174
- "links"=>[
175
- {
176
- "@type"=>"Link",
177
- "rel"=>"contributionDefinition",
178
- "uri"=>"https://sandboxapi.deere.com/platform/contributionDefinitions/CONTRIBUTION_DEFINITION_ID"
179
- }
180
- ]
181
- }
182
- )
191
+ "@type"=>"Link",
192
+ "rel"=>"contributionDefinition",
193
+ "uri"=>"https://sandboxapi.deere.com/platform/contributionDefinitions/CONTRIBUTION_DEFINITION_ID"
194
+ }
195
+ ]
196
+ }
197
+ )
198
+ ```
183
199
 
184
200
  John Deere's standard response is a 204 HTTP status code, with the message "No Content". This method returns the full Net::HTTP response.
185
201
 
@@ -188,7 +204,9 @@ John Deere's standard response is a 204 HTTP status code, with the message "No C
188
204
 
189
205
  DELETE requests require only a resource path.
190
206
 
191
- client.delete('/assets/123123')
207
+ ```ruby
208
+ client.delete('/assets/123123')
209
+ ```
192
210
 
193
211
  John Deere's standard response is a 204 HTTP status code, with the message "No Content". This method returns the full Net::HTTP response.
194
212
 
@@ -1,3 +1,3 @@
1
1
  module MyJohnDeereApi
2
- VERSION='0.15.4'
2
+ VERSION='0.15.5'
3
3
  end
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.15.4
4
+ version: 0.15.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Bellmyer