my_john_deere_api 0.12.3 → 0.12.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +72 -0
- data/lib/my_john_deere_api/version.rb +1 -1
- 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: 272b78cd5d3c194ea5ca6362a9a8f64b1d5be22b4ec79968c4575d7be5497699
|
4
|
+
data.tar.gz: 7b77df8259ab5c41696339835f4c3cdcea26ebf6e0473936f18348a14ca675d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b4b8aef5761dff7936fe113a44af60b53182e28c907b07bd37444ede8461ea9439ccd53c39b7e9ad177ff2723069d475fc7964f6343f8004fd75ba3d159c7f8
|
7
|
+
data.tar.gz: 937e79548f856c03aac06bed21986590ff24cda529284d43763ae5b1784926b614476d53a10ebe85b0cdec8abce63bc1506f038017919144cce985a026001fb3
|
data/README.md
CHANGED
@@ -83,4 +83,76 @@ that contains the verification code so the user doesn't have to provide it.
|
|
83
83
|
authorize.verify(params[:oauth_verifier])
|
84
84
|
|
85
85
|
|
86
|
+
### Interacting with the user's John Deere account
|
87
|
+
|
88
|
+
After authorization is complete, the `Client` object will provide most of the interface for this library. A client can
|
89
|
+
be used with or without user credentials, because some API calls are specific to your application's relationship
|
90
|
+
with John Deere, not your user's. But most interactions will involve user data. Here's how to instantiate a client:
|
91
|
+
|
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
|
+
|
106
|
+
|
107
|
+
#### Arbitrary GET requests
|
108
|
+
|
109
|
+
While the goal of the client is to eliminate the need to make/interpret calls to the John Deere API, it's important
|
110
|
+
to be able to make calls that are not yet fully supported by the client. Or sometimes, you need to troubleshoot.
|
111
|
+
You can pass any path to the get method, and receive the JSON-parsed response.
|
112
|
+
|
113
|
+
client.get('/organizations')
|
114
|
+
|
115
|
+
# Abbreviated sample response:
|
116
|
+
{
|
117
|
+
"links": [...],
|
118
|
+
"total": 1,
|
119
|
+
"values": [
|
120
|
+
{
|
121
|
+
"@type": "Organization",
|
122
|
+
"name": "ABC Farms",
|
123
|
+
"type": "customer",
|
124
|
+
"member": true,
|
125
|
+
"id": "123123",
|
126
|
+
"links": [...]
|
127
|
+
},
|
128
|
+
]
|
129
|
+
}
|
130
|
+
|
131
|
+
This won't provide any client goodies like pagination, validation or weeding out the stuff you don't need (like the nifty client methods).
|
132
|
+
|
133
|
+
|
134
|
+
#### Arbitrary POST requests
|
135
|
+
|
136
|
+
You can also make arbitrary POST requests. This method takes a required resource path, and a hash for the request body that
|
137
|
+
the client will convert to JSON.
|
138
|
+
|
139
|
+
client.post(
|
140
|
+
'/organizations/123123/assets',
|
141
|
+
{
|
142
|
+
"title"=>"i like turtles",
|
143
|
+
"assetCategory"=>"DEVICE",
|
144
|
+
"assetType"=>"SENSOR",
|
145
|
+
"assetSubType"=>"ENVIRONMENTAL",
|
146
|
+
"links"=>[
|
147
|
+
{
|
148
|
+
"@type"=>"Link",
|
149
|
+
"rel"=>"contributionDefinition",
|
150
|
+
"uri"=>"https://sandboxapi.deere.com/platform/contributionDefinitions/CONTRIBUTION_DEFINITION_ID"
|
151
|
+
}
|
152
|
+
]
|
153
|
+
}
|
154
|
+
)
|
155
|
+
|
156
|
+
The response for most requests is just an HTTP status code, with no body. If a body is provided, it will be JSON-parsed and returned.
|
157
|
+
|
86
158
|
More details coming soon.
|