Class: SmplkitGeneratedClient::App::BillingApi

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ BillingApi

Returns a new instance of BillingApi.



19
20
21
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_payment_method(add_payment_method_body, opts = {}) ⇒ PaymentMethodResponse

Add Payment Method Register a Stripe payment method (‘pm_…`) on the account. The client first creates the Stripe payment method using a SetupIntent and Stripe Elements, then submits its identifier here to persist it.

Parameters:

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

    the optional parameters

Returns:



27
28
29
30
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 27

def create_payment_method(add_payment_method_body, opts = {})
  data, _status_code, _headers = create_payment_method_with_http_info(add_payment_method_body, opts)
  data
end

#create_payment_method_with_http_info(add_payment_method_body, opts = {}) ⇒ Array<(PaymentMethodResponse, Integer, Hash)>

Add Payment Method Register a Stripe payment method (&#x60;pm_…&#x60;) on the account. The client first creates the Stripe payment method using a SetupIntent and Stripe Elements, then submits its identifier here to persist it.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(PaymentMethodResponse, Integer, Hash)>)

    PaymentMethodResponse data, response status code and response headers



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
86
87
88
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 37

def create_payment_method_with_http_info(add_payment_method_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.create_payment_method ...'
  end
  # verify the required parameter 'add_payment_method_body' is set
  if @api_client.config.client_side_validation && add_payment_method_body.nil?
    fail ArgumentError, "Missing the required parameter 'add_payment_method_body' when calling BillingApi.create_payment_method"
  end
  # resource path
  local_var_path = '/api/v1/payment_methods'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(add_payment_method_body)

  # return_type
  return_type = opts[:debug_return_type] || 'PaymentMethodResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.create_payment_method",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#create_payment_method\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_payment_method(id, opts = {}) ⇒ nil

Delete Payment Method Delete a payment method. Returns 409 if this is the only payment method on file and the account has an active paid subscription. If the deleted payment method was the default, the oldest remaining payment method is promoted to default.

Parameters:

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

    the optional parameters

Returns:

  • (nil)


95
96
97
98
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 95

def delete_payment_method(id, opts = {})
  delete_payment_method_with_http_info(id, opts)
  nil
end

#delete_payment_method_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Payment Method Delete a payment method. Returns 409 if this is the only payment method on file and the account has an active paid subscription. If the deleted payment method was the default, the oldest remaining payment method is promoted to default.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



105
106
107
108
109
110
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
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 105

def delete_payment_method_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.delete_payment_method ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling BillingApi.delete_payment_method"
  end
  # resource path
  local_var_path = '/api/v1/payment_methods/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.delete_payment_method",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#delete_payment_method\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#execute_setup_intent(opts = {}) ⇒ SetupIntentResponse

Execute Setup Intent Create a Stripe SetupIntent for adding a payment method without an immediate charge. Returns the ‘client_secret` to pass to Stripe Elements in the browser.

Parameters:

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

    the optional parameters

Returns:



157
158
159
160
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 157

def execute_setup_intent(opts = {})
  data, _status_code, _headers = execute_setup_intent_with_http_info(opts)
  data
end

#execute_setup_intent_with_http_info(opts = {}) ⇒ Array<(SetupIntentResponse, Integer, Hash)>

Execute Setup Intent Create a Stripe SetupIntent for adding a payment method without an immediate charge. Returns the &#x60;client_secret&#x60; to pass to Stripe Elements in the browser.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(SetupIntentResponse, Integer, Hash)>)

    SetupIntentResponse data, response status code and response headers



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 166

def execute_setup_intent_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.execute_setup_intent ...'
  end
  # resource path
  local_var_path = '/api/v1/functions/setup_intent/actions/execute'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SetupIntentResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.execute_setup_intent",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#execute_setup_intent\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_invoice(invoice_id, opts = {}) ⇒ InvoiceSingleResponse

Get Invoice Return a single invoice by id. Supports content negotiation via the ‘Accept` header: - `application/pdf` — streams the invoice PDF. - `application/vnd.api+json`, `application/json`, or absent — returns the JSON:API invoice resource. - Any other value — `406 Not Acceptable`.

Parameters:

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

    the optional parameters

Returns:



215
216
217
218
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 215

def get_invoice(invoice_id, opts = {})
  data, _status_code, _headers = get_invoice_with_http_info(invoice_id, opts)
  data
end

#get_invoice_with_http_info(invoice_id, opts = {}) ⇒ Array<(InvoiceSingleResponse, Integer, Hash)>

Get Invoice Return a single invoice by id. Supports content negotiation via the &#x60;Accept&#x60; header: - &#x60;application/pdf&#x60; — streams the invoice PDF. - &#x60;application/vnd.api+json&#x60;, &#x60;application/json&#x60;, or absent — returns the JSON:API invoice resource. - Any other value — &#x60;406 Not Acceptable&#x60;.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(InvoiceSingleResponse, Integer, Hash)>)

    InvoiceSingleResponse data, response status code and response headers



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 225

def get_invoice_with_http_info(invoice_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.get_invoice ...'
  end
  # verify the required parameter 'invoice_id' is set
  if @api_client.config.client_side_validation && invoice_id.nil?
    fail ArgumentError, "Missing the required parameter 'invoice_id' when calling BillingApi.get_invoice"
  end
  # resource path
  local_var_path = '/api/v1/invoices/{invoice_id}'.sub('{invoice_id}', CGI.escape(invoice_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'InvoiceSingleResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.get_invoice",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#get_invoice\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_payment_method(id, opts = {}) ⇒ PaymentMethodResponse

Get Payment Method Return a payment method by id.

Parameters:

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

    the optional parameters

Returns:



278
279
280
281
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 278

def get_payment_method(id, opts = {})
  data, _status_code, _headers = get_payment_method_with_http_info(id, opts)
  data
end

#get_payment_method_with_http_info(id, opts = {}) ⇒ Array<(PaymentMethodResponse, Integer, Hash)>

Get Payment Method Return a payment method by id.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(PaymentMethodResponse, Integer, Hash)>)

    PaymentMethodResponse data, response status code and response headers



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 288

def get_payment_method_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.get_payment_method ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling BillingApi.get_payment_method"
  end
  # resource path
  local_var_path = '/api/v1/payment_methods/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PaymentMethodResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.get_payment_method",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#get_payment_method\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_invoices(opts = {}) ⇒ InvoiceListResponse

List Invoices Return invoice history for the account from Stripe. Default sort is ‘-created_at` (newest first).

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :sort (String)

    Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;-created_at&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;status&#x60;, &#x60;-status&#x60;, &#x60;total&#x60;, &#x60;-total&#x60;. (default to ‘-created_at’)

Returns:



341
342
343
344
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 341

def list_invoices(opts = {})
  data, _status_code, _headers = list_invoices_with_http_info(opts)
  data
end

#list_invoices_with_http_info(opts = {}) ⇒ Array<(InvoiceListResponse, Integer, Hash)>

List Invoices Return invoice history for the account from Stripe. Default sort is &#x60;-created_at&#x60; (newest first).

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :sort (String)

    Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;-created_at&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;status&#x60;, &#x60;-status&#x60;, &#x60;total&#x60;, &#x60;-total&#x60;. (default to ‘-created_at’)

Returns:

  • (Array<(InvoiceListResponse, Integer, Hash)>)

    InvoiceListResponse data, response status code and response headers



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 351

def list_invoices_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.list_invoices ...'
  end
  allowable_values = ["created_at", "-created_at", "status", "-status", "total", "-total"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/v1/invoices'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'InvoiceListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.list_invoices",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#list_invoices\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_payment_methods(opts = {}) ⇒ PaymentMethodListResponse

List Payment Methods List all payment methods for the account. Default is returned first, then newest first.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :sort (String)

    Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;-created_at&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;exp_year&#x60;, &#x60;-exp_year&#x60;, &#x60;is_default&#x60;, &#x60;-is_default&#x60;, &#x60;updated_at&#x60;, &#x60;-updated_at&#x60;. (default to ‘-created_at’)

Returns:



405
406
407
408
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 405

def list_payment_methods(opts = {})
  data, _status_code, _headers = list_payment_methods_with_http_info(opts)
  data
end

#list_payment_methods_with_http_info(opts = {}) ⇒ Array<(PaymentMethodListResponse, Integer, Hash)>

List Payment Methods List all payment methods for the account. Default is returned first, then newest first.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :sort (String)

    Field to sort by. Prefix with &#x60;-&#x60; for descending order. Default: &#x60;-created_at&#x60;. Allowed values: &#x60;created_at&#x60;, &#x60;-created_at&#x60;, &#x60;exp_year&#x60;, &#x60;-exp_year&#x60;, &#x60;is_default&#x60;, &#x60;-is_default&#x60;, &#x60;updated_at&#x60;, &#x60;-updated_at&#x60;. (default to ‘-created_at’)

Returns:

  • (Array<(PaymentMethodListResponse, Integer, Hash)>)

    PaymentMethodListResponse data, response status code and response headers



415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 415

def list_payment_methods_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.list_payment_methods ...'
  end
  allowable_values = ["created_at", "-created_at", "exp_year", "-exp_year", "is_default", "-is_default", "updated_at", "-updated_at"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/v1/payment_methods'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PaymentMethodListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.list_payment_methods",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#list_payment_methods\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#set_default_payment_method(id, opts = {}) ⇒ PaymentMethodResponse

Set Default Payment Method Mark this payment method as the account’s default. Idempotent: returns 200 with no changes when the payment method is already the default.

Parameters:

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

    the optional parameters

Returns:



469
470
471
472
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 469

def set_default_payment_method(id, opts = {})
  data, _status_code, _headers = set_default_payment_method_with_http_info(id, opts)
  data
end

#set_default_payment_method_with_http_info(id, opts = {}) ⇒ Array<(PaymentMethodResponse, Integer, Hash)>

Set Default Payment Method Mark this payment method as the account&#39;s default. Idempotent: returns 200 with no changes when the payment method is already the default.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(PaymentMethodResponse, Integer, Hash)>)

    PaymentMethodResponse data, response status code and response headers



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 479

def set_default_payment_method_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.set_default_payment_method ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling BillingApi.set_default_payment_method"
  end
  # resource path
  local_var_path = '/api/v1/payment_methods/{id}/actions/set_default'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'PaymentMethodResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.set_default_payment_method",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#set_default_payment_method\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_payment_method(id, payment_method_request, opts = {}) ⇒ PaymentMethodResponse

Update Payment Method Update the mutable fields of a payment method (‘billing_details`, `exp_month`, `exp_year`). The `default` flag is not mutable via PUT — use the `set_default` action instead.

Parameters:

  • id (String)
  • payment_method_request (PaymentMethodRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



533
534
535
536
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 533

def update_payment_method(id, payment_method_request, opts = {})
  data, _status_code, _headers = update_payment_method_with_http_info(id, payment_method_request, opts)
  data
end

#update_payment_method_with_http_info(id, payment_method_request, opts = {}) ⇒ Array<(PaymentMethodResponse, Integer, Hash)>

Update Payment Method Update the mutable fields of a payment method (&#x60;billing_details&#x60;, &#x60;exp_month&#x60;, &#x60;exp_year&#x60;). The &#x60;default&#x60; flag is not mutable via PUT — use the &#x60;set_default&#x60; action instead.

Parameters:

  • id (String)
  • payment_method_request (PaymentMethodRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(PaymentMethodResponse, Integer, Hash)>)

    PaymentMethodResponse data, response status code and response headers



544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/api/billing_api.rb', line 544

def update_payment_method_with_http_info(id, payment_method_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BillingApi.update_payment_method ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling BillingApi.update_payment_method"
  end
  # verify the required parameter 'payment_method_request' is set
  if @api_client.config.client_side_validation && payment_method_request.nil?
    fail ArgumentError, "Missing the required parameter 'payment_method_request' when calling BillingApi.update_payment_method"
  end
  # resource path
  local_var_path = '/api/v1/payment_methods/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(payment_method_request)

  # return_type
  return_type = opts[:debug_return_type] || 'PaymentMethodResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"BillingApi.update_payment_method",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BillingApi#update_payment_method\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end