Class: Mediaflux::ScriptFileListIterateRequest

Inherits:
Request
  • Object
show all
Defined in:
app/models/mediaflux/script_file_list_iterate_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:, iterator:, session_user: nil) ⇒ ScriptFileListIterateRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session

  • iterator (Int)

    the iterator returned by ScriptFileListInitRequest



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

def initialize(session_token:, iterator:, session_user: nil)
  super(session_token: session_token, session_user: session_user)
  @iterator = iterator
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use

Returns:

  • (String)


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

def self.service
  "asset.script.execute"
end

Instance Method Details

#complete?Boolean

Have we iterated over all the data?

Returns:

  • (Boolean)


19
20
21
22
23
# File 'app/models/mediaflux/script_file_list_iterate_request.rb', line 19

def complete?
  nested_response = response_xml.xpath("/response/reply/result").text
  nested_xml = Nokogiri::XML.parse(nested_response)
  nested_xml.xpath("/result/iterated/@complete").first.text == "true"
end

#resultObject

Returns the file list



26
27
28
29
30
31
32
# File 'app/models/mediaflux/script_file_list_iterate_request.rb', line 26

def result
  nested_response = response_xml.xpath("/response/reply/result").text
  nested_xml = Nokogiri::XML.parse(nested_response)
  nested_xml.xpath("/result/name").map do |file|
    { id: file["id"], name: file.text }
  end
end