Skip to content

Commit

Permalink
Update checkout_url method on customer resource
Browse files Browse the repository at this point in the history
  • Loading branch information
retsef authored and rsempe committed Jan 7, 2025
1 parent 9055727 commit 8195d35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/lago/api/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def checkout_url(external_customer_id)
"#{client.base_api_url}#{api_resource}/#{external_customer_id}/checkout_url",
)

response = connection.post(uri)[root_name]
response = connection.post({}, uri)[root_name]

JSON.parse(response.to_json, object_class: OpenStruct)
end
Expand Down
12 changes: 2 additions & 10 deletions spec/lago/api/resources/customer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,7 @@

context 'when the customer exists' do
before do
# NOTE: Api makes POST to /customers endpoint first
# stub_request(:post, "https://api.getlago.com/api/v1/customers/#{customer_external_id}/checkout_url")
# .to_return(body: response_body, status: 200)

stub_request(:post, 'https://api.getlago.com/api/v1/customers')
stub_request(:post, "https://api.getlago.com/api/v1/customers/#{customer_external_id}/checkout_url")
.to_return(body: response_body, status: 200)
end

Expand All @@ -275,11 +271,7 @@
let(:customer_external_id) { 'DOESNOTEXIST' }

before do
# NOTE: Api makes POST to /customers endpoint first
# stub_request(:post, "https://api.getlago.com/api/v1/customers/#{customer_external_id}/checkout_url")
# .to_return(body: JSON.generate(status: 404, error: 'Not Found'), status: 404)

stub_request(:post, 'https://api.getlago.com/api/v1/customers')
stub_request(:post, "https://api.getlago.com/api/v1/customers/#{customer_external_id}/checkout_url")
.to_return(body: JSON.generate(status: 404, error: 'Not Found'), status: 404)
end

Expand Down

0 comments on commit 8195d35

Please sign in to comment.