Class: OnlinePayments::SDK::Merchant::MerchantBatch::MerchantBatchClient

Inherits:
ApiResource
  • Object
show all
Defined in:
lib/onlinepayments/sdk/merchant/merchantbatch/merchant_batch_client.rb

Overview

MerchantBatch client. Thread-safe.

Instance Attribute Summary

Attributes inherited from ApiResource

#client_meta_info, #communicator

Instance Method Summary collapse

Constructor Details

#initialize(parent, path_context) ⇒ MerchantBatchClient

Returns a new instance of MerchantBatchClient.

Parameters:



20
21
22
# File 'lib/onlinepayments/sdk/merchant/merchantbatch/merchant_batch_client.rb', line 20

def initialize(parent, path_context)
  super(parent: parent, path_context: path_context)
end

Instance Method Details

#get_batch_status(merchant_batch_reference, context = nil) ⇒ OnlinePayments::SDK::Domain::GetBatchStatusResponse

Resource /v2/{merchantId}/merchant-batches/{merchantBatchReference} - Get batch status

Parameters:

Returns:

Raises:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/onlinepayments/sdk/merchant/merchantbatch/merchant_batch_client.rb', line 104

def get_batch_status(merchant_batch_reference, context = nil)
  path_context = {
    'merchantBatchReference'.freeze => merchant_batch_reference,
  }
  uri = instantiate_uri('/v2/{merchantId}/merchant-batches/{merchantBatchReference}', path_context)


  @communicator.get(
    uri,
    client_headers,
    nil,
    OnlinePayments::SDK::Domain::GetBatchStatusResponse,
    context)
rescue OnlinePayments::SDK::Communication::ResponseException => e
  error_type = OnlinePayments::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise OnlinePayments::SDK.create_exception(e.status_code, e.body, error_object, context)
end

#process_batch(merchant_batch_reference, context = nil) ⇒ Object

Resource /v2/{merchantId}/merchant-batches/{merchantBatchReference}/process - Process batch transactions

Parameters:

Raises:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/onlinepayments/sdk/merchant/merchantbatch/merchant_batch_client.rb', line 70

def process_batch(merchant_batch_reference, context = nil)
  path_context = {
    'merchantBatchReference'.freeze => merchant_batch_reference,
  }
  uri = instantiate_uri('/v2/{merchantId}/merchant-batches/{merchantBatchReference}/process', path_context)


  @communicator.post(
    uri,
    client_headers,
    nil,
    nil,
    nil,
    context)
rescue OnlinePayments::SDK::Communication::ResponseException => e
  error_type = OnlinePayments::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise OnlinePayments::SDK.create_exception(e.status_code, e.body, error_object, context)
end

#submit_batch(body, context = nil) ⇒ OnlinePayments::SDK::Domain::SubmitBatchResponse

Resource /v2/{merchantId}/merchant-batches - Submit batch

Parameters:

Returns:

Raises:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/onlinepayments/sdk/merchant/merchantbatch/merchant_batch_client.rb', line 38

def submit_batch(body, context = nil)
  uri = instantiate_uri('/v2/{merchantId}/merchant-batches', nil)

  context ||= OnlinePayments::SDK::CallContext.new
  context.gzip = true

  @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    OnlinePayments::SDK::Domain::SubmitBatchResponse,
    context)
rescue OnlinePayments::SDK::Communication::ResponseException => e
  error_type = OnlinePayments::SDK::Domain::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise OnlinePayments::SDK.create_exception(e.status_code, e.body, error_object, context)
end