Class: Ingenico::Connect::SDK::Merchant::Refunds::RefundsClient

Inherits:
ApiResource
  • Object
show all
Defined in:
lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb

Overview

Refunds client. Thread-safe.

Instance Attribute Summary

Attributes inherited from ApiResource

#client_meta_info, #communicator

Instance Method Summary collapse

Constructor Details

#initialize(parent, path_context) ⇒ RefundsClient

Returns a new instance of RefundsClient.

Parameters:



20
21
22
# File 'lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb', line 20

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

Instance Method Details

#approve(refund_id, body, context = nil) ⇒ Object

Resource /{merchantId}/refunds/{refundId}/approve - Approve refund

Parameters:

Raises:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb', line 94

def approve(refund_id, body, context=nil)
  path_context = {
    'refundId'.freeze => refund_id,
  }
  uri = instantiate_uri('/v1/{merchantId}/refunds/{refundId}/approve', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    body,
    nil,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#cancel(refund_id, context = nil) ⇒ Object

Resource /{merchantId}/refunds/{refundId}/cancel - Cancel refund

Parameters:

Raises:



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb', line 124

def cancel(refund_id, context=nil)
  path_context = {
    'refundId'.freeze => refund_id,
  }
  uri = instantiate_uri('/v1/{merchantId}/refunds/{refundId}/cancel', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    nil,
    nil,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#cancelapproval(refund_id, context = nil) ⇒ Object

Resource /{merchantId}/refunds/{refundId}/cancelapproval - Undo approve refund

Parameters:

Raises:



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb', line 154

def cancelapproval(refund_id, context=nil)
  path_context = {
    'refundId'.freeze => refund_id,
  }
  uri = instantiate_uri('/v1/{merchantId}/refunds/{refundId}/cancelapproval', path_context)
  return @communicator.post(
    uri,
    client_headers,
    nil,
    nil,
    nil,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#find(query, context = nil) ⇒ Ingenico::Connect::SDK::Domain::Refund::FindRefundsResponse

Resource /{merchantId}/refunds - Find refunds

Parameters:

Returns:

Raises:



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb', line 37

def find(query, context=nil)
  uri = instantiate_uri('/v1/{merchantId}/refunds', nil)
  return @communicator.get(
    uri,
    client_headers,
    query,
    Ingenico::Connect::SDK::Domain::Refund::FindRefundsResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end

#get(refund_id, context = nil) ⇒ Ingenico::Connect::SDK::Domain::Refund::RefundResponse

Resource /{merchantId}/refunds/{refundId} - Get refund

Parameters:

Returns:

Raises:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb', line 64

def get(refund_id, context=nil)
  path_context = {
    'refundId'.freeze => refund_id,
  }
  uri = instantiate_uri('/v1/{merchantId}/refunds/{refundId}', path_context)
  return @communicator.get(
    uri,
    client_headers,
    nil,
    Ingenico::Connect::SDK::Domain::Refund::RefundResponse,
    context)
rescue ResponseException => e
  error_type = Ingenico::Connect::SDK::Domain::Errors::ErrorResponse
  error_object = @communicator.marshaller.unmarshal(e.body, error_type)
  raise create_exception(e.status_code, e.body, error_object, context)
end