class MyJohnDeereApi::Model::Asset

Attributes

asset_category[R]
asset_sub_type[R]
asset_type[R]
last_modified_date[R]
title[R]

Public Instance Methods

attributes() click to toggle source

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

# 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
locations() click to toggle source

locations associated with this asset

# 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
save() click to toggle source

Save any attribute changes to John Deere

# 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
title=(value) click to toggle source

Change the title, locally

# File lib/my_john_deere_api/model/asset.rb, line 24
def title=(value)
  mark_as_unsaved
  @title = value
end
update(new_attributes) click to toggle source

Update the attributes in John Deere

# 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

Private Instance Methods

expected_record_type() click to toggle source
# File lib/my_john_deere_api/model/asset.rb, line 65
def expected_record_type
  'ContributedAsset'
end
map_attributes(record) click to toggle source
# File lib/my_john_deere_api/model/asset.rb, line 57
def map_attributes(record)
  @title = record['title'] if record['title']
  @asset_category = record['assetCategory'] if record['assetCategory']
  @asset_type = record['assetType'] if record['assetType']
  @asset_sub_type = record['assetSubType'] if record['assetSubType']
  @last_modified_date = record['lastModifiedDate'] if record['lastModifiedDate']
end