Documentation
¶
Index ¶
- type AddMemberRequest
- type AdminAddCustomerMemberRequest
- type AdminCustomer
- type AdminGetCustomerResponse
- type AdminListCustomerMembersResponse
- type AdminListCustomersOptions
- type AdminListTiersOptions
- type Client
- func (c *Client) AddMember(ctx context.Context, req AddMemberRequest) error
- func (c *Client) AdminAddMember(ctx context.Context, customerID string, req AdminAddCustomerMemberRequest) error
- func (c *Client) AdminBillingStatus(ctx context.Context) (*GetBillingStatusResponse, error)
- func (c *Client) AdminDeleteCustomer(ctx context.Context, customerID string) error
- func (c *Client) AdminGetCustomer(ctx context.Context, customerID string) (*AdminGetCustomerResponse, error)
- func (c *Client) AdminListCustomerMembers(ctx context.Context, customerID string, opts *ListOpts) (*AdminListCustomerMembersResponse, error)
- func (c *Client) AdminListCustomers(ctx context.Context, opts *AdminListCustomersOptions) (*ListCustomersResponse, error)
- func (c *Client) AdminListTiers(ctx context.Context, opts *AdminListTiersOptions) (*GetAllTiersResponse, error)
- func (c *Client) AdminRemoveMember(ctx context.Context, customerID, userID string) error
- func (c *Client) AdminSetDefaultTier(ctx context.Context, tierID string) error
- func (c *Client) CreateCustomer(ctx context.Context, req CreateCustomerRequest) error
- func (c *Client) DeleteCustomer(ctx context.Context) error
- func (c *Client) GetAllIPLimits(ctx context.Context) (*GetAllIPLimitsResponse, error)
- func (c *Client) GetAllLimits(ctx context.Context) (*GetAllLimitsResponse, error)
- func (c *Client) GetAllQuotas(ctx context.Context) (*GetAllQuotasResponse, error)
- func (c *Client) GetCustomer(ctx context.Context) (*GetCustomerResponse, error)
- func (c *Client) GetCustomerTier(ctx context.Context) (*GetCustomerTierResponse, error)
- func (c *Client) GetIPUsage(ctx context.Context) (*GetIPUsageResponse, error)
- func (c *Client) GetQuotaUsage(ctx context.Context) (*GetQuotaUsageResponse, error)
- func (c *Client) GetServiceIPLimits(ctx context.Context, serviceName string) (*GetServiceIPLimitsResponse, error)
- func (c *Client) GetServiceLimits(ctx context.Context, serviceName string) (*GetServiceLimitsResponse, error)
- func (c *Client) GetServiceQuotas(ctx context.Context, serviceName string) (*GetServiceQuotasResponse, error)
- func (c *Client) GetSpecificLimit(ctx context.Context, serviceName, featureKey string) (*GetSpecificLimitResponse, error)
- func (c *Client) GetSpecificQuota(ctx context.Context, serviceName, featureKey string) (*GetSpecificQuotaResponse, error)
- func (c *Client) GetUsage(ctx context.Context) (*GetUserUsageResponse, error)
- func (c *Client) GetUserQuotaUsage(ctx context.Context, userID string) (*GranularUsageResponse, error)
- func (c *Client) GetUserUsage(ctx context.Context, userID string) (*GranularUsageResponse, error)
- func (c *Client) LeaveCustomer(ctx context.Context) error
- func (c *Client) ListMembers(ctx context.Context, opts *ListOpts) (*ListMembersResponse, error)
- func (c *Client) RemoveMember(ctx context.Context, userID string) error
- func (c *Client) StartPortal(ctx context.Context) (*StartPortalResponse, error)
- func (c *Client) TransferOwnership(ctx context.Context, req TransferOwnershipRequest) error
- func (c *Client) UpdateMember(ctx context.Context, req UpdateMemberRequest) error
- func (c *Client) UpgradeToPro(ctx context.Context, req UpgradeToProRequest) (*UpgradeToProResponse, error)
- type CreateCustomerRequest
- type GetAllIPLimitsResponse
- type GetAllLimitsResponse
- type GetAllQuotasResponse
- type GetAllTiersResponse
- type GetBillingStatusResponse
- type GetCustomerResponse
- type GetCustomerTierResponse
- type GetIPUsageResponse
- type GetQuotaUsageResponse
- type GetServiceIPLimitsResponse
- type GetServiceLimitsResponse
- type GetServiceQuotasResponse
- type GetSpecificLimitResponse
- type GetSpecificQuotaResponse
- type GetUserUsageResponse
- type GranularUsageResponse
- type LimitDetail
- type ListCustomersResponse
- type ListMembersResponse
- type ListOpts
- type Member
- type StartPortalResponse
- type Tier
- type TransferOwnershipRequest
- type UpdateMemberRequest
- type UpgradeToProRequest
- type UpgradeToProResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddMemberRequest ¶
AddMemberRequest is the body for adding a member to a customer.
type AdminAddCustomerMemberRequest ¶
type AdminAddCustomerMemberRequest struct {
UserID string `json:"userID"`
Role string `json:"role"`
}
AdminAddCustomerMemberRequest is the body for admin adding a member to a customer.
type AdminCustomer ¶
type AdminCustomer struct {
ID string `json:"id"`
GCID string `json:"gcid"`
Name string `json:"name"`
Email string `json:"email"`
TierName string `json:"tierName"`
SubscriptionStatus string `json:"subscriptionStatus"`
CreatedAt string `json:"createdAt"`
}
AdminCustomer is a customer in a paginated admin list.
type AdminGetCustomerResponse ¶
type AdminGetCustomerResponse struct {
ID string `json:"id"`
GCID string `json:"gcid"`
Name string `json:"name"`
Email string `json:"email"`
BillingAddress string `json:"billingAddress"`
TierName string `json:"tierName"`
SubscriptionStatus string `json:"subscriptionStatus"`
CreatedAt time.Time `json:"createdAt"`
}
AdminGetCustomerResponse is returned when fetching a customer as admin.
type AdminListCustomerMembersResponse ¶
type AdminListCustomerMembersResponse struct {
Pages int `json:"pages"`
Items int `json:"items"`
Members []Member `json:"members"`
}
AdminListCustomerMembersResponse is the paginated response for admin member listing.
type AdminListCustomersOptions ¶
type AdminListCustomersOptions struct {
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
TierName string `url:"tierName,omitempty"`
Status string `url:"status,omitempty"`
}
AdminListCustomersOptions provides filtering for the admin customer list endpoint.
type AdminListTiersOptions ¶
type AdminListTiersOptions struct {
Active *bool `url:"active,omitempty"`
}
AdminListTiersOptions provides filtering for the admin tier list endpoint.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides access to the Billing API endpoints.
func NewClient ¶
func NewClient(d doFunc) *Client
NewClient creates a new Billing client backed by the root SDK client's do function.
func (*Client) AddMember ¶
func (c *Client) AddMember(ctx context.Context, req AddMemberRequest) error
AddMember adds a member to the current customer.
func (*Client) AdminAddMember ¶
func (c *Client) AdminAddMember(ctx context.Context, customerID string, req AdminAddCustomerMemberRequest) error
AdminAddMember adds a member to a customer as admin.
func (*Client) AdminBillingStatus ¶
func (c *Client) AdminBillingStatus(ctx context.Context) (*GetBillingStatusResponse, error)
AdminBillingStatus returns the billing status for a customer as admin.
func (*Client) AdminDeleteCustomer ¶
AdminDeleteCustomer deletes a customer by ID as admin.
func (*Client) AdminGetCustomer ¶
func (c *Client) AdminGetCustomer(ctx context.Context, customerID string) (*AdminGetCustomerResponse, error)
AdminGetCustomer fetches a customer by ID as admin.
func (*Client) AdminListCustomerMembers ¶
func (c *Client) AdminListCustomerMembers(ctx context.Context, customerID string, opts *ListOpts) (*AdminListCustomerMembersResponse, error)
AdminListCustomerMembers lists members of a customer as admin.
func (*Client) AdminListCustomers ¶
func (c *Client) AdminListCustomers(ctx context.Context, opts *AdminListCustomersOptions) (*ListCustomersResponse, error)
AdminListCustomers lists customers with optional filtering.
func (*Client) AdminListTiers ¶
func (c *Client) AdminListTiers(ctx context.Context, opts *AdminListTiersOptions) (*GetAllTiersResponse, error)
AdminListTiers lists all billing tiers with optional filtering.
func (*Client) AdminRemoveMember ¶
AdminRemoveMember removes a member from a customer as admin.
func (*Client) AdminSetDefaultTier ¶
AdminSetDefaultTier sets a tier as the default tier.
func (*Client) CreateCustomer ¶
func (c *Client) CreateCustomer(ctx context.Context, req CreateCustomerRequest) error
CreateCustomer creates a new customer.
func (*Client) DeleteCustomer ¶
DeleteCustomer deletes the current customer.
func (*Client) GetAllIPLimits ¶
func (c *Client) GetAllIPLimits(ctx context.Context) (*GetAllIPLimitsResponse, error)
GetAllIPLimits returns all IP rate limits (no auth required).
func (*Client) GetAllLimits ¶
func (c *Client) GetAllLimits(ctx context.Context) (*GetAllLimitsResponse, error)
GetAllLimits returns all limits for the customer.
func (*Client) GetAllQuotas ¶
func (c *Client) GetAllQuotas(ctx context.Context) (*GetAllQuotasResponse, error)
GetAllQuotas returns all quotas for the customer.
func (*Client) GetCustomer ¶
func (c *Client) GetCustomer(ctx context.Context) (*GetCustomerResponse, error)
GetCustomer returns the current customer.
func (*Client) GetCustomerTier ¶
func (c *Client) GetCustomerTier(ctx context.Context) (*GetCustomerTierResponse, error)
GetCustomerTier returns the customer's current tier.
func (*Client) GetIPUsage ¶
func (c *Client) GetIPUsage(ctx context.Context) (*GetIPUsageResponse, error)
GetIPUsage returns IP usage data (no auth required).
func (*Client) GetQuotaUsage ¶
func (c *Client) GetQuotaUsage(ctx context.Context) (*GetQuotaUsageResponse, error)
GetQuotaUsage returns quota usage data for the current user.
func (*Client) GetServiceIPLimits ¶
func (c *Client) GetServiceIPLimits(ctx context.Context, serviceName string) (*GetServiceIPLimitsResponse, error)
GetServiceIPLimits returns IP rate limits for a specific service (no auth required).
func (*Client) GetServiceLimits ¶
func (c *Client) GetServiceLimits(ctx context.Context, serviceName string) (*GetServiceLimitsResponse, error)
GetServiceLimits returns limits for a specific service.
func (*Client) GetServiceQuotas ¶
func (c *Client) GetServiceQuotas(ctx context.Context, serviceName string) (*GetServiceQuotasResponse, error)
GetServiceQuotas returns quotas for a specific service.
func (*Client) GetSpecificLimit ¶
func (c *Client) GetSpecificLimit(ctx context.Context, serviceName, featureKey string) (*GetSpecificLimitResponse, error)
GetSpecificLimit returns a specific limit for a service and feature.
func (*Client) GetSpecificQuota ¶
func (c *Client) GetSpecificQuota(ctx context.Context, serviceName, featureKey string) (*GetSpecificQuotaResponse, error)
GetSpecificQuota returns a specific quota for a service and feature.
func (*Client) GetUsage ¶
func (c *Client) GetUsage(ctx context.Context) (*GetUserUsageResponse, error)
GetUsage returns usage data for the current user.
func (*Client) GetUserQuotaUsage ¶
func (c *Client) GetUserQuotaUsage(ctx context.Context, userID string) (*GranularUsageResponse, error)
GetUserQuotaUsage returns granular quota usage for a specific user.
func (*Client) GetUserUsage ¶
GetUserUsage returns granular usage data for a specific user.
func (*Client) LeaveCustomer ¶
LeaveCustomer removes the current user from the customer.
func (*Client) ListMembers ¶
ListMembers lists members of the current customer with optional pagination.
func (*Client) RemoveMember ¶
RemoveMember removes a member from the current customer by user ID.
func (*Client) StartPortal ¶
func (c *Client) StartPortal(ctx context.Context) (*StartPortalResponse, error)
StartPortal starts a Stripe billing portal session.
func (*Client) TransferOwnership ¶
func (c *Client) TransferOwnership(ctx context.Context, req TransferOwnershipRequest) error
TransferOwnership transfers customer ownership to another user.
func (*Client) UpdateMember ¶
func (c *Client) UpdateMember(ctx context.Context, req UpdateMemberRequest) error
UpdateMember updates a member's role in the current customer.
func (*Client) UpgradeToPro ¶
func (c *Client) UpgradeToPro(ctx context.Context, req UpgradeToProRequest) (*UpgradeToProResponse, error)
UpgradeToPro creates a Stripe checkout session for upgrading to Pro.
type CreateCustomerRequest ¶
type CreateCustomerRequest struct {
Name string `json:"name"`
Email string `json:"email"`
BillingAddress string `json:"billingAddress"`
}
CreateCustomerRequest is the body for creating a new customer.
type GetAllIPLimitsResponse ¶
GetAllIPLimitsResponse is returned when fetching all IP limits.
type GetAllLimitsResponse ¶
type GetAllLimitsResponse struct {
CustomerID string `json:"customerId"`
TierName string `json:"tierName"`
Limits map[string]any `json:"limits"`
}
GetAllLimitsResponse is returned when fetching all limits for the customer.
type GetAllQuotasResponse ¶
GetAllQuotasResponse is returned when fetching all quotas for the customer.
type GetAllTiersResponse ¶
type GetAllTiersResponse struct {
Tiers []Tier `json:"tiers"`
}
GetAllTiersResponse is returned when fetching all tiers.
type GetBillingStatusResponse ¶
type GetBillingStatusResponse struct {
CustomerID string `json:"customerId"`
TierName string `json:"tierName"`
SubscriptionStatus string `json:"subscriptionStatus"`
StripeCustomerID string `json:"stripeCustomerID"`
Stacks int `json:"stacks"`
}
GetBillingStatusResponse is returned when fetching billing status as admin.
type GetCustomerResponse ¶
GetCustomerResponse is returned when fetching the current customer.
type GetCustomerTierResponse ¶
type GetCustomerTierResponse struct {
TierID string `json:"tierId"`
TierName string `json:"tierName"`
SubscriptionStatus string `json:"subscriptionStatus"`
Stacks int `json:"stacks"`
}
GetCustomerTierResponse is returned when fetching the customer's tier.
type GetIPUsageResponse ¶
GetIPUsageResponse is returned when fetching IP usage.
type GetQuotaUsageResponse ¶
GetQuotaUsageResponse is returned when fetching quota usage.
type GetServiceIPLimitsResponse ¶
GetServiceIPLimitsResponse is returned when fetching IP limits for a specific service.
type GetServiceLimitsResponse ¶
GetServiceLimitsResponse is returned when fetching limits for a specific service.
type GetServiceQuotasResponse ¶
GetServiceQuotasResponse is returned when fetching quotas for a specific service.
type GetSpecificLimitResponse ¶
type GetSpecificLimitResponse struct {
Value any `json:"value"`
Window string `json:"window"`
Description string `json:"description"`
}
GetSpecificLimitResponse is returned when fetching a specific limit.
type GetSpecificQuotaResponse ¶
GetSpecificQuotaResponse is returned when fetching a specific quota.
type GetUserUsageResponse ¶
GetUserUsageResponse is returned when fetching usage for the current user.
type GranularUsageResponse ¶
GranularUsageResponse is returned when fetching granular usage for a user.
type LimitDetail ¶
type LimitDetail struct {
Value any `json:"value"`
Window string `json:"window"`
Description string `json:"description"`
}
LimitDetail contains the details of a single limit.
type ListCustomersResponse ¶
type ListCustomersResponse struct {
Pages int `json:"pages"`
Items int `json:"items"`
Customers []AdminCustomer `json:"customers"`
}
ListCustomersResponse is the paginated response for admin customer listing.
type ListMembersResponse ¶
type ListMembersResponse struct {
Pages int `json:"pages"`
Items int `json:"items"`
Members []Member `json:"members"`
}
ListMembersResponse is the paginated response for listing members.
type Member ¶
type Member struct {
UserID string `json:"userID"`
Role string `json:"role"`
Email string `json:"email"`
JoinedAt time.Time `json:"joinedAt"`
}
Member represents a member of a customer.
type StartPortalResponse ¶
type StartPortalResponse struct {
URL string `json:"url"`
}
StartPortalResponse is returned when starting a Stripe billing portal session.
type Tier ¶
type Tier struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Price int `json:"price"`
IsActive bool `json:"isActive"`
}
Tier represents a billing tier.
type TransferOwnershipRequest ¶
type TransferOwnershipRequest struct {
NewOwnerUserID string `json:"newOwnerUserID"`
}
TransferOwnershipRequest is the body for transferring customer ownership.
type UpdateMemberRequest ¶
UpdateMemberRequest is the body for updating a member's role.
type UpgradeToProRequest ¶
type UpgradeToProRequest struct {
SuccessURL string `json:"successURL"`
CancelURL string `json:"cancelURL"`
}
UpgradeToProRequest is the body for upgrading to Pro via Stripe.
type UpgradeToProResponse ¶
type UpgradeToProResponse struct {
CheckoutURL string `json:"checkoutURL"`
}
UpgradeToProResponse is returned when creating a Pro upgrade checkout.