Class: Docdata::Order::Client

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

Overview

Client for the Docdata Order API.

Constant Summary collapse

XMLNS_DDP =
"http://www.docdatapayments.com/services/paymentservice/1_3/"
DDP_VERSION =
"1.3"

Instance Method Summary collapse

Constructor Details

#initialize(name, password, options = {}) ⇒ Client

Returns a new instance of Client.



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

def initialize(name, password, options = {})
  @options = options.merge(merchant: { name: name, password: password })
end

Instance Method Details

#create(options = {}) ⇒ Object

Raises:



16
17
18
19
20
21
22
23
24
# File 'lib/docdata/order/client.rb', line 16

def create(options = {})
  params = @options.merge(options)

  response = client.call(:create, message: CreateRequest.new(params), attributes: { xmlns: XMLNS_DDP, version: DDP_VERSION })

  raise Exception, response unless response.success?

  CreateResponse.new(params, response)
end

#start(options = {}) ⇒ Object

Raises:



26
27
28
29
30
31
32
33
34
# File 'lib/docdata/order/client.rb', line 26

def start(options = {})
  params = @options.merge(options)

  response = client.call(:start, message: StartRequest.new(params), attributes: { xmlns: XMLNS_DDP, version: DDP_VERSION })

  raise Exception, response unless response.success?

  StartResponse.new(params, response)
end

#status(options = {}) ⇒ Object

Raises:



36
37
38
39
40
41
42
43
44
# File 'lib/docdata/order/client.rb', line 36

def status(options = {})
  params = @options.merge(options)

  response = client.call(:status_extended, message: ExtendedStatusRequest.new(params), attributes: { xmlns: XMLNS_DDP, version: DDP_VERSION })

  raise Exception, response unless response.success?

  ExtendedStatusResponse.new(params, response)
end