class MyJohnDeereApi::Request::Create::Asset

Private Instance Methods

individual_class() click to toggle source

This is the class used to fetch an individual item

# File lib/my_john_deere_api/request/create/asset.rb, line 20
def individual_class
  Request::Individual::Asset
end
record_id() click to toggle source

id of newly created record

# File lib/my_john_deere_api/request/create/asset.rb, line 13
def record_id
  response.headers['location'].split('/').last
end
request_body() click to toggle source

Request body

# File lib/my_john_deere_api/request/create/asset.rb, line 34
def request_body
  return @body if defined?(@body)

  validate_contribution_definition

  @body = {
    title: attributes[:title],
    assetCategory: attributes[:asset_category],
    assetType: attributes[:asset_type],
    assetSubType: attributes[:asset_sub_type],
    links: [
      {
        '@type' => 'Link',
        'rel' => 'contributionDefinition',
        'uri' => client.contribution_definition_uri,
      }
    ]
  }
end
resource() click to toggle source

Path supplied to API

# File lib/my_john_deere_api/request/create/asset.rb, line 27
def resource
  @resource ||= "/platform/organizations/#{attributes[:organization_id]}/assets"
end