Class: MyJohnDeereApi::Request::Create::Base
- Inherits:
-
Object
- Object
- MyJohnDeereApi::Request::Create::Base
- Includes:
- Validators::Base
- Defined in:
- lib/my_john_deere_api/request/create/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Attributes included from Validators::Base
Instance Method Summary collapse
-
#initialize(client, attributes) ⇒ Base
constructor
Accepts a valid oAuth AccessToken, and a hash of attributes.
-
#object ⇒ Object
Object created by request.
-
#request ⇒ Object
Make the request, if the instance is valid.
Methods included from Validators::Base
Constructor Details
#initialize(client, attributes) ⇒ Base
Accepts a valid oAuth AccessToken, and a hash of attributes.
12 13 14 15 16 17 |
# File 'lib/my_john_deere_api/request/create/base.rb', line 12 def initialize(client, attributes) @client = client @attributes = attributes process_attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/my_john_deere_api/request/create/base.rb', line 7 def attributes @attributes end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/my_john_deere_api/request/create/base.rb', line 7 def client @client end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/my_john_deere_api/request/create/base.rb', line 7 def response @response end |
Instance Method Details
#object ⇒ Object
Object created by request
31 32 33 34 35 36 37 |
# File 'lib/my_john_deere_api/request/create/base.rb', line 31 def object return @object if defined?(@object) request unless response @object = individual_class.new(client, record_id).object end |
#request ⇒ Object
Make the request, if the instance is valid
22 23 24 25 26 |
# File 'lib/my_john_deere_api/request/create/base.rb', line 22 def request validate! @response = client.post(resource, request_body) end |