Skip to content

Commit

Permalink
feat(minimum-commitment): Add minimum commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
ivannovosad committed Mar 13, 2024
1 parent 76bbe87 commit dc570b0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 34 deletions.
71 changes: 46 additions & 25 deletions plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/google/uuid"
)
Expand Down Expand Up @@ -46,40 +47,60 @@ type PlanChargeInput struct {
TaxCodes []string `json:"tax_codes,omitempty"`
}

type MinimumCommitmentInput struct {
AmountCents int `json:"amount_cents,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type PlanInput struct {
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance"`
BillChargeMonthly bool `json:"bill_charge_monthly"`
TrialPeriod float32 `json:"trial_period"`
Charges []PlanChargeInput `json:"charges,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance"`
BillChargeMonthly bool `json:"bill_charge_monthly"`
TrialPeriod float32 `json:"trial_period"`
Charges []PlanChargeInput `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitmentInput `json:"minimum_commitment,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type PlanListInput struct {
PerPage int `json:"per_page,omitempty,string"`
Page int `json:"page,omitempty,string"`
}

type MinimumCommitment struct {
LagoID uuid.UUID `json:"lago_id"`
PlanCode string `json:"plan_code,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
AmountCents int `json:"amount_cents"`
Interval PlanInterval `json:"interval,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`

Taxes []Tax `json:"tax,omitempty"`
}

type Plan struct {
LagoID uuid.UUID `json:"lago_id"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents,omitempty"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance,omitempty"`
BillChargeMonthly bool `json:"bill_charge_monthly,omitempty"`
ActiveSubscriptionsCount int `json:"active_subscriptions_count,omitempty"`
DraftInvoicesCount int `json:"draft_invoices_count,omitempty"`
Charges []Charge `json:"charges,omitempty"`
LagoID uuid.UUID `json:"lago_id"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents,omitempty"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance,omitempty"`
BillChargeMonthly bool `json:"bill_charge_monthly,omitempty"`
ActiveSubscriptionsCount int `json:"active_subscriptions_count,omitempty"`
DraftInvoicesCount int `json:"draft_invoices_count,omitempty"`
Charges []Charge `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitment `json:"minimum_commitment"`

Taxes []Tax `json:"taxes,omitempty"`
}
Expand Down
25 changes: 16 additions & 9 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,23 @@ type ChargeOverridesInput struct {
TaxCodes []string `json:"tax_codes,omitempty"`
}

type MinimumCommitmentOverridesInput struct {
AmountCents int `json:"amount_cents,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type PlanOverridesInput struct {
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
TrialPeriod float32 `json:"trial_period"`
Charges []ChargeOverridesInput `json:"charges,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
TrialPeriod float32 `json:"trial_period"`
Charges []ChargeOverridesInput `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitmentOverridesInput `json:"minimum_commitment"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type SubscriptionInput struct {
Expand Down

0 comments on commit dc570b0

Please sign in to comment.