module StrawberryAPI::Client::Assets

Public Instance Methods

asset(id:, path: nil) click to toggle source

Fetches an asset

@param [Integer] id Id of the asset to retrieve

@return [StrawberryAPI::Asset] The fetched asset

# File lib/strawberry_api/client/assets.rb, line 22
def asset(id:, path: nil)
  if path.nil?
    data = get("/assets/#{id}").parse['asset']
  else
    data = get("/assets/by_path", body: path.to_json).parse['asset']
  end

  data.nil? ? nil : Asset.new(data)
end
asset_custom_metadata(id:) click to toggle source

Fetches an asset custom metadata

@param [Integer] id Id of the asset to retrieve metadata from

@return [Array<Hash>] The fetched asset custom metadata

# File lib/strawberry_api/client/assets.rb, line 74
def asset_custom_metadata(id:)
  data = get("/assets/#{id}/custom_metadata").parse['array']
end
asset_marker_descriptions(id:) click to toggle source

Fetches an asset marker descriptions

@param [Integer] id Id of the asset to retrieve marker descriptions from

@return [Array<StrawberryAPI::Marker>] The retrieved asset marker descriptions

# File lib/strawberry_api/client/assets.rb, line 50
def asset_marker_descriptions(id:)
  data = get("/assets/#{id}/marker_descriptions").parse['array']
  data.map do |marker|
    marker.nil? ? nil : Marker.new(marker)
  end
end
assets() click to toggle source

Fetches all assets

@return [Array<StrawberryAPI::Asset>] A list of assets

# File lib/strawberry_api/client/assets.rb, line 10
def assets
  get("/assets").parse['assets']&.map do |asset|
    Asset.new(asset)
  end
end
delete_assets(project_id:, asset_ids:) click to toggle source

Deletes a project assets

@param [Integer] project_id Id of the project to delete assets from @param [Array<Integer>] asset_ids Ids of the assets to delete

@return [Boolean] Success

# File lib/strawberry_api/client/assets.rb, line 64
def delete_assets(project_id:, asset_ids:)
  delete("/assets/destroy", body: {data: {project_id => {asset_ids: asset_ids}}}).success?
end
update_asset_custom_metadata(id:, custom_metadata:) click to toggle source

Updates an asset custom metadata

@param [Integer] id Id of the asset which to update custom metadata @param [Hash] custom_metadata Custom metadata to update the asset with

@return [Boolean] Success

# File lib/strawberry_api/client/assets.rb, line 85
def update_asset_custom_metadata(id:, custom_metadata:)
  filthy_hash = StrawberryAPI::CustomMetadatum.filthify(custom_metadata: custom_metadata)
  put("/assets/#{id}/update_metadata", query: filthy_hash).success?
end