Class: Twinfield::Api::Finder
- Defined in:
- lib/twinfield/api/finder.rb
Class Method Summary collapse
- .actions ⇒ Object
- .request(type, options = {}) ⇒ Object
- .strip_global_namespace_from_xml(xml) ⇒ Object
- .wsdl ⇒ Object
Methods inherited from BaseApi
client, cluster, cluster_short_name, session, session=
Class Method Details
.actions ⇒ Object
9 10 11 |
# File 'lib/twinfield/api/finder.rb', line 9 def actions @actions ||= client.operations end |
.request(type, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/twinfield/api/finder.rb', line 15 def request(type, = {}) Twinfield.configuration.logger&.debug(" ↳ #{caller.find { |a| !a.match(/\/gems\/|\/ruby\/|<internal:/) }}") first_row = .delete(:first_row) || 1 pattern = .delete(:pattern) || "*" max_rows = .delete(:max_rows) || 100 = { "type" => type, "pattern" => pattern, "field" => "0", "firstRow" => first_row, "maxRows" => max_rows, "options" => { "ArrayOfString" => .map { |k, v| {"string" => [k, v]} } } } xml = client.operation(:search).build(attributes: {xmlns: "http://www.twinfield.com/"}, soap_header: session.header, message: ).build_document client.call(:search, xml: strip_global_namespace_from_xml(xml)) end |
.strip_global_namespace_from_xml(xml) ⇒ Object
38 39 40 41 |
# File 'lib/twinfield/api/finder.rb', line 38 def strip_global_namespace_from_xml xml # ugly enough xmlns is prefixed even though it suggests an element in the global document's namespace xml.gsub("<xmlns:", "<").gsub("</xmlns:", "</") end |