Skip to content

Commit

Permalink
misc(analytics): Rename outstanding invoices to invoice collection (#161
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ivannovosad authored Nov 28, 2023
1 parent e1a8e7f commit ae6aa9e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/lago-ruby-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
require 'lago/api/resources/gross_revenue'
require 'lago/api/resources/group'
require 'lago/api/resources/invoice'
require 'lago/api/resources/invoice_collection'
require 'lago/api/resources/invoiced_usage'
require 'lago/api/resources/mrr'
require 'lago/api/resources/organization'
require 'lago/api/resources/outstanding_invoice'
require 'lago/api/resources/plan'
require 'lago/api/resources/subscription'
require 'lago/api/resources/tax'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
module Lago
module Api
module Resources
class OutstandingInvoice < Base
class InvoiceCollection < Base
def api_resource
'analytics/outstanding_invoices'
'analytics/invoice_collection'
end

def root_name
'outstanding_invoice'
'invoice_collection'
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"outstanding_invoices": [
"invoice_collections": [
{
"month": "2023-11-01T00:00:00.000Z",
"payment_status": "pending",
Expand Down
24 changes: 12 additions & 12 deletions spec/lago/api/resources/outstanding_invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

RSpec.describe Lago::Api::Resources::OutstandingInvoice do
RSpec.describe Lago::Api::Resources::InvoiceCollection do
subject(:resource) { described_class.new(client) }

let(:client) { Lago::Api::Client.new }
Expand All @@ -16,39 +16,39 @@
end

describe '#get_all' do
let(:outstanding_invoices_response) { load_fixture('outstanding_invoice_index') }
let(:invoice_collections_response) { load_fixture('invoice_collection_index') }

context 'when there is no options' do
before do
stub_request(:get, 'https://api.getlago.com/api/v1/analytics/outstanding_invoices')
.to_return(body: outstanding_invoices_response, status: 200)
stub_request(:get, 'https://api.getlago.com/api/v1/analytics/invoice_collection')
.to_return(body: invoice_collections_response, status: 200)
end

it 'returns gross revenue' do
response = resource.get_all

expect(response['outstanding_invoices'].first['currency']).to eq('EUR')
expect(response['outstanding_invoices'].first['amount_cents']).to eq(100)
expect(response['invoice_collections'].first['currency']).to eq('EUR')
expect(response['invoice_collections'].first['amount_cents']).to eq(100)
end
end

context 'when options are present' do
before do
stub_request(:get, 'https://api.getlago.com/api/v1/analytics/outstanding_invoices?currency=EUR')
.to_return(body: outstanding_invoices_response, status: 200)
stub_request(:get, 'https://api.getlago.com/api/v1/analytics/invoice_collection?currency=EUR')
.to_return(body: invoice_collections_response, status: 200)
end

it 'returns gross revenue' do
it 'returns invoice collection' do
response = resource.get_all({ currency: 'EUR' })

expect(response['outstanding_invoices'].first['currency']).to eq('EUR')
expect(response['outstanding_invoices'].first['amount_cents']).to eq(100)
expect(response['invoice_collections'].first['currency']).to eq('EUR')
expect(response['invoice_collections'].first['amount_cents']).to eq(100)
end
end

context 'when there is an issue' do
before do
stub_request(:get, 'https://api.getlago.com/api/v1/analytics/outstanding_invoices')
stub_request(:get, 'https://api.getlago.com/api/v1/analytics/invoice_collection')
.to_return(body: error_response, status: 422)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
require 'lago/api/resources/gross_revenue'
require 'lago/api/resources/group'
require 'lago/api/resources/invoice'
require 'lago/api/resources/invoice_collection'
require 'lago/api/resources/invoiced_usage'
require 'lago/api/resources/mrr'
require 'lago/api/resources/organization'
require 'lago/api/resources/outstanding_invoice'
require 'lago/api/resources/plan'
require 'lago/api/resources/subscription'
require 'lago/api/resources/tax'
Expand Down

0 comments on commit ae6aa9e

Please sign in to comment.