Skip to content

Commit

Permalink
Merge pull request #208 from getlago/feat-anrok-update-client
Browse files Browse the repository at this point in the history
Feat(anrok): update ruby-client with retry endpoint on invoice
  • Loading branch information
annvelents authored Sep 10, 2024
2 parents df4a580 + 8f8ffbe commit c759217
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/lago/api/resources/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def retry_payment(invoice_id)
JSON.parse(response.to_json, object_class: OpenStruct)
end

def retry(invoice_id)
path = "/api/v1/invoices/#{invoice_id}/retry"
response = connection.post({}, path)

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

def payment_url(invoice_id)
path = "/api/v1/invoices/#{invoice_id}/payment_url"
response = connection.post({}, path)['invoice_payment_details']
Expand Down
14 changes: 14 additions & 0 deletions spec/lago/api/resources/invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,20 @@
end
end

describe '#retry' do
before do
stub_request(:post, "https://api.getlago.com/api/v1/invoices/#{invoice_id}/retry")
.with(body: {}).to_return(body: invoice_response, status: 200)
end

it 'returns invoice' do
result = resource.retry(invoice_id)

expect(result.lago_id).to eq(invoice_id)
expect(result.status).to eq('finalized')
end
end

describe '#payment_url' do
let(:url_response) do
{
Expand Down

0 comments on commit c759217

Please sign in to comment.