my_john_deere_api 2.3.3 → 2.3.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 +125 -2
- data/lib/my_john_deere_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b6ea750328ecdcb653d61bbadf19ab4ab23ef2fb712963bda1351736ffedb37
|
4
|
+
data.tar.gz: '059eab2d2bbb7d8d716bde8f61f5ce935c46039dfbe6c82b933041e4f90fd072'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9e2285aa182a610b45b757707a26edad1e2ae342ce7ba62609c6a486f247fe3beaaad9e7df39a2ce2077b099b1a31edd53b1732fcdcde1d5b7253da648a7bdb
|
7
|
+
data.tar.gz: a9fad3831aa447433ee0969eb839d8e21245a29e955b1602ba560b75a989c8737c10c1489474d3982a7f71398407adfb9900968a240fd3cd677b05990e9dc3de
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![CircleCI](https://circleci.com/gh/Intellifarm/my_john_deere_api.svg?style=svg)](https://circleci.com/gh/Intellifarm/my_john_deere_api)
|
4
4
|
|
5
5
|
This client allows you to connect the [MyJohnDeere API](https://developer.deere.com/#!documentation)
|
6
|
-
without having to code your own
|
6
|
+
without having to code your own oAuth process, API requests, and pagination.
|
7
7
|
|
8
8
|
* Works with Rails, but does not require it
|
9
9
|
* Supports both sandbox and live mode
|
@@ -23,6 +23,7 @@ without having to code your own oauth process, API requests, and pagination.
|
|
23
23
|
* [Contribution Definitions](#contribution-definitions)
|
24
24
|
* [Organizations](#organizations)
|
25
25
|
* [Assets](#assets)
|
26
|
+
* [Asset Locations](#asset-locations)
|
26
27
|
* [Direct API Requests](#direct-api-requests)
|
27
28
|
* [GET](#get)
|
28
29
|
* [POST](#post)
|
@@ -435,6 +436,128 @@ asset.save
|
|
435
436
|
```
|
436
437
|
|
437
438
|
|
439
|
+
### [Asset Locations](https://developer.deere.com/#!documentation&doc=.%2Fmyjohndeere%2Fassets.htm)
|
440
|
+
|
441
|
+
Handles an asset's locations. Asset Location collections support the following methods:
|
442
|
+
|
443
|
+
* create(attributes)
|
444
|
+
* all
|
445
|
+
* count
|
446
|
+
* first
|
447
|
+
|
448
|
+
An individual location supports the following methods:
|
449
|
+
|
450
|
+
* timestamp
|
451
|
+
* geometry
|
452
|
+
* measurement\_data
|
453
|
+
|
454
|
+
```ruby
|
455
|
+
asset = organizations.assets.first
|
456
|
+
# => the first asset returned by the organization
|
457
|
+
|
458
|
+
asset.locations
|
459
|
+
# => collection of locations belonging to this asset
|
460
|
+
|
461
|
+
location = asset.locations.first
|
462
|
+
# => the first location returned by the asset. Note that locations do not have their own id's
|
463
|
+
# in the JD platform, and therefore cannot be requested individually via a "find" method.
|
464
|
+
|
465
|
+
location.timestamp
|
466
|
+
# => "2019-11-11T23:00:00.000Z"
|
467
|
+
# John Deere includes 3 decimal places in the format, but does not actually
|
468
|
+
# store fractions of a second, so it will always end in ".000". This is
|
469
|
+
# important, because timestamps must be unique.
|
470
|
+
|
471
|
+
location.geometry
|
472
|
+
# => a GeoJSON formatted hash, for example:
|
473
|
+
# {
|
474
|
+
# "type"=>"Feature",
|
475
|
+
# "geometry"=>{
|
476
|
+
# "geometries"=>[
|
477
|
+
# {
|
478
|
+
# "coordinates"=>[-95.123456, 40.123456],
|
479
|
+
# "type"=>"Point"
|
480
|
+
# }
|
481
|
+
# ],
|
482
|
+
# "type"=>"GeometryCollection"
|
483
|
+
# }
|
484
|
+
# }
|
485
|
+
|
486
|
+
location.measurement_data
|
487
|
+
# => the status details of this location, for example:
|
488
|
+
# [
|
489
|
+
# {
|
490
|
+
# "@type"=>"BasicMeasurement",
|
491
|
+
# "name"=>"[Soil Temperature](http://example.com/current_temperature)",
|
492
|
+
# "value"=>"21.0",
|
493
|
+
# "unit"=>"°C"
|
494
|
+
# }
|
495
|
+
# ]
|
496
|
+
```
|
497
|
+
|
498
|
+
The `create` method creates the location in the John Deere platform, and returns the newly created
|
499
|
+
object from John Deere. However, there will be no new information since there is no unique ID
|
500
|
+
generated. The timestamp submitted (which defaults to "now") will be rounded
|
501
|
+
to the nearest second.
|
502
|
+
|
503
|
+
```ruby
|
504
|
+
locaton = asset.locatons.create(
|
505
|
+
# You can pass fractional seconds, but they will be truncated by JD.
|
506
|
+
timestamp: "2019-11-11T23:00:00.123Z",
|
507
|
+
|
508
|
+
# JD requires more complicated JSON geometry, but this client will convert a simple
|
509
|
+
# set of lat/long coordinates into the larger format automatically.
|
510
|
+
geometry: [-95.123456, 40.123456],
|
511
|
+
|
512
|
+
# This is a list of "measurements"
|
513
|
+
measurement_data: [
|
514
|
+
{
|
515
|
+
name: 'Temperature',
|
516
|
+
value: '68.0',
|
517
|
+
unit: 'F'
|
518
|
+
}
|
519
|
+
]
|
520
|
+
)
|
521
|
+
|
522
|
+
location.timestamp
|
523
|
+
# => "2019-11-11T23:00:00.000Z"
|
524
|
+
# Note that the timestamp's fractional second is truncated by John Deere, though they
|
525
|
+
# still return the record with three digits of precision.
|
526
|
+
|
527
|
+
location.geometry
|
528
|
+
# => a GeoJSON formatted hash in its larger format
|
529
|
+
# {
|
530
|
+
# "type"=>"Feature",
|
531
|
+
# "geometry"=>{
|
532
|
+
# "geometries"=>[
|
533
|
+
# {
|
534
|
+
# "coordinates"=>[-95.123456, 40.123456],
|
535
|
+
# "type"=>"Point"
|
536
|
+
# }
|
537
|
+
# ],
|
538
|
+
# "type"=>"GeometryCollection"
|
539
|
+
# }
|
540
|
+
# }
|
541
|
+
|
542
|
+
location.measurement_data
|
543
|
+
# [
|
544
|
+
# {
|
545
|
+
# "@type"=>"BasicMeasurement",
|
546
|
+
# "name"=>"Temperature",
|
547
|
+
# "value"=>"68.0",
|
548
|
+
# "unit"=>"F"
|
549
|
+
# }
|
550
|
+
# ]
|
551
|
+
|
552
|
+
```
|
553
|
+
|
554
|
+
There is no updating or deleting of a location. The newest location record always acts as the status
|
555
|
+
for the given asset, and is what appears on the map view.
|
556
|
+
|
557
|
+
Note that locations are called "Asset Locations" in John Deere, but we call the association "locations", as in
|
558
|
+
`asset.locations`, for brevity.
|
559
|
+
|
560
|
+
|
438
561
|
## Direct API Requests
|
439
562
|
|
440
563
|
While the goal of the client is to eliminate the need to make/interpret calls to the John Deere API, it's important
|
@@ -544,7 +667,7 @@ Custom errors help clearly identify problems when using the client:
|
|
544
667
|
* **InvalidRecordError** is raised when bad input has been given, in an attempt to create or update
|
545
668
|
a record on the John Deere platform.
|
546
669
|
* **MissingContributionDefinitionIdError** is raised when the optional contribution\_definition\_id
|
547
|
-
has not been set in the client, but an operation has been attempted that requires it - like
|
670
|
+
has not been set in the client, but an operation has been attempted that requires it - like
|
548
671
|
creating an asset in the John Deere platform.
|
549
672
|
* **TypeMismatchError** is raised when a model is instantiated, typically when a record is received
|
550
673
|
from John Deere and is being converted into a Ruby object. Model instantiation is normally handled
|
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: 2.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaime Bellmyer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-02-
|
12
|
+
date: 2020-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: vcr
|