Skip to content

Commit cb94098

Browse files
authored
feat (customers): add support for shippig address (#199)
1 parent 23150a9 commit cb94098

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

lib/lago/api/resources/customer.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def whitelist_params(params)
7878
result_hash[:billing_configuration] = config unless config.empty?
7979
end
8080

81+
whitelist_shipping_address(params[:shipping_address]).tap do |address|
82+
result_hash[:shipping_address] = address unless address.empty?
83+
end
84+
8185
integration_customers = whitelist_integration_customers(params[:integration_customers])
8286
result_hash[:integration_customers] = integration_customers unless integration_customers.empty?
8387

@@ -100,6 +104,17 @@ def whitelist_billing_configuration(billing_params)
100104
)
101105
end
102106

107+
def whitelist_shipping_address(address)
108+
(address || {}).slice(
109+
:address_line1,
110+
:address_line2,
111+
:city,
112+
:zipcode,
113+
:state,
114+
:country,
115+
)
116+
end
117+
103118
def whitelist_integration_customers(integration_customers)
104119
processed_integration_customers = []
105120

spec/factories/customer.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
document_locale: 'fr',
2929
}
3030
end
31+
shipping_address do
32+
{
33+
address_line1: '5230 Penfield Ave',
34+
city: 'Woodland Hills',
35+
zipcode: '91364',
36+
state: 'CA',
37+
country: 'US',
38+
}
39+
end
3140
integration_customers do
3241
[
3342
{

spec/fixtures/api/customer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
"document_locale": "fr",
3131
"provider_payment_methods": ["card"]
3232
},
33+
"shipping_address": {
34+
"address_line1": "5230 Penfield Ave",
35+
"city": "Woodland Hills",
36+
"zipcode": "91364",
37+
"state": "CA",
38+
"country": "US"
39+
},
3340
"integration_customers": [
3441
{
3542
"lago_id": "123asd123lkj987lkj",

spec/lago/api/resources/customer_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
expect(customer.billing_configuration.invoice_grace_period).to eq(3)
4040
expect(customer.billing_configuration.provider_customer_id).to eq('cus_12345')
4141
expect(customer.billing_configuration.provider_payment_methods).to eq(['card'])
42+
expect(customer.shipping_address.city).to eq('Woodland Hills')
43+
expect(customer.shipping_address.country).to eq('US')
4244
expect(customer.integration_customers.first.external_customer_id).to eq('123456789')
4345
expect(customer.integration_customers.first.type).to eq('netsuite')
4446
expect(customer.metadata.first.key).to eq('key')

0 commit comments

Comments
 (0)