Class: Lago::Api::Resources::Customer

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

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#create, #delete, #destroy, #get, #get_all, #initialize, #update

Constructor Details

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

Instance Method Details

#api_resourceObject



7
8
9
# File 'lib/lago/api/resources/customer.rb', line 7

def api_resource
  'customers'
end

#current_usage(customer_id) ⇒ Object



15
16
17
18
# File 'lib/lago/api/resources/customer.rb', line 15

def current_usage(customer_id)
  uri = URI("#{client.base_api_url}#{api_resource}/#{customer_id}/current_usage")
  connection.get(uri, identifier: nil)
end

#root_nameObject



11
12
13
# File 'lib/lago/api/resources/customer.rb', line 11

def root_name
  'customer'
end

#whitelist_billing_configuration(billing_params) ⇒ Object



46
47
48
# File 'lib/lago/api/resources/customer.rb', line 46

def whitelist_billing_configuration(billing_params)
  (billing_params || {}).slice(:payment_provider, :provider_customer_id, :sync)
end

#whitelist_params(params) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lago/api/resources/customer.rb', line 20

def whitelist_params(params)
  result_hash = {
    customer_id: params[:customer_id],
    address_line1: params[:address_line1],
    address_line2: params[:address_line2],
    city: params[:city],
    country: params[:country],
    email: params[:email],
    legal_name: params[:legal_name],
    legal_number: params[:legal_number],
    logo_url: params[:logo_url],
    name: params[:name],
    phone: params[:phone],
    state: params[:state],
    url: params[:url],
    vat_rate: params[:vat_rate],
    zipcode: params[:zipcode]
  }

  whitelist_billing_configuration(params[:billing_configuration]).tap do |config|
    result_hash[:billing_configuration] = config unless config.empty?
  end

  { root_name => result_hash }
end