Class: SquareConnect::RefundApi

Inherits:
Object
  • Object
show all
Defined in:
lib/square_connect/api/refund_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RefundApi

Returns a new instance of RefundApi.



17
18
19
# File 'lib/square_connect/api/refund_api.rb', line 17

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



15
16
17
# File 'lib/square_connect/api/refund_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#create_refund(authorization, location_id, transaction_id, body, opts = {}) ⇒ CreateRefundResponse

CreateRefund Initiates a refund for a previously charged tender.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the original transaction's associated location.

  • transaction_id
  • body

    An object containing the fields to POST for the request.nnSee the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



111
112
113
114
# File 'lib/square_connect/api/refund_api.rb', line 111

def create_refund(authorization, location_id, transaction_id, body, opts = {})
  data, status_code, headers = create_refund_with_http_info(authorization, location_id, transaction_id, body, opts)
  return data
end

#create_refund_with_http_info(authorization, location_id, transaction_id, body, opts = {}) ⇒ Array<(CreateRefundResponse, Fixnum, Hash)>

CreateRefund Initiates a refund for a previously charged tender.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the original transaction&#39;s associated location.

  • transaction_id
  • body

    An object containing the fields to POST for the request.nnSee the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CreateRefundResponse, Fixnum, Hash)>)

    CreateRefundResponse data, response status code and response headers



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/square_connect/api/refund_api.rb', line 124

def create_refund_with_http_info(authorization, location_id, transaction_id, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: RefundApi#create_refund ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling create_refund" if authorization.nil?
  
  # verify the required parameter 'location_id' is set
  fail "Missing the required parameter 'location_id' when calling create_refund" if location_id.nil?
  
  # verify the required parameter 'transaction_id' is set
  fail "Missing the required parameter 'transaction_id' when calling create_refund" if transaction_id.nil?
  
  # verify the required parameter 'body' is set
  fail "Missing the required parameter 'body' when calling create_refund" if body.nil?
  
  # resource path
  path = "/v2/locations/{location_id}/transactions/{transaction_id}/refund".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
  header_params[:'Authorization'] = authorization

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(body)
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CreateRefundResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RefundApi#create_refund\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_refunds(authorization, location_id, opts = {}) ⇒ ListRefundsResponse

ListRefunds Lists refunds for one of a business&#39;s locations.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the location to list refunds for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :begin_time (String)

    The beginning of the requested reporting period, in RFC 3339 format.

  • :end_time (String)

    The end of the requested reporting period, in RFC 3339 format.

  • :sort_order (String)

    The order in which results are listed in the response.

  • :cursor (String)

    A pagination cursor to retrieve the next set of results for yournoriginal query to the endpoint.

Returns:



31
32
33
34
# File 'lib/square_connect/api/refund_api.rb', line 31

def list_refunds(authorization, location_id, opts = {})
  data, status_code, headers = list_refunds_with_http_info(authorization, location_id, opts)
  return data
end

#list_refunds_with_http_info(authorization, location_id, opts = {}) ⇒ Array<(ListRefundsResponse, Fixnum, Hash)>

ListRefunds Lists refunds for one of a business&#39;s locations.

Parameters:

  • authorization

    The value to provide in the Authorization header ofnyour request. This value should follow the format ‘Bearer YOUR_ACCESS_TOKEN_HERE`.

  • location_id

    The ID of the location to list refunds for.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :begin_time (String)

    The beginning of the requested reporting period, in RFC 3339 format.

  • :end_time (String)

    The end of the requested reporting period, in RFC 3339 format.

  • :sort_order (String)

    The order in which results are listed in the response.

  • :cursor (String)

    A pagination cursor to retrieve the next set of results for yournoriginal query to the endpoint.

Returns:

  • (Array<(ListRefundsResponse, Fixnum, Hash)>)

    ListRefundsResponse data, response status code and response headers



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/square_connect/api/refund_api.rb', line 46

def list_refunds_with_http_info(authorization, location_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: RefundApi#list_refunds ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling list_refunds" if authorization.nil?
  
  # verify the required parameter 'location_id' is set
  fail "Missing the required parameter 'location_id' when calling list_refunds" if location_id.nil?
  
  if opts[:'sort_order'] && !['DESC', 'ASC'].include?(opts[:'sort_order'])
    fail 'invalid value for "sort_order", must be one of DESC, ASC'
  end
  
  # resource path
  path = "/v2/locations/{location_id}/refunds".sub('{format}','json').sub('{' + 'location_id' + '}', location_id.to_s)

  # query parameters
  query_params = {}
  query_params[:'begin_time'] = opts[:'begin_time'] if opts[:'begin_time']
  query_params[:'end_time'] = opts[:'end_time'] if opts[:'end_time']
  query_params[:'sort_order'] = opts[:'sort_order'] if opts[:'sort_order']
  query_params[:'cursor'] = opts[:'cursor'] if opts[:'cursor']

  # header parameters
  header_params = {}

  # HTTP header 'Accept' (if needed)
  _header_accept = ['application/json']
  _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result

  # HTTP header 'Content-Type'
  _header_content_type = ['application/json']
  header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
  header_params[:'Authorization'] = authorization

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'ListRefundsResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RefundApi#list_refunds\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end