Class: Mediaflux::AssetMetadataRequest

Inherits:
Request
  • Object
show all
Defined in:
app/models/mediaflux/asset_metadata_request.rb

Overview

Get metadata about an asset in mediaflux

Examples:

 = Mediaflux::AssetMetadataRequest.new(
session_token: current_user.mediaflux_session, id: mediaflux_id).

Instance Attribute Summary collapse

Attributes inherited from Request

#session_token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

build_post_request, default_xml_namespace, default_xml_namespace_uri, #error?, find_or_create_http_client, format_date_for_mediaflux, request_path, #resolve, #resolved?, #response_body, #response_error, #response_xml, uri, #xml_payload, #xtoshell_xml

Constructor Details

#initialize(session_token:, id:) ⇒ AssetMetadataRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session

  • id (Integer)

    Id of the Asset to return the metadata for



13
14
15
16
# File 'app/models/mediaflux/asset_metadata_request.rb', line 13

def initialize(session_token:, id:)
  super(session_token: session_token)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'app/models/mediaflux/asset_metadata_request.rb', line 8

def id
  @id
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use when getting asset metadata

Returns:

  • (String)


20
21
22
# File 'app/models/mediaflux/asset_metadata_request.rb', line 20

def self.service
  "asset.get"
end

Instance Method Details

#metadataObject

parse the returned XML into a hash about the asset that can be utilized



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/mediaflux/asset_metadata_request.rb', line 25

def 
  xml = response_xml
  asset = xml.xpath("/response/reply/result/asset")
   = parse(asset)

  if [:collection]
    [:total_file_count] = asset.xpath("./collection/accumulator/value/non-collections").text
    [:size] = asset.xpath("./collection/accumulator/value/total/@h").text
    [:accum_names] = asset.xpath("./collection/accumulator/@name")
    [:ctime] = asset.xpath("./ctime")
  end

  parse_image(asset.xpath("./meta/mf-image"), ) # this does not do anything because mf-image is not a part of the meta xpath

  parse_note(asset.xpath("./meta/mf-note"), ) # this does not do anything because mf-note is not a part of the meta xpath

  parse_quota(asset.xpath("./collection/quota"), )
  
end