myjohndeere 0.0.11 → 0.1.0

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
  SHA1:
3
- metadata.gz: c1831ed7f9d5597914571ae4a25fd71625b9f99e
4
- data.tar.gz: 4197edf1ab0d1da49e9701a068acd99c429f12a0
3
+ metadata.gz: 7e6813bb496ffe2d2a5d24c26c9255d554675184
4
+ data.tar.gz: 9da19d2acb3e3fdad3b8d08c138e333ee5019f69
5
5
  SHA512:
6
- metadata.gz: 56e08d24d21555aa5172a6f375c7c94afc29270fbffa5365ec487fbb3dc49aa34ab919687f6d052986f5965166fa6795350c2c5fbae3d85401cc56e513da670f
7
- data.tar.gz: a13f520f6b07bf56efc54be842b00008ae033c0d076e5ff589739be54f363688be1eada9f2d9a383bc2d75a4b1025cb2f4d0acdf27ef4a396d3c8c9426f6faed
6
+ metadata.gz: 3c0d1f7ffd65f2b0c3f1b806d1282f2df3c84c807a4d2ab2c6689af54eaecab6c3cb901d5d5826f227e730bd812bbb2885a73c54fe369eb5ef5d4c73c5f09a35
7
+ data.tar.gz: 39b995dbdcbfa0af60fd5a2d0cc3b9ce6d6a97c1a7c616f4b79f15ed5d3e38a474a7c2ebf39b09cb5087b3f1b149134a6171a59c68c3aebe5e22e5605e397a40
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- myjohndeere (0.0.11)
4
+ myjohndeere (0.1.0)
5
5
  oauth (>= 0.5.3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  The MyJohnDeere Ruby library provides convenient access to the MyJohnDeere API from applications written in the Ruby language. It includes a pre-defined set of classes for API resources that are available currently from the API. You will need to get access by going to the [JohnDeere Developer page](https://developer.deere.com/#!welcome). The interface utilizes OAUTH 1.0.
4
4
 
5
+ ## Installation
6
+
7
+ You don't need this source code unless you want to modify the gem. If you just want to use the package, just run:
8
+
9
+ `gem install myjohndeere`
10
+
11
+ If you want to build the gem from source:
12
+
13
+ `gem build myjohndeere.gemspec`
14
+
5
15
  ## Usage
6
16
 
7
17
  ### Configuration
@@ -82,13 +92,13 @@ end
82
92
 
83
93
  ## Listable Objects
84
94
 
85
- MyJohnDeere returns either pages of objects that will automatically be iterated through 10 at a time *or* you'll receive the entirety of the resource if you specify an etag token. **The default behavior is for pagination.**
95
+ MyJohnDeere returns either pages of objects that will automatically be iterated through 10 at a time *or* you'll receive the entirety of the resource if you specify an ETAG token. **The default behavior is for pagination.**
86
96
 
87
97
  **If using the paginated approach**: Use `more_pages?` on the listable object to see if there are more pages to be acquired by using `next_page!`. This will modify the `.start` and `.count` values on the list object. These automatically increase with each `next_page`.
88
98
 
89
- **If using the etag approach**: The entirety of the data set will be returned to you and on the list object you'll want to call `list.etag` and store this locally. You can then use this on future requests to see if anything has changed from the original request.
99
+ **If using the ETAG approach**: The entirety of the data set will be returned to you and on the list object you'll want to call `list.etag` and store this locally. You can then use this on future requests to see if anything has changed from the original request. To use it: `MyJohnDeere::Organization.list(access_token, etag: '')`
90
100
 
91
- If you for some reason specify both, the etag will be the assumed behavior.
101
+ If you for some reason specify both, the ETAG will be the assumed behavior.
92
102
 
93
103
  The raw data can be acquired by using `.data` on a listable object.
94
104
 
@@ -10,7 +10,6 @@ module MyJohnDeere
10
10
  super(json_object, access_token)
11
11
  self.field_id = field_id
12
12
  self.active = self.active.to_s.downcase == "true"
13
- self.multipolygons = json_object["multipolygons"]
14
13
  # This doesn't exist currently, not sure why
15
14
  self.field_id ||= extract_link_with_rel_from_list("fields", /\/(\d+)\/(.+?)\/fields\Z/)
16
15
  end
@@ -10,9 +10,14 @@ module MyJohnDeere
10
10
  def list(access_token, options = {})
11
11
  validate_access_token(access_token)
12
12
  options = {count: 10, start: 0, etag: nil}.merge(options)
13
+ if !options[:etag].nil? then
14
+ options.delete(:count)
15
+ options.delete(:start)
16
+ end
13
17
  options[:body] ||= {}
14
18
  # The count and start are in this list,so move them into the body
15
19
  SPECIAL_BODY_PARAMETERS.each do |sbp|
20
+ next if options[sbp].nil?
16
21
  options[:body][sbp] = options[sbp]
17
22
  end
18
23
 
@@ -1,3 +1,3 @@
1
1
  module MyJohnDeere
2
- VERSION = '0.0.11'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -25,6 +25,20 @@ class TestRestMethods < Minitest::Test
25
25
  end
26
26
  end
27
27
 
28
+ def test_deleted_object_with_etag
29
+ etag_val = "something"
30
+ new_etag = "something2"
31
+ stub_request(:get, /organizations\Z/).
32
+ with(headers: {MyJohnDeere::ETAG_HEADER_KEY => etag_val}).
33
+ to_return(status: 200, body: API_FIXTURES["deleted_organization"].to_json(),
34
+ headers: {MyJohnDeere::ETAG_HEADER_KEY=>new_etag})
35
+
36
+ organizations = MyJohnDeere::Organization.list(default_access_token, etag: etag_val)
37
+
38
+ assert organizations.data.first.deleted
39
+ assert_equal new_etag, organizations.etag
40
+ end
41
+
28
42
  def test_list_with_etag
29
43
  stub_request(:get, /organizations/).
30
44
  with(headers: {MyJohnDeere::ETAG_HEADER_KEY => ""}).
@@ -49,8 +63,9 @@ class TestRestMethods < Minitest::Test
49
63
  end
50
64
 
51
65
  def test_list_with_body
52
- stub_request(:get, /organizations;start=0;count=1/).
53
- with(query: {embed: "boundaries"}).
66
+ stub_request(:get, /organizations/).
67
+ with(query: {embed: "boundaries"},
68
+ headers: {MyJohnDeere::ETAG_HEADER_KEY=>""}).
54
69
  to_return(status: 200, body: LIST_FIXTURE.to_json())
55
70
  organizations = MyJohnDeere::Organization.list(default_access_token, count: 1, etag: "", body: {embed: "boundaries"})
56
71
  assert_equal({:embed=>"boundaries"}, organizations.options[:body])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myjohndeere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Susmarski