my_john_deere_api 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2a0ea6da39733c6548ab2876234e2151e81a6e6014de61fa8fa84658d2d71fb
4
- data.tar.gz: feda45426448cabf22f6cbbcdf08fd69e6c4d78921e2837a85407c54dec852a5
3
+ metadata.gz: b21ab5fade7543a53cfb56a48d2cc251d397ad66ce5fc7642921084683b6a767
4
+ data.tar.gz: f6cac8a2d165caa91171d8f495faaa1013867c50402fb327fcd0ac272806ed93
5
5
  SHA512:
6
- metadata.gz: 8f19da2c83408ef7613ef628c9a15d97d6d15a248bef875ca5d4e9976b8d5d51b471a5673a1a6aaa77a3adbc87f1e9fb6ba8837a3d9aeda7df55dd8a80619ad6
7
- data.tar.gz: be95fdfa597c60f743f8125e9cbb02a316bc9f6c1e52bf8265b2300ae04f7d59bc065198aee99971f5c7dbcdf0511aad0727e27331850d205a60bb0b9068d79d
6
+ metadata.gz: d09890868c851fa39c64a7934d1060e167d980d05a058e84b699c0916642d2b485f996efea49ad20210d9d61173870a301e42a81891695a04bd0616feba0cbf0
7
+ data.tar.gz: 6fdd6b0bee46bb7a6e375259ae21c1ddf2c9113d7b2343f518e6716bf06d1c0811b4d7e3de75aa02cc90c05a76564e50d872d05e5078ec676b2b4d0d20ae49b2
data/README.md CHANGED
@@ -490,6 +490,24 @@ client.delete('/assets/123123')
490
490
 
491
491
  John Deere's standard response is a 204 HTTP status code, with the message "No Content". This method returns the full Net::HTTP response.
492
492
 
493
+
494
+ ### Errors
495
+
496
+ Custom errors help clearly identify problems when using the client:
497
+
498
+ * **UnsupportedEnvironmentError** is raised when you attempt to instantiate a client with an
499
+ unrecognized environment. Valid environments are `:sandbox` or `:production`.
500
+ * **InvalidRecordError** is raised when bad input has been given, in an attempt to create or update
501
+ a record on the John Deere platform.
502
+ * **TypeMismatchError** is raised when a model is instantiated, typically when a record is received
503
+ from John Deere and is being converted into a Ruby object. Model instantiation is normally handled
504
+ by request objects, but this error is helpful if you're instantiating your own models for advanced
505
+ usage.
506
+ * **NotYetImplementedError** is raised when you attempt to use a feature that is earmarked for future
507
+ development, but hasn't been implemented in this client yet. These are a great chance to contribute
508
+ to this gem!
509
+
510
+
493
511
  ### Contributing to This Gem
494
512
 
495
513
  The easiest way to contribute is:
@@ -2,6 +2,8 @@ require 'json'
2
2
 
3
3
  module MyJohnDeereApi
4
4
  class Request::Create::Base
5
+ include Validators::Base
6
+
5
7
  attr_reader :client, :attributes, :response
6
8
 
7
9
  ##
@@ -42,36 +44,8 @@ module MyJohnDeereApi
42
44
  @object = model.new(client, fetch_record)
43
45
  end
44
46
 
45
- ##
46
- # Runs validations, adding to the errors hash as needed. Returns true
47
- # if the errors hash is still empty after all validations have been run.
48
-
49
- def valid?
50
- return @is_valid if defined?(@is_valid)
51
-
52
- validate_required
53
- validate_attributes
54
-
55
- @is_valid = errors.empty?
56
- end
57
-
58
- ##
59
- # Raises an error if the record is invalid. Passes the errors hash
60
- # to the error, in order to build a useful message string.
61
-
62
- def validate!
63
- raise(InvalidRecordError, errors) unless valid?
64
- end
65
-
66
47
  private
67
48
 
68
- ##
69
- # Run validations unique to a given model. This should be overridden
70
- # by children where needed.
71
-
72
- def validate_attributes
73
- end
74
-
75
49
  ##
76
50
  # Convert inputs into working attributes. This allows us to auto-create
77
51
  # some attributes from others, or set defaults, on a class-by-class basis.
@@ -80,22 +54,6 @@ module MyJohnDeereApi
80
54
  def process_attributes
81
55
  end
82
56
 
83
- ##
84
- # Attributes that must be specified, override in child class
85
-
86
- def required_attributes
87
- []
88
- end
89
-
90
- ##
91
- # Validates required attributes
92
-
93
- def validate_required
94
- required_attributes.each do |attr|
95
- errors[attr] = 'is required' unless attributes[attr]
96
- end
97
- end
98
-
99
57
  ##
100
58
  # Headers for POST request
101
59
 
@@ -1,3 +1,3 @@
1
1
  module MyJohnDeereApi
2
- VERSION='2.2.2'
2
+ VERSION='2.2.3'
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: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Bellmyer