Class: Lago::Api::Resources::Customers::PaymentMethod

Inherits:
Base
  • Object
show all
Defined in:
lib/lago/api/resources/customers/payment_method.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#base_api_resource, #create, #get, #initialize, #update

Methods inherited from Base

#create, #get, #get_all, #initialize, #update, #whitelist_params

Constructor Details

This class inherits a constructor from Lago::Api::Resources::Customers::Base

Instance Method Details

#api_resourceObject



10
11
12
# File 'lib/lago/api/resources/customers/payment_method.rb', line 10

def api_resource
  "#{base_api_resource}/payment_methods"
end

#destroy(id, options: nil) ⇒ Object



18
19
20
21
22
# File 'lib/lago/api/resources/customers/payment_method.rb', line 18

def destroy(id, options: nil)
  response = connection.destroy(identifier: id, options:)[root_name]

  JSON.parse(response.to_json, object_class: OpenStruct)
end

#root_nameObject



14
15
16
# File 'lib/lago/api/resources/customers/payment_method.rb', line 14

def root_name
  'payment_method'
end

#set_as_default(payment_method_id) ⇒ Object

rubocop:disable Naming/AccessorMethodName



25
26
27
28
29
30
# File 'lib/lago/api/resources/customers/payment_method.rb', line 25

def set_as_default(payment_method_id)
  path = "/api/v1/#{api_resource}/#{payment_method_id}/set_as_default"
  response = connection.put(path, identifier: nil, body: {})[root_name]

  JSON.parse(response.to_json, object_class: OpenStruct)
end