Class: MyJohnDeereApi::Model::Asset

Inherits:
Base
  • Object
show all
Includes:
Helpers::CaseConversion
Defined in:
lib/my_john_deere_api/model/asset.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #id, #links, #record_type

Instance Method Summary collapse

Methods inherited from Base

#accessor, #initialize

Constructor Details

This class inherits a constructor from MyJohnDeereApi::Model::Base

Instance Attribute Details

#asset_categoryObject (readonly)

Returns the value of attribute asset_category.



5
6
7
# File 'lib/my_john_deere_api/model/asset.rb', line 5

def asset_category
  @asset_category
end

#asset_sub_typeObject (readonly)

Returns the value of attribute asset_sub_type.



5
6
7
# File 'lib/my_john_deere_api/model/asset.rb', line 5

def asset_sub_type
  @asset_sub_type
end

#asset_typeObject (readonly)

Returns the value of attribute asset_type.



5
6
7
# File 'lib/my_john_deere_api/model/asset.rb', line 5

def asset_type
  @asset_type
end

#last_modified_dateObject (readonly)

Returns the value of attribute last_modified_date.



5
6
7
# File 'lib/my_john_deere_api/model/asset.rb', line 5

def last_modified_date
  @last_modified_date
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/my_john_deere_api/model/asset.rb', line 5

def title
  @title
end

Instance Method Details

#attributesObject

A listing of attributes that can be passed back to John Deere



10
11
12
13
14
15
16
17
18
19
# File 'lib/my_john_deere_api/model/asset.rb', line 10

def attributes
  {
    id: id,
    title: title,
    asset_category: asset_category,
    asset_type: asset_type,
    asset_sub_type: asset_sub_type,
    organization_id: 'placeholder'
  }
end

#locationsObject

locations associated with this asset



50
51
52
53
# File 'lib/my_john_deere_api/model/asset.rb', line 50

def locations
  return @locations if defined?(@locations)
  @locations = Request::Collection::AssetLocations.new(client, asset: id)
end

#saveObject

Save any attribute changes to John Deere



32
33
34
35
36
37
# File 'lib/my_john_deere_api/model/asset.rb', line 32

def save
  if unsaved?
    mark_as_saved
    Request::Update::Asset.new(client, self, attributes).request
  end
end

#update(new_attributes) ⇒ Object

Update the attributes in John Deere



42
43
44
45
# File 'lib/my_john_deere_api/model/asset.rb', line 42

def update new_attributes
  map_attributes(camelize(new_attributes))
  Request::Update::Asset.new(client, self, attributes).request
end