Class: SquareConnect::CustomerCardApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CustomerCardApi

Returns a new instance of CustomerCardApi.



17
18
19
# File 'lib/square_connect/api/customer_card_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/customer_card_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#create_customer_card(authorization, customer_id, body, opts = {}) ⇒ CreateCustomerCardResponse

CreateCustomerCard Adds a card on file to an existing customer.

Parameters:

  • authorization

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

  • customer_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:



28
29
30
31
# File 'lib/square_connect/api/customer_card_api.rb', line 28

def create_customer_card(authorization, customer_id, body, opts = {})
  data, status_code, headers = create_customer_card_with_http_info(authorization, customer_id, body, opts)
  return data
end

#create_customer_card_with_http_info(authorization, customer_id, body, opts = {}) ⇒ Array<(CreateCustomerCardResponse, Fixnum, Hash)>

CreateCustomerCard Adds a card on file to an existing customer.

Parameters:

  • authorization

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

  • customer_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<(CreateCustomerCardResponse, Fixnum, Hash)>)

    CreateCustomerCardResponse data, response status code and response headers



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
86
87
88
89
90
# File 'lib/square_connect/api/customer_card_api.rb', line 40

def create_customer_card_with_http_info(authorization, customer_id, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CustomerCardApi#create_customer_card ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling create_customer_card" if authorization.nil?
  
  # verify the required parameter 'customer_id' is set
  fail "Missing the required parameter 'customer_id' when calling create_customer_card" if customer_id.nil?
  
  # verify the required parameter 'body' is set
  fail "Missing the required parameter 'body' when calling create_customer_card" if body.nil?
  
  # resource path
  path = "/v2/customers/{customer_id}/cards".sub('{format}','json').sub('{' + 'customer_id' + '}', customer_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 => 'CreateCustomerCardResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CustomerCardApi#create_customer_card\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_customer_card(authorization, customer_id, card_id, opts = {}) ⇒ DeleteCustomerCardResponse

DeleteCustomerCard Removes a card on file from a customer.

Parameters:

  • authorization

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

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

    the optional parameters

Returns:



99
100
101
102
# File 'lib/square_connect/api/customer_card_api.rb', line 99

def delete_customer_card(authorization, customer_id, card_id, opts = {})
  data, status_code, headers = delete_customer_card_with_http_info(authorization, customer_id, card_id, opts)
  return data
end

#delete_customer_card_with_http_info(authorization, customer_id, card_id, opts = {}) ⇒ Array<(DeleteCustomerCardResponse, Fixnum, Hash)>

DeleteCustomerCard Removes a card on file from a customer.

Parameters:

  • authorization

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

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

    the optional parameters

Returns:

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

    DeleteCustomerCardResponse data, response status code and response headers



111
112
113
114
115
116
117
118
119
120
121
122
123
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
# File 'lib/square_connect/api/customer_card_api.rb', line 111

def delete_customer_card_with_http_info(authorization, customer_id, card_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CustomerCardApi#delete_customer_card ..."
  end
  
  # verify the required parameter 'authorization' is set
  fail "Missing the required parameter 'authorization' when calling delete_customer_card" if authorization.nil?
  
  # verify the required parameter 'customer_id' is set
  fail "Missing the required parameter 'customer_id' when calling delete_customer_card" if customer_id.nil?
  
  # verify the required parameter 'card_id' is set
  fail "Missing the required parameter 'card_id' when calling delete_customer_card" if card_id.nil?
  
  # resource path
  path = "/v2/customers/{customer_id}/cards/{card_id}".sub('{format}','json').sub('{' + 'customer_id' + '}', customer_id.to_s).sub('{' + 'card_id' + '}', card_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 = nil
  
  auth_names = []
  data, status_code, headers = @api_client.call_api(:DELETE, path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'DeleteCustomerCardResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CustomerCardApi#delete_customer_card\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end