module StrawberryAPI::Client::Assets
Public Instance Methods
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
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
Fetches an asset links
@param [Integer] ids Ids of the asset to retrieve links from
@return [Array<Hash>] The retrieved asset links
# File lib/strawberry_api/client/assets.rb, line 38 def asset_links(ids:) get("/assets/links", body: {asset_ids: ids}.to_json).parse['links']&.map do |link| link end end
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
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
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
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