Class: GdsApi::AssetManager
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#asset(id) ⇒ GdsApi::Response?
Fetches an asset given the id.
-
#create_asset(asset) ⇒ GdsApi::Response
Creates an asset given a hash with one
fileattribute. -
#delete_asset(id) ⇒ GdsApi::Response
Deletes an asset given an id.
-
#restore_asset(id) ⇒ GdsApi::Response
Restores an asset given an id.
-
#update_asset(id, asset) ⇒ GdsApi::Response
Updates an asset given a hash with one
fileattribute.
Methods inherited from Base
#client, #create_client, #get_list, #initialize, #url_for_slug
Constructor Details
This class inherits a constructor from GdsApi::Base
Instance Method Details
#asset(id) ⇒ GdsApi::Response?
Fetches an asset given the id
90 91 92 |
# File 'lib/gds_api/asset_manager.rb', line 90 def asset(id) get_json("#{base_url}/assets/#{id}") end |
#create_asset(asset) ⇒ GdsApi::Response
Creates an asset given a hash with one file attribute
Makes a POST request to the asset manager api to create an asset.
The asset must be provided as a Hash with a single file attribute that behaves like a File object. The content-type that the asset manager will subsequently serve will be based only on the file’s extension (derived from #path). If you supply a content-type via, for example ActionDispatch::Http::UploadedFile or another multipart wrapper, it will be ignored.
46 47 48 |
# File 'lib/gds_api/asset_manager.rb', line 46 def create_asset(asset) post_multipart("#{base_url}/assets", asset: asset) end |
#delete_asset(id) ⇒ GdsApi::Response
Deletes an asset given an id
Makes a DELETE request to the asset manager api to delete an asset.
113 114 115 |
# File 'lib/gds_api/asset_manager.rb', line 113 def delete_asset(id) delete_json("#{base_url}/assets/#{id}") end |
#restore_asset(id) ⇒ GdsApi::Response
Restores an asset given an id
Makes a POST request to the asset manager api to restore an asset.
136 137 138 |
# File 'lib/gds_api/asset_manager.rb', line 136 def restore_asset(id) post_json("#{base_url}/assets/#{id}/restore") end |
#update_asset(id, asset) ⇒ GdsApi::Response
Updates an asset given a hash with one file attribute
Makes a PUT request to the asset manager api to update an asset.
The asset must be provided as a Hash with a single file attribute that behaves like a File object. The content-type that the asset manager will subsequently serve will be based only on the file’s extension (derived from #path). If you supply a content-type via, for example ActionDispatch::Http::UploadedFile or another multipart wrapper, it will be ignored.
79 80 81 |
# File 'lib/gds_api/asset_manager.rb', line 79 def update_asset(id, asset) put_multipart("#{base_url}/assets/#{id}", asset: asset) end |