Class: MyJohnDeereApi::Request::Collection::Assets

Inherits:
Base
  • Object
show all
Defined in:
lib/my_john_deere_api/request/collection/assets.rb

Instance Attribute Summary

Attributes inherited from Base

#associations, #client

Instance Method Summary collapse

Methods inherited from Base

#all, #count, #each, #initialize

Constructor Details

This class inherits a constructor from MyJohnDeereApi::Request::Collection::Base

Instance Method Details

#create(attributes) ⇒ Object

Create a new asset



22
23
24
25
# File 'lib/my_john_deere_api/request/collection/assets.rb', line 22

def create(attributes)
  merged_attributes = attributes.merge(organization_id: associations[:organization])
  Create::Asset.new(client, merged_attributes).object
end

#find(asset_id) ⇒ Object

Retrieve an asset from JD



30
31
32
# File 'lib/my_john_deere_api/request/collection/assets.rb', line 30

def find(asset_id)
  Individual::Asset.new(client, asset_id).object
end

#modelObject

This is the class used to model the data



15
16
17
# File 'lib/my_john_deere_api/request/collection/assets.rb', line 15

def model
  MyJohnDeereApi::Model::Asset
end

#resourceObject

The resource path for the first page in the collection



8
9
10
# File 'lib/my_john_deere_api/request/collection/assets.rb', line 8

def resource
  "/platform/organizations/#{associations[:organization]}/assets"
end