Class: Mediaflux::NamespaceExistRequest

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

Instance Attribute Summary

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:, namespace:) ⇒ NamespaceExistRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session



6
7
8
9
# File 'app/models/mediaflux/namespace_exist_request.rb', line 6

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

Class Method Details

.serviceString

Specifies the Mediaflux service to use

Returns:

  • (String)


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

def self.service
  "asset.namespace.exists"
end

Instance Method Details

#exist?Boolean

Be aware that asset.namespace.exists does not return the ID of the asset validated so we cannot return it back to the user (Mediaflux returns the path that we validated but not the actual asset ID. Hence we return true/false for this kind of request.

Returns:

  • (Boolean)


21
22
23
# File 'app/models/mediaflux/namespace_exist_request.rb', line 21

def exist?
  response_xml.xpath("/response/reply/result/exists").text == "true"
end