lago

package module
v0.3.3-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2022 License: AGPL-3.0 Imports: 6 Imported by: 3

README

Lago Go Client

Installation

go get github.com/getlago/lago-go-client@v0.1.0-alpha.1

Usage

import "github.com/getlago/lago-go-client"

func main() {
  lagoClient := lago.New().
    SetApiKey("MY_API_KEY").
    // SetDebug will log the RAW request and RAW response
    SetDebug(true)

  // If you want to use your API url for self hosted version
  lagoClient := lago.New().
    SetBaseURL("https://my.url").
    SetApiKey("MY_API_KEY")
}

Development

  • Fork the repository
  • Open a Pull Request

Documentation

The Lago documentation is available at doc.getlago.com.

Contributing

The contribution documentation is available here

License

Lago GO client is distributed under AGPL-3.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddOn

type AddOn struct {
	LagoID      uuid.UUID `json:"lago_id,omitempty"`
	Name        string    `json:"name,omitempty"`
	Code        string    `json:"code,omitempty"`
	Description string    `json:"description,omitempty"`

	AmountCents    int      `json:"amount_cents,omitempty"`
	AmountCurrency Currency `json:"amount_currency,omitempty"`

	CreatedAt time.Time `json:"created_at,omitempty"`
}

type AddOnInput

type AddOnInput struct {
	Name        string `json:"name,omitempty"`
	Code        string `json:"code,omitempty"`
	Description string `json:"description,omitempty"`

	AmountCents    int      `json:"amount_cents,omitempty"`
	AmountCurrency Currency `json:"amount_currency,omitempty"`
}

type AddOnListInput

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

type AddOnParams

type AddOnParams struct {
	AddOn *AddOnInput `json:"add_on"`
}

type AddOnRequest

type AddOnRequest struct {
	// contains filtered or unexported fields
}

func (*AddOnRequest) ApplyToCustomer

func (adr *AddOnRequest) ApplyToCustomer(ctx context.Context, applyAddOnInput *ApplyAddOnInput) (*AppliedAddOn, *Error)

func (*AddOnRequest) Create

func (adr *AddOnRequest) Create(ctx context.Context, addOnInput *AddOnInput) (*AddOn, *Error)

func (*AddOnRequest) Delete

func (adr *AddOnRequest) Delete(ctx context.Context, addOnCode string) (*AddOn, *Error)

func (*AddOnRequest) Get

func (adr *AddOnRequest) Get(ctx context.Context, addOnCode string) (*AddOn, *Error)

func (*AddOnRequest) GetList

func (adr *AddOnRequest) GetList(ctx context.Context, addOnListInput *AddOnListInput) (*AddOnResult, *Error)

func (*AddOnRequest) Update

func (adr *AddOnRequest) Update(ctx context.Context, addOnInput *AddOnInput) (*AddOn, *Error)

type AddOnResult

type AddOnResult struct {
	AddOn  *AddOn   `json:"add_on,omitempty"`
	AddOns []AddOn  `json:"add_ons,omitempty"`
	Meta   Metadata `json:"meta,omitempty"`
}

type AggregationType

type AggregationType string
const (
	CountAggregation          AggregationType = "count_agg"
	SumAggregation            AggregationType = "sum_agg"
	MaxAggregation            AggregationType = "max_agg"
	UniqueCountAggregation    AggregationType = "unique_count_agg"
	RecurringCountAggregation AggregationType = "recurring_count_agg"
)

type AppliedAddOn

type AppliedAddOn struct {
	LagoID             uuid.UUID `json:"lago_id,omitempty"`
	LagoAddOnID        uuid.UUID `json:"lago_add_on_id,omitempty"`
	LagoCustomerID     uuid.UUID `json:"lago_customer_id,omitempty"`
	ExternalCustomerID string    `json:"external_customer_id,omitempty"`

	AddOnCode      string   `json:"add_on_code,omitempty"`
	AmountCents    int      `json:"amount_cents,omitempty"`
	AmountCurrency Currency `json:"amount_currency,omitempty"`

	CreatedAt time.Time `json:"created_at,omitempty"`
}

type AppliedAddOnResult

type AppliedAddOnResult struct {
	AppliedAddOn *AppliedAddOn `json:"applied_add_on,omitempty"`
}

type AppliedCoupon

type AppliedCoupon struct {
	LagoID             uuid.UUID `json:"lago_id,omitempty"`
	LagoCouponID       uuid.UUID `json:"lago_coupon_id,omitempty"`
	ExternalCustomerID string    `json:"external_customer_id,omitempty"`
	LagoCustomerID     uuid.UUID `json:"lago_customer_id,omitempty"`

	CouponCode     string   `json:"coupon_code,omitempty"`
	AmountCents    int      `json:"amount_cents,omitempty"`
	AmountCurrency Currency `json:"amount_currency,omitempty"`

	ExpirationDate string    `json:"expiration_date,omitempty"`
	TerminatedAt   time.Time `json:"terminated_at,omitempty"`
}

type AppliedCouponResult

type AppliedCouponResult struct {
	AppliedCoupon *AppliedCoupon `json:"applied_coupon,omitempty"`
}

type ApplyAddOnInput

type ApplyAddOnInput struct {
	ExternalCustomerID string   `json:"external_customer_id,omitempty"`
	AddOnCode          string   `json:"add_on_code,omitempty"`
	AmountCents        int      `json:"amount_cents,omitempty"`
	AmountCurrency     Currency `json:"amount_currency,omitempty"`
}

type ApplyAddOnParams

type ApplyAddOnParams struct {
	AppliedAddOn *ApplyAddOnInput `json:"applied_add_on"`
}

type ApplyCouponInput

type ApplyCouponInput struct {
	ExternalCustomerID string   `json:"external_customer_id,omitempty"`
	CouponCode         string   `json:"coupon_code,omitempty"`
	AmountCents        int      `json:"amount_cents,omitempty"`
	AmountCurrency     Currency `json:"amount_currency,omitempty"`
}

type ApplyCouponParams

type ApplyCouponParams struct {
	AppliedCoupon *ApplyCouponInput `json:"applied_coupon"`
}

type BillableMetric

type BillableMetric struct {
	LagoID uuid.UUID `json:"lago_id"`
}

type BillableMetricInput

type BillableMetricInput struct {
	Name            string          `json:"name,omitempty"`
	Code            string          `json:"code,omitempty"`
	Description     string          `json:"description,omitempty"`
	AggregationType AggregationType `json:"aggregation_type,omitempty"`
	FieldName       string          `json:"field_name"`
}

type BillableMetricListInput

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

type BillableMetricParams

type BillableMetricParams struct {
	BillableMetricInput *BillableMetricInput
}

type BillableMetricRequest

type BillableMetricRequest struct {
	// contains filtered or unexported fields
}

func (*BillableMetricRequest) Create

func (bmr *BillableMetricRequest) Create(ctx context.Context, billableMetricInput *BillableMetricInput) (*BillableMetric, *Error)

func (*BillableMetricRequest) Delete

func (bmr *BillableMetricRequest) Delete(ctx context.Context, billableMetricCode string) (*BillableMetric, *Error)

func (*BillableMetricRequest) Get

func (bmr *BillableMetricRequest) Get(ctx context.Context, billableMetricCode string) (*BillableMetric, *Error)

func (*BillableMetricRequest) GetList

func (bmr *BillableMetricRequest) GetList(ctx context.Context, billableMetricListInput *BillableMetricListInput) (*BillableMetricResult, *Error)

func (*BillableMetricRequest) Update

func (bmr *BillableMetricRequest) Update(ctx context.Context, billableMetricInput *BillableMetricInput) (*BillableMetric, *Error)

type BillableMetricResult

type BillableMetricResult struct {
	BillableMetric  *BillableMetric  `json:"billable_metric,omitempty"`
	BillableMetrics []BillableMetric `json:"billable_metrics,omitempty"`
	Meta            Metadata         `json:"meta,omitempty"`
}

type BillingTime

type BillingTime string
const (
	Anniversary BillingTime = "anniversary"
	Calendar    BillingTime = "calendar"
)

type Charge

type Charge struct {
	LagoID               uuid.UUID              `json:"lago_id,omitempty"`
	LagoBillableMetricID uuid.UUID              `json:"lago_billable_metric_id,omitempty"`
	ChargeModel          ChargeModel            `json:"charge_model,omitempty"`
	CreatedAt            time.Time              `json:"created_at,omitempty"`
	Properties           map[string]interface{} `json:"properties,omitempty"`
}

type ChargeModel

type ChargeModel string
const (
	StandardChargeModel   ChargeModel = "standard"
	GraduatedChargeModel  ChargeModel = "graduated"
	PackageChargeModel    ChargeModel = "package"
	PercentageChargeModel ChargeModel = "percentage"
)

type Client

type Client struct {
	Debug      bool
	HttpClient *resty.Client
}

func New

func New() *Client

func (*Client) AddOn

func (c *Client) AddOn() *AddOnRequest

func (*Client) BillableMetric

func (c *Client) BillableMetric() *BillableMetricRequest

func (*Client) Coupon

func (c *Client) Coupon() *CouponRequest

func (*Client) Customer

func (c *Client) Customer() *CustomerRequest

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, cr *ClientRequest) (interface{}, *Error)

func (*Client) Event

func (c *Client) Event() *EventRequest

func (*Client) Get

func (c *Client) Get(ctx context.Context, cr *ClientRequest) (interface{}, *Error)

func (*Client) Invoice

func (c *Client) Invoice() *InvoiceRequest

func (*Client) Organization

func (c *Client) Organization() *OrganizationRequest

func (*Client) Plan

func (c *Client) Plan() *PlanRequest

func (*Client) Post

func (c *Client) Post(ctx context.Context, cr *ClientRequest) (interface{}, *Error)

func (*Client) PostWithoutBody

func (c *Client) PostWithoutBody(ctx context.Context, cr *ClientRequest) (interface{}, *Error)

func (*Client) PostWithoutResult

func (c *Client) PostWithoutResult(ctx context.Context, cr *ClientRequest) *Error

func (*Client) Put

func (c *Client) Put(ctx context.Context, cr *ClientRequest) (interface{}, *Error)

func (*Client) SetApiKey

func (c *Client) SetApiKey(apiKey string) *Client

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(url string) *Client

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool) *Client

func (*Client) Subscription

func (c *Client) Subscription() *SubscriptionRequest

func (*Client) Wallet

func (c *Client) Wallet() *WalletRequest

func (*Client) WalletTransaction

func (c *Client) WalletTransaction() *WalletTransactionRequest

type ClientRequest

type ClientRequest struct {
	Path        string
	QueryParams map[string]string
	Result      interface{}
	Body        interface{}
}

type Coupon

type Coupon struct {
	LagoID             uuid.UUID        `json:"lago_id,omitempty"`
	Name               string           `json:"name,omitempty"`
	Code               string           `json:"code,omitempty"`
	AmountCents        int              `json:"amount_cents,omitempty"`
	AmountCurrency     Currency         `json:"amount_currency,omitempty"`
	Expiration         CouponExpiration `json:"expiration,omitempty"`
	ExpirationDuration int              `json:"expiration_duration,omitempty"`
	CreatedAt          time.Time        `json:"created_at,omitempty"`
}

type CouponExpiration

type CouponExpiration string
const (
	CouponExpirationTimeLimit    CouponExpiration = "time_limit"
	CouponExpirationNoExpiration CouponExpiration = "no_expiration"
)

type CouponInput

type CouponInput struct {
	Name               string           `json:"name,omitempty"`
	Code               string           `json:"code,omitempty"`
	AmountCents        int              `json:"amount_cents,omitempty"`
	AmountCurrency     Currency         `json:"amount_currency,omitempty"`
	Expiration         CouponExpiration `json:"expiration,omitempty"`
	ExpirationDuration int              `json:"expiration_duration,omitempty"`
}

type CouponListInput

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

type CouponParams

type CouponParams struct {
	Coupon *CouponInput `json:"coupon"`
}

type CouponRequest

type CouponRequest struct {
	// contains filtered or unexported fields
}

func (*CouponRequest) ApplyToCustomer

func (cr *CouponRequest) ApplyToCustomer(ctx context.Context, applyCouponInput *ApplyCouponInput) (*AppliedCoupon, *Error)

func (*CouponRequest) Create

func (cr *CouponRequest) Create(ctx context.Context, couponInput *CouponInput) (*Coupon, *Error)

func (*CouponRequest) Delete

func (cr *CouponRequest) Delete(ctx context.Context, couponCode string) (*Coupon, *Error)

func (*CouponRequest) Get

func (cr *CouponRequest) Get(ctx context.Context, couponCode string) (*Coupon, *Error)

func (*CouponRequest) GetList

func (cr *CouponRequest) GetList(ctx context.Context, couponListInput *CouponListInput) (*CouponResult, *Error)

func (*CouponRequest) Update

func (cr *CouponRequest) Update(ctx context.Context, couponInput *CouponInput) (*Coupon, *Error)

type CouponResult

type CouponResult struct {
	Coupon  *Coupon  `json:"coupon,omitempty"`
	Coupons []Coupon `json:"coupons,omitempty"`
	Meta    Metadata `json:"meta,omitempty"`
}

type Currency

type Currency string
const (
	EUR Currency = "EUR"
	USD Currency = "USD"
)

type Customer

type Customer struct {
	LagoID       uuid.UUID `json:"lago_id,omitempty"`
	SequentialID int       `json:"sequential_id,omitempty"`
	ExternalID   string    `json:"external_id,omitempty"`
	Slug         string    `json:"slug,omitempty"`

	Name                 string                       `json:"name,omitempty"`
	Email                string                       `json:"email,omitempty"`
	AddressLine1         string                       `json:"address_line1,omitempty"`
	AddressLine2         string                       `json:"address_line2,omitempty"`
	City                 string                       `json:"city,omitempty"`
	State                string                       `json:"state,omitempty"`
	Zipcode              string                       `json:"zipcode,omitempty"`
	Country              string                       `json:"country,omitempty"`
	LegalName            string                       `json:"legal_name,omitempty"`
	LegalNumber          string                       `json:"legal_number,omitempty"`
	LogoURL              string                       `json:"logo_url,omitempty"`
	Phone                string                       `json:"phone,omitempty"`
	URL                  string                       `json:"url,omitempty"`
	BillingConfiguration CustomerBillingConfiguration `json:"billing_configuration,omitempty"`
	VatRate              float32                      `json:"vat_rate,omitempty"`

	CreatedAt time.Time `json:"created_at,omitempty"`
}

type CustomerBillingConfiguration

type CustomerBillingConfiguration struct {
	PaymentProvider    CustomerPaymentProvider `json:"payment_provider,omitempty"`
	ProviderCustomerID string                  `json:"provider_customer_id,omitempty"`
}

type CustomerBillingConfigurationInput

type CustomerBillingConfigurationInput struct {
	PaymentProvider    CustomerPaymentProvider `json:"payment_provider,omitempty"`
	ProviderCustomerID string                  `json:"provider_customer_id,omitempty"`
	Sync               bool                    `json:"sync,omitempty"`
}

type CustomerChargeUsage

type CustomerChargeUsage struct {
	Units          string   `json:"units,omitempty"`
	AmountCents    int      `json:"amount_cents,omitempty"`
	AmountCurrency Currency `json:"amount_currency,omitempty"`

	Charge         *Charge         `json:"charge,omitempty"`
	BillableMetric *BillableMetric `json:"billable_metric,omitempty"`
}

type CustomerInput

type CustomerInput struct {
	ExternalID           string                            `json:"external_id,omitempty"`
	Name                 string                            `json:"name,omitempty"`
	Email                string                            `json:"email,omitempty"`
	AddressLine1         string                            `json:"address_line_1,omitempty"`
	AddressLine2         string                            `json:"address_line_2,omitempty"`
	City                 string                            `json:"city,omitempty"`
	Zipcode              string                            `json:"zipcode,omitempty"`
	State                string                            `json:"state,omitempty"`
	Country              string                            `json:"country,omitempty"`
	LegalName            string                            `json:"legal_name,omitempty"`
	LegalNumber          string                            `json:"legal_number,omitempty"`
	Phone                string                            `json:"phone,omitempty"`
	URL                  string                            `json:"url,omitempty"`
	BillingConfiguration CustomerBillingConfigurationInput `json:"billing_configuration,omitempty"`
	VatRate              float32                           `json:"vat_rate,omitempty"`
}

type CustomerListInput

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

type CustomerParams

type CustomerParams struct {
	Customer *CustomerInput `json:"customer"`
}

type CustomerPaymentProvider

type CustomerPaymentProvider string
const (
	PaymentProviderStripe CustomerPaymentProvider = "stripe"
)

type CustomerRequest

type CustomerRequest struct {
	// contains filtered or unexported fields
}

func (*CustomerRequest) Create

func (cr *CustomerRequest) Create(ctx context.Context, customerInput *CustomerInput) (*Customer, *Error)

func (*CustomerRequest) CurrentUsage

func (cr *CustomerRequest) CurrentUsage(ctx context.Context, externalCustomerID string) (*CustomerUsage, *Error)

func (*CustomerRequest) Get

func (cr *CustomerRequest) Get(ctx context.Context, externalCustomerID string) (*Customer, *Error)

func (*CustomerRequest) GetList

func (cr *CustomerRequest) GetList(ctx context.Context, customerListInput *CustomerListInput) (*CustomerResult, *Error)

func (*CustomerRequest) Update

func (cr *CustomerRequest) Update(ctx context.Context, customerInput *CustomerInput) (*Customer, *Error)

NOTE: Update endpoint does not exists, actually we use the create endpoint with the same externalID to update a customer

type CustomerResult

type CustomerResult struct {
	Customer  *Customer  `json:"customer"`
	Customers []Customer `json:"customers,omitempty"`
	Meta      Metadata   `json:"medata,omitempty"`
}

type CustomerUsage

type CustomerUsage struct {
	FromDate    string `json:"from_date,omitempty"`
	ToDate      string `json:"to_date,omitempty"`
	IssuingDate string `json:"issuing_date,omitempty"`

	AmountCents         int      `json:"amount_cents,omitempty"`
	AmountCurrency      Currency `json:"amount_currency,omitempty"`
	TotalAmountCents    int      `json:"total_amount_cents,omitempty"`
	TotalAmountCurrency Currency `json:"total_amount_currency,omitempty"`
	VatAmountCents      int      `json:"vat_amount_cents,omitempty"`
	VatAmountCurrency   Currency `json:"vat_amount_currency,omitempty"`

	ChargesUsage []CustomerChargeUsage `json:"charges_usage,omitempty"`
}

type CustomerUsageResult

type CustomerUsageResult struct {
	CustomerUsage *CustomerUsage `json:"customer_usage"`
}

type Error

type Error struct {
	Err error `json:"-"`

	HTTPStatusCode int    `json:"status"`
	Msg            string `json:"message"`

	ErrorDetail ErrorDetail `json:"error_details"`
}

type ErrorCode

type ErrorCode string
const (
	ErrorCodeAlreadyExist ErrorCode = "value_already_exist"
	ErrorCodeInvalidValue
	ErrorTypeAssert ErrorCode = "error_type_assert"
)

func (ErrorCode) Error

func (e ErrorCode) Error() string

type ErrorDetail added in v1.5.3

type ErrorDetail struct {
	ErrorCode []ErrorCode `json:"code,omitempty"`
}

type EventInput

type EventInput struct {
	TransactionID      string            `json:"transaction_id,omitempty"`
	ExternalCustomerID string            `json:"external_customer_id,omitempty"`
	Code               string            `json:"code,omitempty"`
	Timestamp          int64             `json:"timestamp,omitempty"`
	Properties         map[string]string `json:"properties,omitempty"`
}

type EventParams

type EventParams struct {
	Event *EventInput `json:"event"`
}

type EventRequest

type EventRequest struct {
	// contains filtered or unexported fields
}

func (*EventRequest) Create

func (er *EventRequest) Create(ctx context.Context, eventInput *EventInput) *Error

type Invoice

type Invoice struct {
	LagoID       uuid.UUID `json:"lago_id,omitempty"`
	SequentialID int       `json:"sequential_id,omitempty"`
	Number       string    `json:"number,omitempty"`

	Status InvoiceStatus `json:"status,omitempty"`

	AmountCents       int      `json:"amount_cents,omitempty"`
	AmountCurrency    Currency `json:"amount_currency,omitempty"`
	VatAmountCents    int      `json:"vat_amount_cents,omitempty"`
	VatAmountCurrency Currency `json:"vat_amount_currency,omitempty"`

	FileURL string `json:"file_url,omitempty"`

	FromDate        string `json:"from_date,omitempty"`
	ToDate          string `json:"to_date,omitempty"`
	ChargesFromDate string `json:"charges_from_date,omitempty"`
	IssuingDate     string `json:"issuing_date,omitempty"`

	Customer     *Customer      `json:"customer,omitempty"`
	Subscription []Subscription `json:"subscriptions,omitempty"`

	Fees    []InvoiceFee    `json:"fees,omitempty"`
	Credits []InvoiceCredit `json:"credits,omitempty"`
}

type InvoiceCredit

type InvoiceCredit struct {
	Item InvoiceCreditItem `json:"item,omitempty"`

	AmountCents    int      `json:"amount_cents,omitempty"`
	AmountCurrency Currency `json:"amount_currency,omitempty"`
}

type InvoiceCreditItem

type InvoiceCreditItem struct {
	Type InvoiceCreditItemType `json:"type,omitempty"`
	Code string                `json:"code,omitempty"`
	Name string                `json:"name,omitempty"`
}

type InvoiceCreditItemType

type InvoiceCreditItemType string
const (
	InvoiceCreditItemCredit InvoiceCreditItemType = "coupon"
)

type InvoiceFee

type InvoiceFee struct {
	Item InvoiceFeeItem `json:"item,omitempty"`

	AmountCents       int      `json:"amount_cents,omitempty"`
	AmountCurrency    Currency `json:"amount_currency,omitempty"`
	VatAmountCents    int      `json:"vat_amount_cents,omitempty"`
	VatAmountCurrency Currency `json:"vat_amount_currency,omitempty"`
}

type InvoiceFeeItem

type InvoiceFeeItem struct {
	Type InvoiceFeeItemType `json:"type,omitempty"`
	Code string             `json:"code,omitempty"`
	Name string             `json:"name,omitempty"`
}

type InvoiceFeeItemType

type InvoiceFeeItemType string
const (
	InvoiceFeeItemSubscription InvoiceFeeItemType = "subscription"
	InvoiceFeeItemCharge       InvoiceFeeItemType = "charge"
	InvoiceFeeItemAddOn        InvoiceFeeItemType = "add_on"
)

type InvoiceInput

type InvoiceInput struct {
	LagoID uuid.UUID     `json:"lago_id,omitempty"`
	Status InvoiceStatus `json:"status,omitempty"`
}

type InvoiceListInput

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

	IssuingDateFrom string `json:"issuing_date_from,omitempty"`
	IssuingDateTo   string `json:"issuing_date_to,omitempty"`
}

type InvoiceParams

type InvoiceParams struct {
	Invoice *InvoiceInput `json:"invoice"`
}

type InvoiceRequest

type InvoiceRequest struct {
	// contains filtered or unexported fields
}

func (*InvoiceRequest) Download

func (ir *InvoiceRequest) Download(ctx context.Context, invoiceID string) (*Invoice, *Error)

func (*InvoiceRequest) Get

func (ir *InvoiceRequest) Get(ctx context.Context, invoiceID string) (*Invoice, *Error)

func (*InvoiceRequest) GetList

func (ir *InvoiceRequest) GetList(ctx context.Context, invoiceListInput *InvoiceListInput) (*InvoiceResult, *Error)

func (*InvoiceRequest) Update

func (ir *InvoiceRequest) Update(ctx context.Context, invoiceInput *InvoiceInput) (*Invoice, *Error)

type InvoiceResult

type InvoiceResult struct {
	Invoice  *Invoice  `json:"invoice,omitempty"`
	Invoices []Invoice `json:"invoices,omitempty"`
	Meta     Metadata  `json:"meta,omitempty"`
}

type InvoiceStatus

type InvoiceStatus string
const (
	InvoiceStatusPending   InvoiceStatus = "pending"
	InvoiceStatusSucceeded InvoiceStatus = "succeeded"
	InvoiceStatusFailed    InvoiceStatus = "failed"
)

type Metadata

type Metadata struct {
	CurrentPage int `json:"current_page,omitempty"`
	NextPage    int `json:"next_page,omitempty"`
	PrevPage    int `json:"prev_page,omitempty"`
	TotalPages  int `json:"total_pages,omitempty"`
	TotalCount  int `json:"total_count,omitempty"`
}

type Organization

type Organization struct {
	Name string `json:"name,omitempty"`

	Email        string `json:"email,omitempty"`
	AddressLine1 string `json:"address_line_1,omitempty"`
	AddressLine2 string `json:"address_line_2,omitempty"`
	City         string `json:"city,omitempty"`
	Zipcode      string `json:"zipcode,omitempty"`
	State        string `json:"state,omitempty"`
	Country      string `json:"country,omitempty"`
	LegalName    string `json:"legal_name,omitempty"`
	LegalNumber  string `json:"legal_number,omitempty"`

	CreatedAt time.Time `json:"created_at,omitempty"`
}

type OrganizationInput

type OrganizationInput struct {
	Name string `json:"name,omitempty"`

	Email        string `json:"email,omitempty"`
	AddressLine1 string `json:"address_line_1,omitempty"`
	AddressLine2 string `json:"address_line_2,omitempty"`
	City         string `json:"city,omitempty"`
	Zipcode      string `json:"zipcode,omitempty"`
	State        string `json:"state,omitempty"`
	Country      string `json:"country,omitempty"`
	LegalName    string `json:"legal_name,omitempty"`
	LegalNumber  string `json:"legal_number,omitempty"`

	InvoiceFooter string  `json:"invoice_footer,omitempty"`
	WebhookURL    string  `json:"webhook_url,omitempty"`
	VatRate       float32 `json:"vat_rate,omitempty"`
}

type OrganizationParams

type OrganizationParams struct {
	Organization *OrganizationInput `json:"organization"`
}

type OrganizationRequest

type OrganizationRequest struct {
	// contains filtered or unexported fields
}

func (*OrganizationRequest) Update

func (or *OrganizationRequest) Update(ctx context.Context, organizationInput *OrganizationInput) (*Organization, *Error)

type OrganizationResult

type OrganizationResult struct {
	Organization *Organization `json:"organization,omitempty"`
}

type Plan

type Plan struct {
	LagoID            uuid.UUID    `json:"lago_id"`
	Name              string       `json:"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"`
	Charges           []Charge     `json:"charges,omitempty"`
}

type PlanChargeInput

type PlanChargeInput struct {
	LagoID           *uuid.UUID             `json:"id,omitempty"`
	BillableMetricID uuid.UUID              `json:"billable_metric_id,omitempty"`
	AmountCurrency   Currency               `json:"amount_currency,omitempty"`
	ChargeModel      ChargeModel            `json:"charge_model,omitempty"`
	Properties       map[string]interface{} `json:"properties"`
}

type PlanInput

type PlanInput struct {
	Name              string            `json:"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"`
	Charges           []PlanChargeInput `json:"charges,omitempty"`
}

type PlanInterval

type PlanInterval string
const (
	PlanWeekly  PlanInterval = "weekly"
	PlanMonthly PlanInterval = "monthly"
	PlanYearly  PlanInterval = "yearly"
)

type PlanListInput

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

type PlanParams

type PlanParams struct {
	Plan *PlanInput `json:"plan"`
}

type PlanRequest

type PlanRequest struct {
	// contains filtered or unexported fields
}

func (*PlanRequest) Create

func (pr *PlanRequest) Create(ctx context.Context, planInput *PlanInput) (*Plan, *Error)

func (*PlanRequest) Delete

func (pr *PlanRequest) Delete(ctx context.Context, planCode string) (*Plan, *Error)

func (*PlanRequest) Get

func (pr *PlanRequest) Get(ctx context.Context, planCode string) (*Plan, *Error)

func (*PlanRequest) GetList

func (pr *PlanRequest) GetList(ctx context.Context, planListInput *PlanListInput) (*PlanResult, *Error)

func (*PlanRequest) Update

func (pr *PlanRequest) Update(ctx context.Context, planInput *PlanInput) (*Plan, *Error)

type PlanResult

type PlanResult struct {
	Plan  *Plan    `json:"plan,omitempty"`
	Plans []Plan   `json:"plans,omitempty"`
	Meta  Metadata `json:"meta,omitempty"`
}

type Status

type Status string
const (
	Active     Status = "active"
	Terminated Status = "terminated"
)

type Subscription

type Subscription struct {
	LagoID             uuid.UUID `json:"lago_id"`
	LagoCustomerID     uuid.UUID `json:"lago_customer_id"`
	ExternalCustomerID string    `json:"external_customer_id"`

	PlanCode string `json:"plan_code"`

	Status           SubscriptionStatus `json:"status"`
	BillingTime      BillingTime        `json:"billing_time"`
	SubscriptionDate string             `json:"subscription_date"`

	PreviousPlanCode  string `json:"previous_plan_code"`
	NextPlanCode      string `json:"next_plan_code"`
	DowngradePlanDate string `json:"downgrade_plan_date"`

	CreatedAt    *time.Time `json:"created_at"`
	StartedAt    *time.Time `json:"started_at"`
	CanceledAt   *time.Time `json:"canceled_at"`
	TerminatedAt *time.Time `json:"terminated_at"`
}

type SubscriptionInput

type SubscriptionInput struct {
	ExternalCustomerID string      `json:"external_customer_id,omitempty"`
	PlanCode           string      `json:"plan_code,omitempty"`
	BillingTime        BillingTime `json:"billing_time,omitempty"`
}

type SubscriptionListInput

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

type SubscriptionParams

type SubscriptionParams struct {
	Subscription *SubscriptionInput `json:"subscription"`
}

type SubscriptionRequest

type SubscriptionRequest struct {
	// contains filtered or unexported fields
}

func (*SubscriptionRequest) Create

func (sr *SubscriptionRequest) Create(ctx context.Context, subscriptionInput *SubscriptionInput) (*Subscription, *Error)

func (*SubscriptionRequest) GetList

func (sr *SubscriptionRequest) GetList(ctx context.Context, subscriptionListInput SubscriptionListInput) (*SubscriptionResult, *Error)

func (*SubscriptionRequest) Terminate

func (sr *SubscriptionRequest) Terminate(ctx context.Context, externalCustomerID string) (*Subscription, *Error)

type SubscriptionResult

type SubscriptionResult struct {
	Subscription  *Subscription  `json:"subscription,omitempty"`
	Subscriptions []Subscription `json:"subscriptions,omitempty"`
	Meta          Metadata       `json:"meta,omitempty"`
}

type SubscriptionStatus

type SubscriptionStatus string
const (
	SubscriptionStatusActive     SubscriptionStatus = "active"
	SubscriptionStatusPending    SubscriptionStatus = "pending"
	SubscriptionStatusTerminated SubscriptionStatus = "terminated"
	SubscriptionStatusCanceled   SubscriptionStatus = "canceled"
)

type TransactionType

type TransactionType string
const (
	Outbound TransactionType = "outbound"
	Inbound  TransactionType = "inbound"
)

type Wallet

type Wallet struct {
	LagoID               uuid.UUID `json:"lago_id,omitempty"`
	LagoCustomerID       uuid.UUID `json:"lago_customer_id,omitempty"`
	ExternalCustomerID   string    `json:"external_customer_id,omitempty"`
	Status               Status    `json:"status,omitempty"`
	Currency             string    `json:"currency,omitempty"`
	Name                 string    `json:"name,omitempty"`
	RateAmount           string    `json:"rate_amount,omitempty"`
	CreditsBalance       string    `json:"credits_balance,omitempty"`
	Balance              string    `json:"balance,omitempty"`
	ConsumedCredits      string    `json:"consumed_credits,omitempty"`
	CreatedAt            time.Time `json:"created_at,omitempty"`
	ExpirationDate       time.Time `json:"expiration_date,omitempty"`
	LastBalanceSyncAt    time.Time `json:"last_balance_sync_at,omitempty"`
	LastConsumedCreditAt time.Time `json:"last_consumed_credit_at,omitempty"`
	TerminatedAt         time.Time `json:"terminated_at,omitempty"`
}

type WalletInput

type WalletInput struct {
	RateAmount         string `json:"rate_amount,omitempty"`
	Name               string `json:"name,omitempty"`
	PaidCredits        string `json:"paid_credits,omitempty"`
	GrantedCredits     string `json:"granted_credits,omitempty"`
	ExpirationDate     string `json:"expiration_date,omitempty"`
	ExternalCustomerId string `json:"external_customer_id,omitempty"`
}

type WalletListInput

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

type WalletParams

type WalletParams struct {
	WalletInput *WalletInput
}

type WalletRequest

type WalletRequest struct {
	// contains filtered or unexported fields
}

func (*WalletRequest) Create

func (bmr *WalletRequest) Create(ctx context.Context, walletInput *WalletInput) (*Wallet, *Error)

func (*WalletRequest) Delete

func (bmr *WalletRequest) Delete(ctx context.Context, walletId string) (*Wallet, *Error)

func (*WalletRequest) Get

func (bmr *WalletRequest) Get(ctx context.Context, walletId string) (*Wallet, *Error)

func (*WalletRequest) GetList

func (bmr *WalletRequest) GetList(ctx context.Context, walletListInput *WalletListInput) (*WalletResult, *Error)

func (*WalletRequest) Update

func (bmr *WalletRequest) Update(ctx context.Context, walletInput *WalletInput, walletId string) (*Wallet, *Error)

type WalletResult

type WalletResult struct {
	Wallet  *Wallet  `json:"wallet,omitempty"`
	Wallets []Wallet `json:"wallets,omitempty"`
	Meta    Metadata `json:"meta,omitempty"`
}

type WalletStatus

type WalletStatus string
const (
	WalletStatusPending WalletStatus = "pending"
	WalletStatusSettled WalletStatus = "settled"
)

type WalletTransaction

type WalletTransaction struct {
	LagoID          uuid.UUID       `json:"lago_id,omitempty"`
	LagoWalletID    uuid.UUID       `json:"lago_wallet_id,omitempty"`
	Status          WalletStatus    `json:"status,omitempty"`
	TransactionType TransactionType `json:"transaction_type,omitempty"`
	Amount          string          `json:"amount,omitempty"`
	CreditAmount    string          ` json:"credit_amount,omitempty"`
	CreatedAt       time.Time       `json:"created_at,omitempty"`
	SettledAt       time.Time       `json:"settled_at,omitempty"`
}

type WalletTransactionInput

type WalletTransactionInput struct {
	WalletId       string `json:"wallet_id,omitempty"`
	PaidCredits    string `json:"paid_credits,omitempty"`
	GrantedCredits string `json:"granted_credits,omitempty"`
}

type WalletTransactionParams

type WalletTransactionParams struct {
	WalletTransactionInput *WalletTransactionInput
}

type WalletTransactionRequest

type WalletTransactionRequest struct {
	// contains filtered or unexported fields
}

func (*WalletTransactionRequest) Create

func (bmr *WalletTransactionRequest) Create(ctx context.Context, walletTransactionInput *WalletTransactionInput) (*WalletTransaction, *Error)

type WalletTransactionResult

type WalletTransactionResult struct {
	WalletTransactions []WalletTransaction `json:"wallet_transactions,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL