Skip to content

Commit

Permalink
misc(analytics): Rename outstanding invoices to invoice collection (#148
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ivannovosad authored Nov 28, 2023
1 parent 789297a commit 516a645
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions outstanding_invoice.go → invoice_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ import (

type PaymentStatus string

type OutstandingInvoiceRequest struct {
type InvoiceCollectionRequest struct {
client *Client
}

type OutstandingInvoiceListInput struct {
type InvoiceCollectionListInput struct {
AmountCurrency string `json:"currency,omitempty,string"`
Months int `json:"months,omitempty,string"`
}

type OutstandingInvoiceResult struct {
OutstandingInvoice *OutstandingInvoice `json:"outstanding_invoice,omitempty"`
OutstandingInvoices []OutstandingInvoice `json:"outstanding_invoices,omitempty"`
type InvoiceCollectionResult struct {
InvoiceCollection *InvoiceCollection `json:"invoice_collection,omitempty"`
InvoiceCollections []InvoiceCollection `json:"invoice_collections,omitempty"`
}

type OutstandingInvoice struct {
type InvoiceCollection struct {
Month string `json:"month,omitempty"`
PaymentStatus InvoicePaymentStatus `json:"payment_status,omitempty"`
InvoicesCount int `json:"invoices_count,omitempty"`
AmountCents int `json:"amount_cents,omitempty"`
AmountCurrency Currency `json:"currency,omitempty"`
}

func (c *Client) OutstandingInvoice() *OutstandingInvoiceRequest {
return &OutstandingInvoiceRequest{
func (c *Client) InvoiceCollection() *InvoiceCollectionRequest {
return &InvoiceCollectionRequest{
client: c,
}
}

func (adr *OutstandingInvoiceRequest) GetList(ctx context.Context, OutstandingInvoiceListInput *OutstandingInvoiceListInput) (*OutstandingInvoiceResult, *Error) {
jsonQueryparams, err := json.Marshal(OutstandingInvoiceListInput)
func (adr *InvoiceCollectionRequest) GetList(ctx context.Context, InvoiceCollectionListInput *InvoiceCollectionListInput) (*InvoiceCollectionResult, *Error) {
jsonQueryparams, err := json.Marshal(InvoiceCollectionListInput)
if err != nil {
return nil, &Error{Err: err}
}
Expand All @@ -47,20 +47,20 @@ func (adr *OutstandingInvoiceRequest) GetList(ctx context.Context, OutstandingIn
}

clientRequest := &ClientRequest{
Path: "analytics/outstanding_invoices",
Path: "analytics/invoice_collection",
QueryParams: queryParams,
Result: &OutstandingInvoiceResult{},
Result: &InvoiceCollectionResult{},
}

result, clientErr := adr.client.Get(ctx, clientRequest)
if clientErr != nil {
return nil, clientErr
}

OutstandingInvoiceResult, ok := result.(*OutstandingInvoiceResult)
InvoiceCollectionResult, ok := result.(*InvoiceCollectionResult)
if !ok {
return nil, &ErrorTypeAssert
}

return OutstandingInvoiceResult, nil
return InvoiceCollectionResult, nil
}

0 comments on commit 516a645

Please sign in to comment.