Class: Docdata::Order::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/docdata/order/request.rb

Overview

Base class for XML requests to Docdata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



12
13
14
# File 'lib/docdata/order/request.rb', line 12

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/docdata/order/request.rb', line 10

def options
  @options
end

Instance Method Details

#to_sObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/docdata/order/request.rb', line 16

def to_s
  builder = Builder::XmlMarkup.new

  # Merchant credentials.
  if subject_merchant
    builder.merchant(name: merchant_name, password: merchant_password) do |merchant|
      # The merchant on whose behalf this request should be executed.
      merchant.subjectMerchant(name: subject_merchant_name, token: subject_merchant_token) do |subject|
        if subject_merchant_fee
          # The fee to apply to the subject merchant. If the fee is zero, then it is ignored. A fee can only be applied to create-order requests.
          subject.fee(moment: subject_merchant_fee_moment) do |fee|
            fee.amount(subject_merchant_fee_amount, currency: subject_merchant_fee_currency)
            fee.description(subject_merchant_fee_description) if subject_merchant_fee_description
          end
        end
      end
    end
  else
    builder.merchant(name: merchant_name, password: merchant_password)
  end

  build_request(builder)

  # This element contains information about the application contacting the webservice.
  # This info is useful when debugging troubleshooting technical integration issues.
  builder.integrationInfo do |integration|
    # The name of the plugin used to contact this webservice.
    integration.webshopPlugin('docdata-order')
    # The version of the plugin used to contact this webservice.
    integration.webshopPluginVersion(Docdata::Order::VERSION)
    # The name of the plugin creator used to contact this webservice.
    integration.integratorName('Kentaa')
    # The programming language used to contact this webservice.
    integration.programmingLanguage("Ruby #{RUBY_VERSION}")
    # The operating system from which this webservice is contacted.
    integration.operatingSystem(RUBY_PLATFORM)
    # The full version number (including minor e.q. 1.3.0)
    # of the xsd which is used during integration. DDP can make minor
    # (non-breaking) changes to the xsd. These are reflected in a minor
    # version number. It can therefore be useful to know if a different
    # minor version of the xsd was used during merchant development than
    # the one currently active in production.
    integration.ddpXsdVersion(Docdata::Order::Client::DDP_VERSION)
  end

  builder.target!
end