Class: Noths::RefundsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/noths/api/refunds_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RefundsApi

Returns a new instance of RefundsApi.



9
10
11
# File 'lib/noths/api/refunds_api.rb', line 9

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



7
8
9
# File 'lib/noths/api/refunds_api.rb', line 7

def api_client
  @api_client
end

Instance Method Details

#refunds_create(token, order_id, refund_reason, cents, opts = {}) ⇒ RefundResponse

Refund an order Refunds all or part of an order

Parameters:

  • token

    Authentication credential

  • order_id

    Order id

  • refund_reason

    Customer will see this message

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

    the optional parameters

Returns:



21
22
23
24
# File 'lib/noths/api/refunds_api.rb', line 21

def refunds_create(token, order_id, refund_reason, cents, opts = {})
  data, _status_code, _headers = refunds_create_with_http_info(token, order_id, refund_reason, cents, opts)
  return data
end

#refunds_create_with_http_info(token, order_id, refund_reason, cents, opts = {}) ⇒ Array<(RefundResponse, Fixnum, Hash)>

Refund an order Refunds all or part of an order

Parameters:

  • token

    Authentication credential

  • order_id

    Order id

  • refund_reason

    Customer will see this message

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

    the optional parameters

Returns:

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

    RefundResponse data, response status code and response headers



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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/noths/api/refunds_api.rb', line 34

def refunds_create_with_http_info(token, order_id, refund_reason, cents, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: RefundsApi.refunds_create ..."
  end
  # verify the required parameter 'token' is set
  if @api_client.config.client_side_validation && token.nil?
    fail ArgumentError, "Missing the required parameter 'token' when calling RefundsApi.refunds_create"
  end
  # verify the required parameter 'order_id' is set
  if @api_client.config.client_side_validation && order_id.nil?
    fail ArgumentError, "Missing the required parameter 'order_id' when calling RefundsApi.refunds_create"
  end
  # verify the required parameter 'refund_reason' is set
  if @api_client.config.client_side_validation && refund_reason.nil?
    fail ArgumentError, "Missing the required parameter 'refund_reason' when calling RefundsApi.refunds_create"
  end
  # verify the required parameter 'cents' is set
  if @api_client.config.client_side_validation && cents.nil?
    fail ArgumentError, "Missing the required parameter 'cents' when calling RefundsApi.refunds_create"
  end
  # resource path
  local_var_path = "/api/v1/orders/{order_id}/refunds".sub('{' + 'order_id' + '}', order_id.to_s)

  # query parameters
  query_params = {}
  query_params[:'token'] = token

  # header parameters
  header_params = {}
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

  # form parameters
  form_params = {}
  form_params["refund_reason"] = refund_reason
  form_params["cents"] = cents

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