Class: Mediaflux::IteratorRequest

Inherits:
Request
  • Object
show all
Defined in:
app/models/mediaflux/iterator_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:, action: "get-values", size: nil) ⇒ IteratorRequest

Constructor

Parameters:

  • session_token (String)

    the API token for the authenticated session



7
8
9
10
11
12
# File 'app/models/mediaflux/iterator_request.rb', line 7

def initialize(session_token:, iterator:, action: "get-values", size: nil)
  super(session_token: session_token)
  @iterator = iterator
  @size = size
  @action = action
end

Class Method Details

.serviceString

Specifies the Mediaflux service to use when running a query

Returns:

  • (String)


16
17
18
# File 'app/models/mediaflux/iterator_request.rb', line 16

def self.service
  "asset.query.iterate"
end

Instance Method Details

#resultObject

Returns hash with the files fetched in this iteration as well as a flag on whether we are done iterating (complete=true) or if we need to keep iterating



22
23
24
25
26
27
28
29
# File 'app/models/mediaflux/iterator_request.rb', line 22

def result
  xml = response_xml
  {
    files: parse_files(xml),
    complete: xml.xpath("/response/reply/result/iterated/@complete").text == "true",
    count: xml.xpath("/response/reply/result/iterated").text.to_i
  }
end