class SoapyYandex::Request

Attributes

api_path[R]
attributes[R]
name[R]

Public Class Methods

new(api_path, name, attributes) click to toggle source
# File lib/soapy_yandex/request.rb, line 9
def initialize(api_path, name, attributes)
  @api_path = api_path
  @name = name
  @attributes = attributes
end

Public Instance Methods

to_s() click to toggle source
# File lib/soapy_yandex/request.rb, line 15
def to_s
  Ox.dump(xml, with_xml: true)
end

Private Instance Methods

default_attributes() click to toggle source
# File lib/soapy_yandex/request.rb, line 29
def default_attributes
  {
    requestDT: Time.now.utc.iso8601,
    clientOrderId: SecureRandom.hex(12)
  }
end
node_with_attributes(name, attributes) click to toggle source
# File lib/soapy_yandex/request.rb, line 36
def node_with_attributes(name, attributes)
  Ox::Element.new(name).tap do |node|
    attributes.each do |key, value|
      node[key] = value
    end
  end
end
xml() click to toggle source
# File lib/soapy_yandex/request.rb, line 23
def xml
  Ox::Document.new(version: '1.0', encoding: 'UTF-8').tap do |doc|
    doc << node_with_attributes(name, attributes.merge(default_attributes))
  end
end