Class: GdsApi::AssetManager

Inherits:
Base
  • Object
show all
Defined in:
lib/gds_api/asset_manager.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

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) ⇒ Response?

Fetches an asset given the id

Parameters:

  • id (String)

    The asset identifier

Returns:

  • (Response, nil)

    A response object containing the parsed JSON response. If the asset cannot be found, nil wil be returned.

Raises:



44
45
46
# File 'lib/gds_api/asset_manager.rb', line 44

def asset(id)
  get_json("#{base_url}/assets/#{id}")
end

#create_asset(asset) ⇒ Net::HTTPResponse

Creates an asset given attributes

Makes a ‘POST` request to the asset manager api to create an asset. The api accepts

the following attributes:
  • ‘file` - a File object

Parameters:

  • asset (Hash)

    The attributes for the asset to send to the api.

Returns:

  • (Net::HTTPResponse)

    The raw http response from the api.

Raises:



17
18
19
# File 'lib/gds_api/asset_manager.rb', line 17

def create_asset(asset)
  post_multipart("#{base_url}/assets", { :asset => asset })
end

#update_asset(id, asset) ⇒ Net::HTTPResponse

Updates an asset given attributes

Makes a ‘PUT` request to the asset manager api to update an asset. The api accepts the following attributes:

  • ‘file` - a File object

Parameters:

  • id (String)

    The asset identifier

  • asset (Hash)

    The attributes for the asset to send to the api.

Returns:

  • (Net::HTTPResponse)

    The raw http response from the api.

Raises:



33
34
35
# File 'lib/gds_api/asset_manager.rb', line 33

def update_asset(id, asset)
  put_multipart("#{base_url}/assets/#{id}", { :asset => asset })
end