Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(customers): add support for shippig address #199

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/lago/api/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def whitelist_params(params)
result_hash[:billing_configuration] = config unless config.empty?
end

whitelist_shipping_address(params[:shipping_address]).tap do |address|
result_hash[:shipping_address] = address unless address.empty?
end

integration_customers = whitelist_integration_customers(params[:integration_customers])
result_hash[:integration_customers] = integration_customers unless integration_customers.empty?

Expand All @@ -100,6 +104,17 @@ def whitelist_billing_configuration(billing_params)
)
end

def whitelist_shipping_address(address)
(address || {}).slice(
:address_line1,
:address_line2,
:city,
:zipcode,
:state,
:country,
)
end

def whitelist_integration_customers(integration_customers)
processed_integration_customers = []

Expand Down
9 changes: 9 additions & 0 deletions spec/factories/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
document_locale: 'fr',
}
end
shipping_address do
{
address_line1: '5230 Penfield Ave',
city: 'Woodland Hills',
zipcode: '91364',
state: 'CA',
country: 'US',
}
end
integration_customers do
[
{
Expand Down
7 changes: 7 additions & 0 deletions spec/fixtures/api/customer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
"document_locale": "fr",
"provider_payment_methods": ["card"]
},
"shipping_address": {
"address_line1": "5230 Penfield Ave",
"city": "Woodland Hills",
"zipcode": "91364",
"state": "CA",
"country": "US"
},
"integration_customers": [
{
"lago_id": "123asd123lkj987lkj",
Expand Down
2 changes: 2 additions & 0 deletions spec/lago/api/resources/customer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
expect(customer.billing_configuration.invoice_grace_period).to eq(3)
expect(customer.billing_configuration.provider_customer_id).to eq('cus_12345')
expect(customer.billing_configuration.provider_payment_methods).to eq(['card'])
expect(customer.shipping_address.city).to eq('Woodland Hills')
expect(customer.shipping_address.country).to eq('US')
expect(customer.integration_customers.first.external_customer_id).to eq('123456789')
expect(customer.integration_customers.first.type).to eq('netsuite')
expect(customer.metadata.first.key).to eq('key')
Expand Down
Loading