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(ProgressiveBilling): Expose Usage Threshold fields #200

Merged
merged 2 commits into from
Sep 2, 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
30 changes: 17 additions & 13 deletions invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const (
)

const (
InvoiceCreditItemCredit InvoiceCreditItemType = "coupon"
InvoiceCreditItemCoupon InvoiceCreditItemType = "coupon"
InvoiceCreditItemCreditNote InvoiceCreditItemType = "credit_note"
InvoiceCreditItemInvoice InvoiceCreditItemType = "invoice"
)

type InvoiceRequest struct {
Expand Down Expand Up @@ -158,15 +160,16 @@ type Invoice struct {

Currency Currency `json:"currency,omitempty"`

FeesAmountCents int `json:"fees_amount_cents,omitempty"`
TaxesAmountCents int `json:"taxes_amount_cents,omitempty"`
CouponsAmountCents int `json:"coupons_amount_cents,omitempty"`
CreditNotesAmountCents int `json:"credit_notes_amount_cents,omitempty"`
SubTotalExcludingTaxesAmountCents int `json:"sub_total_excluding_taxes_amount_cents,omitempty"`
SubTotalIncludingTaxesAmountCents int `json:"sub_total_including_taxes_amount_cents,omitempty"`
TotalAmountCents int `json:"total_amount_cents,omitempty"`
PrepaidCreditAmountCents int `json:"prepaid_credit_amount_cents,omitempty"`
NetPaymentTerm int `json:"net_payment_term,omitempty"`
FeesAmountCents int `json:"fees_amount_cents,omitempty"`
TaxesAmountCents int `json:"taxes_amount_cents,omitempty"`
CouponsAmountCents int `json:"coupons_amount_cents,omitempty"`
CreditNotesAmountCents int `json:"credit_notes_amount_cents,omitempty"`
SubTotalExcludingTaxesAmountCents int `json:"sub_total_excluding_taxes_amount_cents,omitempty"`
SubTotalIncludingTaxesAmountCents int `json:"sub_total_including_taxes_amount_cents,omitempty"`
TotalAmountCents int `json:"total_amount_cents,omitempty"`
PrepaidCreditAmountCents int `json:"prepaid_credit_amount_cents,omitempty"`
ProgressiveBillingCreditAmountCents int `json:"progressive_billing_credit_amount_cents"`
NetPaymentTerm int `json:"net_payment_term,omitempty"`

FileURL string `json:"file_url,omitempty"`
Metadata []InvoiceMetadataResponse `json:"metadata,omitempty"`
Expand All @@ -175,9 +178,10 @@ type Invoice struct {
Customer *Customer `json:"customer,omitempty"`
Subscriptions []Subscription `json:"subscriptions,omitempty"`

Fees []Fee `json:"fees,omitempty"`
Credits []InvoiceCredit `json:"credits,omitempty"`
AppliedTaxes []InvoiceAppliedTax `json:"applied_taxes,omitempty"`
Fees []Fee `json:"fees,omitempty"`
Credits []InvoiceCredit `json:"credits,omitempty"`
AppliedTaxes []InvoiceAppliedTax `json:"applied_taxes,omitempty"`
AppliedUsageThreshold []AppliedUsageThreshold `json:"applied_usage_threshold,omitempty"`
}

type InvoicePaymentUrl struct {
Expand Down
4 changes: 3 additions & 1 deletion plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type PlanInput struct {
Charges []PlanChargeInput `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitmentInput `json:"minimum_commitment,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
UsageThresholds []UsageThresholdInput `json:"usage_thresholds,omitempty"`
}

type PlanListInput struct {
Expand Down Expand Up @@ -103,7 +104,8 @@ type Plan struct {
Charges []Charge `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitment `json:"minimum_commitment"`

Taxes []Tax `json:"taxes,omitempty"`
Taxes []Tax `json:"taxes,omitempty"`
UsageThresholds []UsageThreshold `json:"usage_thresholds,omitempty"`
}

func (c *Client) Plan() *PlanRequest {
Expand Down
1 change: 1 addition & 0 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type PlanOverridesInput struct {
Charges []ChargeOverridesInput `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitmentOverridesInput `json:"minimum_commitment"`
TaxCodes []string `json:"tax_codes,omitempty"`
UsageThresholds []UsageThreshold `json:"usage_thresholds,omitempty"`
}

type SubscriptionInput struct {
Expand Down
29 changes: 29 additions & 0 deletions usage_threshold.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package lago

import (
"time"

"github.com/google/uuid"
)

type UsageThresholdInput struct {
LagoId *uuid.UUID `json:"id,omitempty"`
ThresholdDisplayName string `json:"threshold_display_name,omitempty"`
AmountCents int `json:"amount_cents"`
Recurring bool `json:"recurring"`
}

type UsageThreshold struct {
LagoID uuid.UUID `json:"lago_id"`
ThresholdDisplayName string `json:"threshold_display_name,omitempty"`
AmountCents int `json:"amount_cents"`
Recurring bool `json:"recurring"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

type AppliedUsageThreshold struct {
LifetimeUsageAmountCents int `json:"lifetime_usage_amount_cents"`
CreatedAt time.Time `json:"created_at"`
UsageThreshold UsageThreshold `json:"usage_threshold"`
}
Loading