Module: StrawberryAPI::Client::Assets

Included in:
StrawberryAPI::Client
Defined in:
lib/strawberry_api/client/assets.rb

Instance Method Summary collapse

Instance Method Details

#asset(id:, path: nil) ⇒ StrawberryAPI::Asset

Fetches an asset



22
23
24
25
26
27
28
29
30
# 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:) ⇒ Array<Hash>

Fetches an asset custom metadata



74
75
76
# File 'lib/strawberry_api/client/assets.rb', line 74

def (id:)
  data = get("/assets/#{id}/custom_metadata").parse['array']
end

Fetches an asset links



38
39
40
41
42
# 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

#asset_marker_descriptions(id:) ⇒ Array<StrawberryAPI::Marker>

Fetches an asset marker descriptions



50
51
52
53
54
55
# 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

#assetsArray<StrawberryAPI::Asset>

Fetches all assets



10
11
12
13
14
# 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:) ⇒ Boolean

Deletes a project assets



64
65
66
# 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:) ⇒ Boolean

Updates an asset custom metadata



85
86
87
88
# File 'lib/strawberry_api/client/assets.rb', line 85

def (id:, custom_metadata:)
  filthy_hash = StrawberryAPI::CustomMetadatum.filthify(custom_metadata: )
  put("/assets/#{id}/update_metadata", query: filthy_hash).success?
end