Files
sdk/api_billing.go

7043 lines
255 KiB
Go

/*
Hanzo Cloud API
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
)
// BillingAPIService BillingAPI service
type BillingAPIService service
type BillingAPIAssignSeatsRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingAssignment *BillingAssignment
}
func (r BillingAPIAssignSeatsRequest) BillingAssignment(billingAssignment BillingAssignment) BillingAPIAssignSeatsRequest {
r.billingAssignment = &billingAssignment
return r
}
func (r BillingAPIAssignSeatsRequest) Execute() (*BillingSubscription, *http.Response, error) {
return r.ApiService.AssignSeatsExecute(r)
}
/*
AssignSeats Assign a team's seats
Assigns a team's seats: which member holds a standard seat and which a premium
one, replacing what was assigned.
A seat type is given no more members than the seats of it paid for — the fewer
of the period in hand's and the next one's — and a member holds one seat; past
either the request is 400 and nothing changes. Which member holds a seat moves
no money and bounds no usage: a team's usage is all of its seats' together.
The team's seats are its admins' to assign, and the platform's. A member is
refused with 403 and told to ask an admin. A subscription from another org, or
held by a wallet the caller may not change, is not found.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return BillingAPIAssignSeatsRequest
*/
func (a *BillingAPIService) AssignSeats(ctx context.Context, id string) BillingAPIAssignSeatsRequest {
return BillingAPIAssignSeatsRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingSubscription
func (a *BillingAPIService) AssignSeatsExecute(r BillingAPIAssignSeatsRequest) (*BillingSubscription, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingSubscription
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.AssignSeats")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/subscriptions/{id}/seats"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingAssignment == nil {
return localVarReturnValue, nil, reportError("billingAssignment is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingAssignment
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPICancelSubscriptionRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingSubscriptionAct *BillingSubscriptionAct
}
func (r BillingAPICancelSubscriptionRequest) BillingSubscriptionAct(billingSubscriptionAct BillingSubscriptionAct) BillingAPICancelSubscriptionRequest {
r.billingSubscriptionAct = &billingSubscriptionAct
return r
}
func (r BillingAPICancelSubscriptionRequest) Execute() (*BillingSubscription, *http.Response, error) {
return r.ApiService.CancelSubscriptionExecute(r)
}
/*
CancelSubscription End a subscription
Ends a subscription.
It cancels at the END OF THE PAID PERIOD by default, because a customer who
cancels has already paid for the period they are in and taking it away is
taking money for nothing. `atPeriodEnd: false` ends it at once, which is the
caller asking for that.
The org's plan is its admins' to end, and the platform's in support mode. A
member is refused with 403 and told to ask an admin; a member billed from a
wallet of their own may end that wallet's plan. Every one is on the audit
trail, the operator named when it is the platform acting inside the org.
A subscription from another org, or held by a wallet the caller may not
change, is not found rather than refused, so an id cannot be probed for
existence.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the subscription, from the path.
@return BillingAPICancelSubscriptionRequest
*/
func (a *BillingAPIService) CancelSubscription(ctx context.Context, id string) BillingAPICancelSubscriptionRequest {
return BillingAPICancelSubscriptionRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingSubscription
func (a *BillingAPIService) CancelSubscriptionExecute(r BillingAPICancelSubscriptionRequest) (*BillingSubscription, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingSubscription
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.CancelSubscription")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/subscriptions/{id}/cancel"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingSubscriptionAct == nil {
return localVarReturnValue, nil, reportError("billingSubscriptionAct is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingSubscriptionAct
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPICollectInvoiceRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingInvoiceRef *BillingInvoiceRef
}
func (r BillingAPICollectInvoiceRequest) BillingInvoiceRef(billingInvoiceRef BillingInvoiceRef) BillingAPICollectInvoiceRequest {
r.billingInvoiceRef = &billingInvoiceRef
return r
}
func (r BillingAPICollectInvoiceRequest) Execute() (*BillingCollected, *http.Response, error) {
return r.ApiService.CollectInvoiceExecute(r)
}
/*
CollectInvoice Collect an issued invoice from credits, balance, then card
Collects an issued invoice: credit grants first, then prepaid balance, then the
card on file — the same waterfall the dunning workflow runs. It spends the
named customer's money, so it is the org admin's act; a member is refused 403.
A DECLINE IS NOT AN ERROR. It answers with paid=false, a reason, and the
invoice still open, because a declined collection is a normal business outcome
that must remain retryable — and because sealing it as a failure would wedge
dunning behind a replayed decline. Only a successful collection is sealed, so a
retry of a paid invoice replays the receipt instead of charging again.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the invoice id.
@return BillingAPICollectInvoiceRequest
*/
func (a *BillingAPIService) CollectInvoice(ctx context.Context, id string) BillingAPICollectInvoiceRequest {
return BillingAPICollectInvoiceRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingCollected
func (a *BillingAPIService) CollectInvoiceExecute(r BillingAPICollectInvoiceRequest) (*BillingCollected, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCollected
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.CollectInvoice")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices/{id}/collect"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingInvoiceRef == nil {
return localVarReturnValue, nil, reportError("billingInvoiceRef is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingInvoiceRef
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIDeleteBillingAlertsByIdRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIDeleteBillingAlertsByIdRequest) Execute() (*http.Response, error) {
return r.ApiService.DeleteBillingAlertsByIdExecute(r)
}
/*
DeleteBillingAlertsById Removes one of the caller's spend caps and answers 204.
Removes one of the caller's spend caps and answers 204.
Removing a cap RAISES what the org may spend, so it takes the same authority
setting one does. The caps that remain still bind: this drops one, never the
whole policy.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the cap to remove, from the path.
@return BillingAPIDeleteBillingAlertsByIdRequest
*/
func (a *BillingAPIService) DeleteBillingAlertsById(ctx context.Context, id string) BillingAPIDeleteBillingAlertsByIdRequest {
return BillingAPIDeleteBillingAlertsByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
func (a *BillingAPIService) DeleteBillingAlertsByIdExecute(r BillingAPIDeleteBillingAlertsByIdRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.DeleteBillingAlertsById")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/alerts/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIDeleteBillingMethodsByIdRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIDeleteBillingMethodsByIdRequest) Execute() (*BillingDetachment, *http.Response, error) {
return r.ApiService.DeleteBillingMethodsByIdExecute(r)
}
/*
DeleteBillingMethodsById Removes one card or account the caller has saved.
Removes one card or account the caller has saved.
It detaches only the CALLER'S own — the wallet this request bills from,
resolved server-side — so an id belonging to another customer of the same org
is not something this operation can reach. The org's cards are removed only
by an admin of the org or the platform; a member is refused with 403 and told
to ask an admin. A platform or service caller
detaches on the subject's behalf, and that authority is decided HERE, where the
credential is, and travels as a value: authority decided twice is authority
that eventually disagrees with itself.
The card is vaulted at the processor, so what goes is our token for it.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the saved method to detach, from the path.
@return BillingAPIDeleteBillingMethodsByIdRequest
*/
func (a *BillingAPIService) DeleteBillingMethodsById(ctx context.Context, id string) BillingAPIDeleteBillingMethodsByIdRequest {
return BillingAPIDeleteBillingMethodsByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingDetachment
func (a *BillingAPIService) DeleteBillingMethodsByIdExecute(r BillingAPIDeleteBillingMethodsByIdRequest) (*BillingDetachment, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingDetachment
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.DeleteBillingMethodsById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/methods/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIDeleteBillingPortalMethodsByIdRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIDeleteBillingPortalMethodsByIdRequest) Execute() (*BillingDetachment, *http.Response, error) {
return r.ApiService.DeleteBillingPortalMethodsByIdExecute(r)
}
/*
DeleteBillingPortalMethodsById Removes one card or account the caller has saved, at the address a hosted checkout reaches it by.
Removes one card or account the caller has saved, at the
address a hosted checkout reaches it by. One set of rows, two spellings: a card
detached at either is gone from both, because there is one store behind them.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the saved method to detach, from the path.
@return BillingAPIDeleteBillingPortalMethodsByIdRequest
*/
func (a *BillingAPIService) DeleteBillingPortalMethodsById(ctx context.Context, id string) BillingAPIDeleteBillingPortalMethodsByIdRequest {
return BillingAPIDeleteBillingPortalMethodsByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingDetachment
func (a *BillingAPIService) DeleteBillingPortalMethodsByIdExecute(r BillingAPIDeleteBillingPortalMethodsByIdRequest) (*BillingDetachment, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingDetachment
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.DeleteBillingPortalMethodsById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/portal/methods/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingAccountsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingAccountsRequest) Execute() ([]BillingBillingAccount, *http.Response, error) {
return r.ApiService.GetBillingAccountsExecute(r)
}
/*
GetBillingAccounts Answers the caller's billing accounts: the org itself, its currency, when it was opened, and the caller's own standing in it.
Answers the caller's billing accounts: the org itself, its currency, when it
was opened, and the caller's own standing in it.
The standing is the caller's, resolved from the validated principal here and
sent to the store rather than looked up there — the membership roster is IAM's
and commerce keeps none, so a callee that answered "what role is this" would
be inventing it. An anonymous read gets the account with no role rather than
an implied membership.
Scoped to the caller's own org, which is the whole tenancy story: there is no
org field on the wire and none on the input.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingAccountsRequest
*/
func (a *BillingAPIService) GetBillingAccounts(ctx context.Context) BillingAPIGetBillingAccountsRequest {
return BillingAPIGetBillingAccountsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return []BillingBillingAccount
func (a *BillingAPIService) GetBillingAccountsExecute(r BillingAPIGetBillingAccountsRequest) ([]BillingBillingAccount, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue []BillingBillingAccount
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingAccounts")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/accounts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingAccountsByIdMembersRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIGetBillingAccountsByIdMembersRequest) Execute() ([]BillingHolder, *http.Response, error) {
return r.ApiService.GetBillingAccountsByIdMembersExecute(r)
}
/*
GetBillingAccountsByIdMembers Answers one billing account's roster.
Answers one billing account's roster.
commerce stores no roster — that is IAM's — so the only member it can name is
the caller, and that is what comes back. What it does enforce is that the
account named in the path is the caller's own: a foreign id is 403, not an
empty list, because "no members" and "not your account" are different answers.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the billing account id, which for this store is the org's own id.
@return BillingAPIGetBillingAccountsByIdMembersRequest
*/
func (a *BillingAPIService) GetBillingAccountsByIdMembers(ctx context.Context, id string) BillingAPIGetBillingAccountsByIdMembersRequest {
return BillingAPIGetBillingAccountsByIdMembersRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return []BillingHolder
func (a *BillingAPIService) GetBillingAccountsByIdMembersExecute(r BillingAPIGetBillingAccountsByIdMembersRequest) ([]BillingHolder, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue []BillingHolder
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingAccountsByIdMembers")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/accounts/{id}/members"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingAlertsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingAlertsRequest) Execute() ([]BillingAlert, *http.Response, error) {
return r.ApiService.GetBillingAlertsExecute(r)
}
/*
GetBillingAlerts Lists this org's spend caps: the ceiling, its scope, whether it enforces, and how much of it has been spent this period.
Lists this org's spend caps: the ceiling, its scope, whether it enforces, and
how much of it has been spent this period.
`periodSpentCents`, `over` and `warn` are ABSENT rather than zero when the
spend could not be read, because "nothing spent" and "spend unknown" are
different answers and a customer acting on the first when the second is true
would be reading a ceiling that is not there. The policy row is reported
either way.
The period is the UTC calendar month and `resetsAt` is when the count starts
again, so a surface can say "resets on" without a second call.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingAlertsRequest
*/
func (a *BillingAPIService) GetBillingAlerts(ctx context.Context) BillingAPIGetBillingAlertsRequest {
return BillingAPIGetBillingAlertsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return []BillingAlert
func (a *BillingAPIService) GetBillingAlertsExecute(r BillingAPIGetBillingAlertsRequest) ([]BillingAlert, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue []BillingAlert
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingAlerts")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/alerts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingAlertsAuthorizeRequest struct {
ctx context.Context
ApiService *BillingAPIService
project *string
service *string
amount *string
pv *string
}
// Project narrows the verdict to one project's caps. Empty is the org-wide row.
func (r BillingAPIGetBillingAlertsAuthorizeRequest) Project(project string) BillingAPIGetBillingAlertsAuthorizeRequest {
r.project = &project
return r
}
// Service narrows it to one service's caps. Empty is every service.
func (r BillingAPIGetBillingAlertsAuthorizeRequest) Service(service string) BillingAPIGetBillingAlertsAuthorizeRequest {
r.service = &service
return r
}
// Amount is the proposed spend in cents.
func (r BillingAPIGetBillingAlertsAuthorizeRequest) Amount(amount string) BillingAPIGetBillingAlertsAuthorizeRequest {
r.amount = &amount
return r
}
// PV is \"1\" when the caller ESTABLISHED the project rather than merely carrying a claim of one. An unproven project may not deny traffic.
func (r BillingAPIGetBillingAlertsAuthorizeRequest) Pv(pv string) BillingAPIGetBillingAlertsAuthorizeRequest {
r.pv = &pv
return r
}
func (r BillingAPIGetBillingAlertsAuthorizeRequest) Execute() (*BillingCapVerdict, *http.Response, error) {
return r.ApiService.GetBillingAlertsAuthorizeExecute(r)
}
/*
GetBillingAlertsAuthorize Answers whether one proposed spend fits inside this org's caps.
Answers whether one proposed spend fits inside this org's caps.
It is the per-request verdict the metering edge consumes before every priced
call, and its caller is a SERVICE rather than a person: the platform, stating
the org over the plane, with no user behind it. So this admits that principal
where the CRUD beside it does not.
Every covering row is evaluated, most-restrictive-wins, and the tightest one
is what `capCents`, `spentCents` and `reason` describe. Soft rows never deny;
nor does a project-scoped enforcing row whose project axis the caller could
not establish — `pv=1` is how a caller states that it did, and an unproven
claim must not be able to refuse traffic.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingAlertsAuthorizeRequest
*/
func (a *BillingAPIService) GetBillingAlertsAuthorize(ctx context.Context) BillingAPIGetBillingAlertsAuthorizeRequest {
return BillingAPIGetBillingAlertsAuthorizeRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingCapVerdict
func (a *BillingAPIService) GetBillingAlertsAuthorizeExecute(r BillingAPIGetBillingAlertsAuthorizeRequest) (*BillingCapVerdict, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCapVerdict
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingAlertsAuthorize")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/alerts/authorize"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.project != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "project", r.project, "form", "")
}
if r.service != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "service", r.service, "form", "")
}
if r.amount != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "amount", r.amount, "form", "")
}
if r.pv != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "pv", r.pv, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingBalanceRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingBalanceRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingBalanceExecute(r)
}
/*
GetBillingBalance Prepaid credit the caller's org can still spend
Answers the spendable prepaid balance of the wallet this caller bills from — the same wallet the AI prepaid gate reads before admitting a paid request, the edge meter debits, and a top-up credits.
The wallet is an ADDRESS, not an org: `account` echoes the key resolved within the ledger — the org's shared pool for a tenant org, a personal account for a member of the shared signup org. The echo is the point. A browser could only GUESS its own payer by decoding its own token, and a guess that disagrees with the server is how money lands in an account the gate never reads.
`balance`, `holds` and `available` are whole USD cents, ROUNDED from the ledger's exact 18-decimal value. On the co-resident ledger `holds` is 0 and `available` equals `balance`: the gate's reservations live in its own pod and are never posted, so the settled balance IS the spendable one.
`cash`, `line` and `credit` say where `available` came from, and add up to it. `cash` is money the customer paid — a settled card payment or a recorded wire. `credit` is money Hanzo minted: signup and promotional credit, admin grants. `line` is what is left of the org's postpaid credit line (`creditLimit`), and `due` what the account owes on it: usage the line paid for, invoiced, and paid down first by the next payment. A debit draws cash, then the line, then credit; granted credit never pays what is due. The three line fields are absent when the ledger did not report them.
The ledger is the caller's own org, taken from the VALIDATED IAM owner claim and never from a client header. No validated principal is 401. A balance that cannot be READ is 502, never 0: unknown is not broke.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingBalanceRequest
*/
func (a *BillingAPIService) GetBillingBalance(ctx context.Context) BillingAPIGetBillingBalanceRequest {
return BillingAPIGetBillingBalanceRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingBalanceExecute(r BillingAPIGetBillingBalanceRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingBalance")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/balance"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingCreditBalanceRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingCreditBalanceRequest) Execute() (*BillingCreditBalance, *http.Response, error) {
return r.ApiService.GetBillingCreditBalanceExecute(r)
}
/*
GetBillingCreditBalance Answers what the caller can spend right now, one entry per currency.
Answers what the caller can spend right now, one entry per currency.
Only ACTIVE grants count: a voided, exhausted or lapsed grant contributes
nothing, which is why this number can be smaller than the grant list suggests
and why the two reads exist separately. It is credit, not prepaid balance —
/v1/billing/balance is the wallet, and the two are added by the gate, never by
a reader.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingCreditBalanceRequest
*/
func (a *BillingAPIService) GetBillingCreditBalance(ctx context.Context) BillingAPIGetBillingCreditBalanceRequest {
return BillingAPIGetBillingCreditBalanceRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingCreditBalance
func (a *BillingAPIService) GetBillingCreditBalanceExecute(r BillingAPIGetBillingCreditBalanceRequest) (*BillingCreditBalance, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCreditBalance
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingCreditBalance")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/credit-balance"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingCreditBalanceBreakdownRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingCreditBalanceBreakdownRequest) Execute() (interface{}, *http.Response, error) {
return r.ApiService.GetBillingCreditBalanceBreakdownExecute(r)
}
/*
GetBillingCreditBalanceBreakdown Answers that same spendable credit split by grant tag, with the earliest expiry under each and the total across all of them.
Answers that same spendable credit split by grant tag, with the earliest
expiry under each and the total across all of them.
The split is the point: it is how trial credit is told apart from bought
credit, which is what a surface asks before it decides whether to spend any.
An unregistered address answers 404 and a caller reads that as "no credit", so
this being served is the difference between a customer with a trial grant
being offered their trial and being told they have none.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingCreditBalanceBreakdownRequest
*/
func (a *BillingAPIService) GetBillingCreditBalanceBreakdown(ctx context.Context) BillingAPIGetBillingCreditBalanceBreakdownRequest {
return BillingAPIGetBillingCreditBalanceBreakdownRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return interface{}
func (a *BillingAPIService) GetBillingCreditBalanceBreakdownExecute(r BillingAPIGetBillingCreditBalanceBreakdownRequest) (interface{}, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingCreditBalanceBreakdown")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/credit-balance/breakdown"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingCreditsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingCreditsRequest) Execute() (*BillingCreditGrants, *http.Response, error) {
return r.ApiService.GetBillingCreditsExecute(r)
}
/*
GetBillingCredits Lists the caller's credit grants — every one of them, spent and lapsed and voided included.
Lists the caller's credit grants — every one of them, spent and lapsed and
voided included.
That is deliberate and it is what makes the list useful: a grant list is a
LEDGER, and one that hid its spent rows could not be reconciled against a
burn-down. What is spendable right now is the sibling read, /v1/billing/
credit-balance, and the two are different questions.
Scoped to the caller's own wallet, resolved server-side.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingCreditsRequest
*/
func (a *BillingAPIService) GetBillingCredits(ctx context.Context) BillingAPIGetBillingCreditsRequest {
return BillingAPIGetBillingCreditsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingCreditGrants
func (a *BillingAPIService) GetBillingCreditsExecute(r BillingAPIGetBillingCreditsRequest) (*BillingCreditGrants, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCreditGrants
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingCredits")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/credits"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingCryptoDepositByIdRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIGetBillingCryptoDepositByIdRequest) Execute() (*BillingCryptoDeposit, *http.Response, error) {
return r.ApiService.GetBillingCryptoDepositByIdExecute(r)
}
/*
GetBillingCryptoDepositById Reads one of the caller's own deposit intents back — pending, confirming, or succeeded.
Reads one of the caller's own deposit intents back — pending, confirming, or
succeeded.
status is pending until a transfer to the address is seen, confirming while
the chain buries it (confirmations counts up to requiredConfirmations), and
succeeded once it is credited: creditedCents is then in the caller's balance
as cash (GET /v1/billing/balance, cash). The answer is the same shape the mint
returned, terms and instructions included, so polling it is all an agent needs.
An intent belonging to another payer answers 404, exactly as an id that names
nothing, so a guessed id cannot confirm that somebody else's deposit exists.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the deposit intent id.
@return BillingAPIGetBillingCryptoDepositByIdRequest
*/
func (a *BillingAPIService) GetBillingCryptoDepositById(ctx context.Context, id string) BillingAPIGetBillingCryptoDepositByIdRequest {
return BillingAPIGetBillingCryptoDepositByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingCryptoDeposit
func (a *BillingAPIService) GetBillingCryptoDepositByIdExecute(r BillingAPIGetBillingCryptoDepositByIdRequest) (*BillingCryptoDeposit, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCryptoDeposit
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingCryptoDepositById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/crypto/deposit/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingCryptoGatewayRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingCryptoGatewayRequest) Execute() (*BillingGatewayTerms, *http.Response, error) {
return r.ApiService.GetBillingCryptoGatewayExecute(r)
}
/*
GetBillingCryptoGateway Answers the terms to sign a USDC top-up against, for an agent or a person paying from a wallet: the treasury to pay, the networks and USDC contracts, the EIP-712 domain and types, the limits, and a nonce issued to the caller.
Answers the terms to sign a USDC top-up against, for an agent or a person
paying from a wallet: the treasury to pay, the networks and USDC contracts,
the EIP-712 domain and types, the limits, and a nonce issued to the caller.
Sign TransferWithAuthorization {from, to: payTo, value, validAfter,
validBefore, nonce} under one network's domain, then POST it here with the
salt. The nonce is the caller's own: a payment signed against it credits the
caller and cannot be presented by anyone else.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingCryptoGatewayRequest
*/
func (a *BillingAPIService) GetBillingCryptoGateway(ctx context.Context) BillingAPIGetBillingCryptoGatewayRequest {
return BillingAPIGetBillingCryptoGatewayRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingGatewayTerms
func (a *BillingAPIService) GetBillingCryptoGatewayExecute(r BillingAPIGetBillingCryptoGatewayRequest) (*BillingGatewayTerms, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingGatewayTerms
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingCryptoGateway")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/crypto/gateway"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingCryptoGatewayByIdRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIGetBillingCryptoGatewayByIdRequest) Execute() (*BillingGatewayPayment, *http.Response, error) {
return r.ApiService.GetBillingCryptoGatewayByIdExecute(r)
}
/*
GetBillingCryptoGatewayById Reads one of the caller's own USDC top-ups back: pending, accepted (credited or deferred), settled, failed or refused.
Reads one of the caller's own USDC top-ups back: pending, accepted (credited
or deferred), settled, failed or refused.
A payment belonging to another payer answers 404, exactly as an id that names
nothing, so a guessed id cannot confirm somebody else's payment exists.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the top-up's id, from the path.
@return BillingAPIGetBillingCryptoGatewayByIdRequest
*/
func (a *BillingAPIService) GetBillingCryptoGatewayById(ctx context.Context, id string) BillingAPIGetBillingCryptoGatewayByIdRequest {
return BillingAPIGetBillingCryptoGatewayByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingGatewayPayment
func (a *BillingAPIService) GetBillingCryptoGatewayByIdExecute(r BillingAPIGetBillingCryptoGatewayByIdRequest) (*BillingGatewayPayment, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingGatewayPayment
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingCryptoGatewayById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/crypto/gateway/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingCryptoOptionsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingCryptoOptionsRequest) Execute() (*BillingCryptoOptions, *http.Response, error) {
return r.ApiService.GetBillingCryptoOptionsExecute(r)
}
/*
GetBillingCryptoOptions Answers which chains and tokens the crypto rail accepts — what an asset picker renders — and the pairs themselves in assets: a chain and a token each on offer are not a pair on offer.
Answers which chains and tokens the crypto rail accepts — what an asset picker
renders — and the pairs themselves in assets: a chain and a token each on offer
are not a pair on offer.
It is the intersection of two live facts rather than a configured list: an
asset appears only if something is WATCHING it and the custody processor
supports it. An address nobody watches credits nobody, so offering one would
take a customer's money and lose it. A rail with nothing armed answers 503,
not an empty menu — "no rail" and "no assets" are different, and only one of
them means try again later.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingCryptoOptionsRequest
*/
func (a *BillingAPIService) GetBillingCryptoOptions(ctx context.Context) BillingAPIGetBillingCryptoOptionsRequest {
return BillingAPIGetBillingCryptoOptionsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingCryptoOptions
func (a *BillingAPIService) GetBillingCryptoOptionsExecute(r BillingAPIGetBillingCryptoOptionsRequest) (*BillingCryptoOptions, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCryptoOptions
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingCryptoOptions")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/crypto/options"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingInvoicesRequest struct {
ctx context.Context
ApiService *BillingAPIService
subject *string
status *string
subscriptionId *string
limit *int64
cursor *string
}
func (r BillingAPIGetBillingInvoicesRequest) Subject(subject string) BillingAPIGetBillingInvoicesRequest {
r.subject = &subject
return r
}
func (r BillingAPIGetBillingInvoicesRequest) Status(status string) BillingAPIGetBillingInvoicesRequest {
r.status = &status
return r
}
func (r BillingAPIGetBillingInvoicesRequest) SubscriptionId(subscriptionId string) BillingAPIGetBillingInvoicesRequest {
r.subscriptionId = &subscriptionId
return r
}
func (r BillingAPIGetBillingInvoicesRequest) Limit(limit int64) BillingAPIGetBillingInvoicesRequest {
r.limit = &limit
return r
}
func (r BillingAPIGetBillingInvoicesRequest) Cursor(cursor string) BillingAPIGetBillingInvoicesRequest {
r.cursor = &cursor
return r
}
func (r BillingAPIGetBillingInvoicesRequest) Execute() (*BillingInvoices, *http.Response, error) {
return r.ApiService.GetBillingInvoicesExecute(r)
}
/*
GetBillingInvoices Lists the caller's invoices, newest first, with the count beside them.
Lists the caller's invoices, newest first, with the count beside them.
It is scoped to the caller's own billing subject — the wallet this request
bills from, resolved server-side — so a query cannot widen it to another
customer of the same org. An org with no invoices is an empty list, not a
refusal.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingInvoicesRequest
*/
func (a *BillingAPIService) GetBillingInvoices(ctx context.Context) BillingAPIGetBillingInvoicesRequest {
return BillingAPIGetBillingInvoicesRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingInvoices
func (a *BillingAPIService) GetBillingInvoicesExecute(r BillingAPIGetBillingInvoicesRequest) (*BillingInvoices, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingInvoices
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingInvoices")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.subject != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "subject", r.subject, "form", "")
}
if r.status != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "")
}
if r.subscriptionId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "subscriptionId", r.subscriptionId, "form", "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
if r.cursor != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingInvoicesByIdPdfRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIGetBillingInvoicesByIdPdfRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingInvoicesByIdPdfExecute(r)
}
/*
GetBillingInvoicesByIdPdf Download one invoice as a PDF
Answers the invoice as an attachment — `application/pdf` under a Content-Disposition naming the invoice number — rather than as a JSON value, which is why this one route is untyped where its five siblings are typed: a PDF is bytes with a filename, and the two headers are the whole contract.
The render is a PURE function of the invoice: one page, no timestamps and no random ids, so the same invoice renders the same bytes however often it is asked for and a retry after a dropped connection costs a re-render and nothing else.
The invoice is read from the caller's own org, taken from the VALIDATED IAM owner claim and never from a client header, and the lookup is scoped at the storage layer — so an id belonging to another customer resolves to nothing and answers 404 rather than being found and then refused.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return BillingAPIGetBillingInvoicesByIdPdfRequest
*/
func (a *BillingAPIService) GetBillingInvoicesByIdPdf(ctx context.Context, id string) BillingAPIGetBillingInvoicesByIdPdfRequest {
return BillingAPIGetBillingInvoicesByIdPdfRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingInvoicesByIdPdfExecute(r BillingAPIGetBillingInvoicesByIdPdfRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingInvoicesByIdPdf")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices/{id}/pdf"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingInvoicesHostedByLinkRequest struct {
ctx context.Context
ApiService *BillingAPIService
link string
}
func (r BillingAPIGetBillingInvoicesHostedByLinkRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingInvoicesHostedByLinkExecute(r)
}
/*
GetBillingInvoicesHostedByLink Is the order invoice a link shows, read on the brand of the host it is asked on: a link read on another brand's host is a miss.
Is the order invoice a link shows, read on the brand of the host
it is asked on: a link read on another brand's host is a miss.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param link
@return BillingAPIGetBillingInvoicesHostedByLinkRequest
*/
func (a *BillingAPIService) GetBillingInvoicesHostedByLink(ctx context.Context, link string) BillingAPIGetBillingInvoicesHostedByLinkRequest {
return BillingAPIGetBillingInvoicesHostedByLinkRequest{
ApiService: a,
ctx: ctx,
link: link,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingInvoicesHostedByLinkExecute(r BillingAPIGetBillingInvoicesHostedByLinkRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingInvoicesHostedByLink")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices/hosted/{link}"
localVarPath = strings.Replace(localVarPath, "{"+"link"+"}", url.PathEscape(parameterValueToString(r.link, "link")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingInvoicesHostedByLinkPdfRequest struct {
ctx context.Context
ApiService *BillingAPIService
link string
}
func (r BillingAPIGetBillingInvoicesHostedByLinkPdfRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingInvoicesHostedByLinkPdfExecute(r)
}
/*
GetBillingInvoicesHostedByLinkPdf Is the order invoice a link shows, as a PDF to print or save.
Is the order invoice a link shows, as a PDF to print or save.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param link
@return BillingAPIGetBillingInvoicesHostedByLinkPdfRequest
*/
func (a *BillingAPIService) GetBillingInvoicesHostedByLinkPdf(ctx context.Context, link string) BillingAPIGetBillingInvoicesHostedByLinkPdfRequest {
return BillingAPIGetBillingInvoicesHostedByLinkPdfRequest{
ApiService: a,
ctx: ctx,
link: link,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingInvoicesHostedByLinkPdfExecute(r BillingAPIGetBillingInvoicesHostedByLinkPdfRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingInvoicesHostedByLinkPdf")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices/hosted/{link}/pdf"
localVarPath = strings.Replace(localVarPath, "{"+"link"+"}", url.PathEscape(parameterValueToString(r.link, "link")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingLedgerRequest struct {
ctx context.Context
ApiService *BillingAPIService
range_ *string
}
// Range is the window: 24h, 7d, 30d or 90d. Anything else — including absent — is 30d, so a typo silently widens the window to a month rather than failing.
func (r BillingAPIGetBillingLedgerRequest) Range_(range_ string) BillingAPIGetBillingLedgerRequest {
r.range_ = &range_
return r
}
func (r BillingAPIGetBillingLedgerRequest) Execute() ([]BillingFinanceLedgerEntry, *http.Response, error) {
return r.ApiService.GetBillingLedgerExecute(r)
}
/*
GetBillingLedger Answers the org's own postings inside `range=`, each as a signed entry: a DEPOSIT CREDITS the wallet (positive, account `credits:<org>`), a HOLD sets money aside for a payment agreed and not yet made (negative, account `held:<org>`) and its return gives it back (positive), and every other posting DEBITS it (negative, account `usage:<org>`), described by its notes or its tags.
Answers the org's own postings inside `range=`, each as a signed
entry: a DEPOSIT CREDITS the wallet (positive, account `credits:<org>`), a
HOLD sets money aside for a payment agreed and not yet made (negative, account
`held:<org>`) and its return gives it back (positive), and every other posting
DEBITS it (negative, account `usage:<org>`), described by its notes or its
tags. The sign is the posting's own meaning, read through ONE
vocabulary shared with the ledger that wrote it — a reader with its own
spelling for `deposit` rendered a customer's grant as a charge.
This is the closest projection of the truth. The org's double-entry postings
are the source of record — balanced, only ever appended, one file per org —
and this lane is that list, wider than either half of it: the deposits are the
grants /v1/billing/credits lists and the debits are the spend /v1/billing/usage
rolls up. It answers 503 where this deployment runs no ledger, rather than
reporting an empty wallet.
A row whose timestamp will not parse is KEPT rather than dropped — a malformed
date must show up in a money list, not vanish from it. `balanceCents` is
omitted: these are MOVEMENTS, and the standing balance is /v1/billing/balance.
Cents are ROUNDED from the ledger's exact 18-decimal USD. Scoped to the
caller's own org, where the org's ledger file is the tenant boundary; 401
without a validated principal.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingLedgerRequest
*/
func (a *BillingAPIService) GetBillingLedger(ctx context.Context) BillingAPIGetBillingLedgerRequest {
return BillingAPIGetBillingLedgerRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return []BillingFinanceLedgerEntry
func (a *BillingAPIService) GetBillingLedgerExecute(r BillingAPIGetBillingLedgerRequest) ([]BillingFinanceLedgerEntry, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue []BillingFinanceLedgerEntry
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingLedger")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/ledger"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.range_ != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "range", r.range_, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingMethodsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingMethodsRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingMethodsExecute(r)
}
/*
GetBillingMethods Cards and accounts on file for the caller
Answers every payment method the caller has saved, newest first.
A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.
The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.
`/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.
A store that cannot be read answers an EMPTY LIST rather than a failure: the saved-cards panel renders empty instead of breaking the page around it.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingMethodsRequest
*/
func (a *BillingAPIService) GetBillingMethods(ctx context.Context) BillingAPIGetBillingMethodsRequest {
return BillingAPIGetBillingMethodsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingMethodsExecute(r BillingAPIGetBillingMethodsRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingMethods")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/methods"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingPayoutsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingPayoutsRequest) Execute() ([]BillingPayout, *http.Response, error) {
return r.ApiService.GetBillingPayoutsExecute(r)
}
/*
GetBillingPayouts Answers the org's outbound payouts, newest first — amount, destination, status, and the failure reason where one applies.
Answers the org's outbound payouts, newest first — amount, destination,
status, and the failure reason where one applies.
A payout is ORG-scoped rather than subject-scoped, so there is nothing to pin
beyond the tenant the caller already is, and no query can widen it.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingPayoutsRequest
*/
func (a *BillingAPIService) GetBillingPayouts(ctx context.Context) BillingAPIGetBillingPayoutsRequest {
return BillingAPIGetBillingPayoutsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return []BillingPayout
func (a *BillingAPIService) GetBillingPayoutsExecute(r BillingAPIGetBillingPayoutsRequest) ([]BillingPayout, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue []BillingPayout
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingPayouts")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/payouts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingPlansRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingPlansRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingPlansExecute(r)
}
/*
GetBillingPlans The plan catalog, priced with whatever offer is in force
Answers every plan on sale — its price, what it includes, and the limits it carries — optionally narrowed to one `?category=`.
The prices are what the CHECKOUT will charge: any active promotion is applied before they leave the store, so a reader never applies a discount a second time and a quote can never disagree with the sale.
`?coupon=` quotes the catalog under a plan coupon code: each paid plan it covers carries `couponCode`, `couponPercent`, `couponMonths` (how many monthly periods it discounts, from the first paid one; 1 for a first-month coupon), `couponFirstCents` (what each of those months charges under it) and `couponEnds`; every other row carries `couponError` — `unknown`, `expired`, `exhausted` or `not_applicable`. Nothing is reserved by a quote. Without the parameter the catalog is unchanged.
It is public and needs no tenant, and it is the catalog of the brand the request's host resolves to — the same brand `/v1/commerce/org` answers there. A brand that publishes no plans answers an empty list.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingPlansRequest
*/
func (a *BillingAPIService) GetBillingPlans(ctx context.Context) BillingAPIGetBillingPlansRequest {
return BillingAPIGetBillingPlansRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingPlansExecute(r BillingAPIGetBillingPlansRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingPlans")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/plans"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingPortalMethodsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingPortalMethodsRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingPortalMethodsExecute(r)
}
/*
GetBillingPortalMethods Cards and accounts on file for the caller
Answers every payment method the caller has saved, newest first.
A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.
The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.
`/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.
A store that cannot be read answers an EMPTY LIST rather than a failure: the saved-cards panel renders empty instead of breaking the page around it.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingPortalMethodsRequest
*/
func (a *BillingAPIService) GetBillingPortalMethods(ctx context.Context) BillingAPIGetBillingPortalMethodsRequest {
return BillingAPIGetBillingPortalMethodsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingPortalMethodsExecute(r BillingAPIGetBillingPortalMethodsRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingPortalMethods")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/portal/methods"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingRechargeRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingRechargeRequest) Execute() (*BillingAutoRecharge, *http.Response, error) {
return r.ApiService.GetBillingRechargeExecute(r)
}
/*
GetBillingRecharge Reads the auto-reload rule of the wallet the caller pays from — the org's own account, or a person's wallet in the signup org: top that balance up by `amountCents` whenever it falls below `thresholdCents`, charging that payer's card on file off-session, at most `perDay` times in a UTC day (0 is no daily limit, which the payer's plan sets).
Reads the auto-reload rule of the wallet the caller pays from — the org's own
account, or a person's wallet in the signup org: top that balance up by
`amountCents` whenever it falls below `thresholdCents`, charging that payer's card
on file off-session, at most `perDay` times in a UTC day (0 is no daily limit,
which the payer's plan sets). It is the same setting every prepaid AI account
calls auto-reload.
An org that has never set one reads as disabled with zeroes rather than as an
error — "no rule" answers the question — and `stored` is how a caller tells
never-configured from deliberately-off.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingRechargeRequest
*/
func (a *BillingAPIService) GetBillingRecharge(ctx context.Context) BillingAPIGetBillingRechargeRequest {
return BillingAPIGetBillingRechargeRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingAutoRecharge
func (a *BillingAPIService) GetBillingRechargeExecute(r BillingAPIGetBillingRechargeRequest) (*BillingAutoRecharge, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingAutoRecharge
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingRecharge")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/recharge"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingSettingsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingSettingsRequest) Execute() (*BillingPaymentConfig, *http.Response, error) {
return r.ApiService.GetBillingSettingsExecute(r)
}
/*
GetBillingSettings Answers the PUBLIC half of this org's processor configuration — the ids a browser needs to tokenize a card, and the environment it must tokenize against.
Answers the PUBLIC half of this org's processor configuration — the ids a
browser needs to tokenize a card, and the environment it must tokenize
against.
It carries no secret: an application id is published to every checkout page by
design. What matters is that it names the SAME processor account the charge
will be made on, because a card vaulted against one account and charged
against another is a card that saves and then cannot be used.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingSettingsRequest
*/
func (a *BillingAPIService) GetBillingSettings(ctx context.Context) BillingAPIGetBillingSettingsRequest {
return BillingAPIGetBillingSettingsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingPaymentConfig
func (a *BillingAPIService) GetBillingSettingsExecute(r BillingAPIGetBillingSettingsRequest) (*BillingPaymentConfig, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingPaymentConfig
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingSettings")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/settings"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingSubscriptionsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingSubscriptionsRequest) Execute() (*BillingSubscriptions, *http.Response, error) {
return r.ApiService.GetBillingSubscriptionsExecute(r)
}
/*
GetBillingSubscriptions Lists the plans the caller may see, with the count beside them.
Lists the plans the caller may see, with the count beside them.
An admin of the org, and the platform, see every plan the org holds, and may
narrow to one wallet with `userId`. A member sees the plans of the wallet they
pay from — the org's own for a member of a pooled org, their own in the shared
signup org — and never another member's; the card a plan renews on is left off
a row the member cannot change. A query cannot widen any of it to another
customer's org. An org on nothing is an empty list, not a refusal — being on no
plan is an answer.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingSubscriptionsRequest
*/
func (a *BillingAPIService) GetBillingSubscriptions(ctx context.Context) BillingAPIGetBillingSubscriptionsRequest {
return BillingAPIGetBillingSubscriptionsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingSubscriptions
func (a *BillingAPIService) GetBillingSubscriptionsExecute(r BillingAPIGetBillingSubscriptionsRequest) (*BillingSubscriptions, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingSubscriptions
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingSubscriptions")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/subscriptions"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingTierRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingTierRequest) Execute() (*BillingTier, *http.Response, error) {
return r.ApiService.GetBillingTierExecute(r)
}
/*
GetBillingTier Answers which tier the caller is on, what it allows, and what is left to spend.
Answers which tier the caller is on, what it allows, and what is left to spend.
`effectiveAvailable` is the ONLY figure to compare against zero. The others are
its parts — prepaid money, granted credits and the daily term are three sources
of one spend, not three balances to add up a second time.
A tier that cannot be READ is an error, never Free. The router in front of the
models maps any non-2xx to Free, so answering Free from a question nobody could
answer would pin every paying customer to the most restrictive row with nothing
anywhere to find.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingTierRequest
*/
func (a *BillingAPIService) GetBillingTier(ctx context.Context) BillingAPIGetBillingTierRequest {
return BillingAPIGetBillingTierRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingTier
func (a *BillingAPIService) GetBillingTierExecute(r BillingAPIGetBillingTierRequest) (*BillingTier, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingTier
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingTier")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/tier"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingTransactionsRequest struct {
ctx context.Context
ApiService *BillingAPIService
currency *string
limit *string
offset *string
}
// Currency filters to one currency. Empty reads every currency.
func (r BillingAPIGetBillingTransactionsRequest) Currency(currency string) BillingAPIGetBillingTransactionsRequest {
r.currency = &currency
return r
}
// Limit is the page size; absent or non-positive takes the default 100.
func (r BillingAPIGetBillingTransactionsRequest) Limit(limit string) BillingAPIGetBillingTransactionsRequest {
r.limit = &limit
return r
}
// Offset is how far into the history the page starts.
func (r BillingAPIGetBillingTransactionsRequest) Offset(offset string) BillingAPIGetBillingTransactionsRequest {
r.offset = &offset
return r
}
func (r BillingAPIGetBillingTransactionsRequest) Execute() (*BillingTransactions, *http.Response, error) {
return r.ApiService.GetBillingTransactionsExecute(r)
}
/*
GetBillingTransactions Answers one page of the caller's own ledger, newest first: what moved, how much, when, and what it was tagged with.
Answers one page of the caller's own ledger, newest first: what moved, how
much, when, and what it was tagged with.
`count` is the size of the WHOLE history rather than of the page, which is how
a reader knows there is more to ask for, and `user` echoes the wallet the page
was read for — the same subject the spend gate debits, so a customer can see
which account answered rather than guessing from their own token.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingTransactionsRequest
*/
func (a *BillingAPIService) GetBillingTransactions(ctx context.Context) BillingAPIGetBillingTransactionsRequest {
return BillingAPIGetBillingTransactionsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingTransactions
func (a *BillingAPIService) GetBillingTransactionsExecute(r BillingAPIGetBillingTransactionsRequest) (*BillingTransactions, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingTransactions
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingTransactions")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/transactions"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.currency != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "currency", r.currency, "form", "")
}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
if r.offset != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingTransactionsByIdRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
}
func (r BillingAPIGetBillingTransactionsByIdRequest) Execute() (*BillingTransaction, *http.Response, error) {
return r.ApiService.GetBillingTransactionsByIdExecute(r)
}
/*
GetBillingTransactionsById Reads one ledger entry by its id.
Reads one ledger entry by its id.
It is the MEMBER of the collection beside it rather than a second way to ask —
the same rows GET /v1/billing/transactions lists, addressed one at a time. A
top-up receipt is read here, because a receipt IS a ledger entry: the id this
takes is the `transactionId` a top-up hands back.
The read is narrower than the list: commerce's core loads the row and refuses
anything that is not a deposit, so a row that exists but is not a top-up
answers 404. That asymmetry is stated rather than closed, because widening a
money read to make two shapes match is not a change worth making for symmetry.
The books are the caller's own and cannot be named, so a guessed id misses
rather than reaching another tenant's ledger.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return BillingAPIGetBillingTransactionsByIdRequest
*/
func (a *BillingAPIService) GetBillingTransactionsById(ctx context.Context, id string) BillingAPIGetBillingTransactionsByIdRequest {
return BillingAPIGetBillingTransactionsByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingTransaction
func (a *BillingAPIService) GetBillingTransactionsByIdExecute(r BillingAPIGetBillingTransactionsByIdRequest) (*BillingTransaction, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingTransaction
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingTransactionsById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/transactions/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingUsageRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingUsageRequest) Execute() (*http.Response, error) {
return r.ApiService.GetBillingUsageExecute(r)
}
/*
GetBillingUsage Every billed call the caller's org made, attributed to a product
Answers one row per BILLED call against the caller's org — transaction id, amount, timestamp and the metered unit. This is the raw charged ledger, not a rollup.
Each row is stamped with a canonical `metadata.product` derived from what the meter persisted: `agent` becomes agents, `provisioning` becomes the provisioned kind, a token-metered row becomes inference, anything else keeps its metering surface. The ledger has no product field of its own, so this read is where that dimension is made real — from the SAME charged rows, never a second meter. A row that already carries its own product WINS, so the derivation stops the day the meter records one.
Each row carries `name`: what its metered unit (`metadata.model`) reads as on a bill — `Desktop sandbox` for `desktop/visor`, `Agent sessions` for `session`. An AI model is its own name. Show `name`; `metadata.model` stays the unit the ledger keys on.
`product=<id>` filters to one product server-side. `groupBy=product` reduces to `{product,requests,amountCents}` rollups instead of rows.
`amount` is whole USD cents, ROUNDED; `decimal` beside it is the SAME debit exact, as an 18-decimal USD string. Sum `decimal`. A page of sub-cent token calls totals correctly there and totals ZERO in `amount` — that difference is real money.
Scoped to the caller's own org's books, where the org's ledger file IS the tenant boundary; no client-supplied subject is ever forwarded. 401 without a validated principal. The co-resident read returns the 2000 most recent debits, newest first; `start` and `end` narrow the window only on the split-deploy upstream.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingUsageRequest
*/
func (a *BillingAPIService) GetBillingUsage(ctx context.Context) BillingAPIGetBillingUsageRequest {
return BillingAPIGetBillingUsageRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) GetBillingUsageExecute(r BillingAPIGetBillingUsageRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingUsage")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/usage"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIGetBillingUsageAccountsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingUsageAccountsRequest) Execute() (*BillingAccounts, *http.Response, error) {
return r.ApiService.GetBillingUsageAccountsExecute(r)
}
/*
GetBillingUsageAccounts Answers per-account totals for the linked provider accounts the gateway ROUTED this caller's traffic through — requests, prompt and completion tokens, recorded cost — plus their honest sum.
Answers per-account totals for the linked provider accounts the
gateway ROUTED this caller's traffic through — requests, prompt and completion
tokens, recorded cost — plus their honest sum.
This is the one read in the billing namespace scoped to the PERSON, not the
org. Rows are keyed on (validated org, validated user), so a caller sees the
accounts THEY linked and never a colleague's, even inside one org — everything
else under /v1/billing is org-wide. Neither key is ever read from the request
body or the query.
It is a ROUTING counter, not the money ledger. `costCents` is 0 for an account
billed by its own subscription, where the plan pays the provider directly, so
these totals do not reconcile against what the org was charged.
/v1/billing/usage is the charged ledger.
401 without a validated principal. Where the linked-account plane is not
resident the answer is an honest 501 — never an empty breakdown, which would
read as no usage.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingUsageAccountsRequest
*/
func (a *BillingAPIService) GetBillingUsageAccounts(ctx context.Context) BillingAPIGetBillingUsageAccountsRequest {
return BillingAPIGetBillingUsageAccountsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingAccounts
func (a *BillingAPIService) GetBillingUsageAccountsExecute(r BillingAPIGetBillingUsageAccountsRequest) (*BillingAccounts, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingAccounts
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingUsageAccounts")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/usage/accounts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingUsageRollupRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingUsageRollupRequest) Execute() (*BillingRollup, *http.Response, error) {
return r.ApiService.GetBillingUsageRollupExecute(r)
}
/*
GetBillingUsageRollup Answers the caller's month: what their plan includes, what has been consumed against it, and the wallet beside it.
Answers the caller's month: what their plan includes, what has been consumed
against it, and the wallet beside it.
The two blocks are SEPARATE monies and are never added. One is usage a plan
granted; the other is prepaid credit bought with a card. Their sum is not a
number anyone holds, and a reader that formed it would be inventing a balance.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingUsageRollupRequest
*/
func (a *BillingAPIService) GetBillingUsageRollup(ctx context.Context) BillingAPIGetBillingUsageRollupRequest {
return BillingAPIGetBillingUsageRollupRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingRollup
func (a *BillingAPIService) GetBillingUsageRollupExecute(r BillingAPIGetBillingUsageRollupRequest) (*BillingRollup, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingRollup
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingUsageRollup")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/usage/rollup"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetBillingWireRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIGetBillingWireRequest) Execute() (*BillingWireInstructions, *http.Response, error) {
return r.ApiService.GetBillingWireExecute(r)
}
/*
GetBillingWire Answers where to send a wire top-up: the receiving bank details, with the caller's own payment reference.
Answers where to send a wire top-up: the receiving bank details, with the
caller's own payment reference.
The account is the SERVING BRAND'S — resolved from the host the customer is
paying on, so paying on one brand never shows another's bank — and the
reference carries the caller's billing key, which is how an arriving wire
names who it credits. Nothing mints here; a receipt is settled by an operator
once the bank confirms it.
It is all-or-nothing: no configured account is 503 rather than a partial form,
because nobody can wire to three fields out of five.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIGetBillingWireRequest
*/
func (a *BillingAPIService) GetBillingWire(ctx context.Context) BillingAPIGetBillingWireRequest {
return BillingAPIGetBillingWireRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingWireInstructions
func (a *BillingAPIService) GetBillingWireExecute(r BillingAPIGetBillingWireRequest) (*BillingWireInstructions, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingWireInstructions
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetBillingWire")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/wire"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIGetInvoiceRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
brand *string
}
// Brand is the brand that bills (hanzo, lux, zoo, pars), whose mark and address a rendered invoice carries. The edge sets it from the caller&#39;s issuer; empty is Hanzo.
func (r BillingAPIGetInvoiceRequest) Brand(brand string) BillingAPIGetInvoiceRequest {
r.brand = &brand
return r
}
func (r BillingAPIGetInvoiceRequest) Execute() (*BillingInvoice, *http.Response, error) {
return r.ApiService.GetInvoiceExecute(r)
}
/*
GetInvoice Read one invoice
Reads one invoice out of the caller's org.
The org scopes the read by construction — the store is namespaced to it — so an
id belonging to another tenant is not found rather than found and then filtered.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the invoice id.
@return BillingAPIGetInvoiceRequest
*/
func (a *BillingAPIService) GetInvoice(ctx context.Context, id string) BillingAPIGetInvoiceRequest {
return BillingAPIGetInvoiceRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingInvoice
func (a *BillingAPIService) GetInvoiceExecute(r BillingAPIGetInvoiceRequest) (*BillingInvoice, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingInvoice
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.GetInvoice")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.brand != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "brand", r.brand, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIIssueInvoiceRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingInvoiceRef *BillingInvoiceRef
}
func (r BillingAPIIssueInvoiceRequest) BillingInvoiceRef(billingInvoiceRef BillingInvoiceRef) BillingAPIIssueInvoiceRequest {
r.billingInvoiceRef = &billingInvoiceRef
return r
}
func (r BillingAPIIssueInvoiceRequest) Execute() (*BillingInvoice, *http.Response, error) {
return r.ApiService.IssueInvoiceExecute(r)
}
/*
IssueInvoice Issue a draft invoice, making it collectible
Issues a draft invoice: moves it to OPEN, assigns its number, and makes it
collectible. It is the org admin's act; a member is refused 403.
Only a draft can be issued. An invoice already open, paid or void is refused
with the state machine's own reason rather than being silently re-issued, which
would mint a second number for one debt.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the invoice id.
@return BillingAPIIssueInvoiceRequest
*/
func (a *BillingAPIService) IssueInvoice(ctx context.Context, id string) BillingAPIIssueInvoiceRequest {
return BillingAPIIssueInvoiceRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingInvoice
func (a *BillingAPIService) IssueInvoiceExecute(r BillingAPIIssueInvoiceRequest) (*BillingInvoice, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingInvoice
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.IssueInvoice")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices/{id}/issue"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingInvoiceRef == nil {
return localVarReturnValue, nil, reportError("billingInvoiceRef is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingInvoiceRef
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPatchBillingAlertsByIdRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingAlertPatch *BillingAlertPatch
}
func (r BillingAPIPatchBillingAlertsByIdRequest) BillingAlertPatch(billingAlertPatch BillingAlertPatch) BillingAPIPatchBillingAlertsByIdRequest {
r.billingAlertPatch = &billingAlertPatch
return r
}
func (r BillingAPIPatchBillingAlertsByIdRequest) Execute() (*BillingAlert, *http.Response, error) {
return r.ApiService.PatchBillingAlertsByIdExecute(r)
}
/*
PatchBillingAlertsById Changes one spend cap: raise or lower the ceiling, flip enforcement, retune the rate limit.
Changes one spend cap: raise or lower the ceiling, flip enforcement, retune
the rate limit.
Only the fields the body carries move. Every mutable field is optional, and an
absent one is PRESERVED rather than reset — so a change that flips enforcement
cannot silently wipe the threshold it enforces.
A cap belonging to another org is a 404, not a 403: a guessed id must not
become an oracle for what anyone else holds.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return BillingAPIPatchBillingAlertsByIdRequest
*/
func (a *BillingAPIService) PatchBillingAlertsById(ctx context.Context, id string) BillingAPIPatchBillingAlertsByIdRequest {
return BillingAPIPatchBillingAlertsByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingAlert
func (a *BillingAPIService) PatchBillingAlertsByIdExecute(r BillingAPIPatchBillingAlertsByIdRequest) (*BillingAlert, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPatch
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingAlert
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PatchBillingAlertsById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/alerts/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingAlertPatch == nil {
return localVarReturnValue, nil, reportError("billingAlertPatch is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingAlertPatch
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingAlertsRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingAlertSpec *BillingAlertSpec
}
func (r BillingAPIPostBillingAlertsRequest) BillingAlertSpec(billingAlertSpec BillingAlertSpec) BillingAPIPostBillingAlertsRequest {
r.billingAlertSpec = &billingAlertSpec
return r
}
func (r BillingAPIPostBillingAlertsRequest) Execute() (*BillingAlert, *http.Response, error) {
return r.ApiService.PostBillingAlertsExecute(r)
}
/*
PostBillingAlerts Opens a spend cap on the caller's own org.
Opens a spend cap on the caller's own org.
At least one limit must mean something: a threshold above zero (a spend cap)
or a requests-per-minute above zero (a rate limit). A row that bounds neither
is refused rather than stored, because a ceiling nothing measures against is a
ceiling a customer believes in and does not have.
The cap is keyed on the caller's own billing subject, resolved server-side —
the SAME key the verdict looks it up under, which is what makes enforcement
bind rather than merely record.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingAlertsRequest
*/
func (a *BillingAPIService) PostBillingAlerts(ctx context.Context) BillingAPIPostBillingAlertsRequest {
return BillingAPIPostBillingAlertsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingAlert
func (a *BillingAPIService) PostBillingAlertsExecute(r BillingAPIPostBillingAlertsRequest) (*BillingAlert, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingAlert
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingAlerts")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/alerts"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingAlertSpec == nil {
return localVarReturnValue, nil, reportError("billingAlertSpec is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingAlertSpec
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingCryptoDepositRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingCryptoAsset *BillingCryptoAsset
}
func (r BillingAPIPostBillingCryptoDepositRequest) BillingCryptoAsset(billingCryptoAsset BillingCryptoAsset) BillingAPIPostBillingCryptoDepositRequest {
r.billingCryptoAsset = &billingCryptoAsset
return r
}
func (r BillingAPIPostBillingCryptoDepositRequest) Execute() (*BillingCryptoDeposit, *http.Response, error) {
return r.ApiService.PostBillingCryptoDepositExecute(r)
}
/*
PostBillingCryptoDeposit Issues a deposit address the caller can send crypto to, on the asset they ask for.
Issues a deposit address the caller can send crypto to, on the asset they ask
for.
The address credits the CALLER'S own wallet and nobody else's: the payer is
the validated principal, never a body value. Asking again reuses the caller's
open intent rather than minting a second address, so a refresh cannot spray
key generations — and a payer who sent to the address they saw earlier is
still credited.
No balance moves here. The chain watcher credits on real confirmations, so
what comes back is an address, a status and the terms: the minimum that
credits, any fee, the confirmations required, and one line of instructions.
Once the transfer is that deep the deposit is credited as cash to the caller's
balance (GET /v1/billing/balance, cash) and its status is succeeded.
The asset is checked against GET /v1/billing/crypto/options before anything is
minted. A chain, a token or a pair the rail does not accept is 400, and the
answer lists the accepted chains, tokens and assets. A deposit rail with
nothing watched is 503 — nothing sent now can be credited, and the Gateway
rail or a card is the way to pay until it reopens.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingCryptoDepositRequest
*/
func (a *BillingAPIService) PostBillingCryptoDeposit(ctx context.Context) BillingAPIPostBillingCryptoDepositRequest {
return BillingAPIPostBillingCryptoDepositRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingCryptoDeposit
func (a *BillingAPIService) PostBillingCryptoDepositExecute(r BillingAPIPostBillingCryptoDepositRequest) (*BillingCryptoDeposit, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCryptoDeposit
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingCryptoDeposit")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/crypto/deposit"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingCryptoAsset == nil {
return localVarReturnValue, nil, reportError("billingCryptoAsset is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingCryptoAsset
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingCryptoGatewayRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingSignedPayment *BillingSignedPayment
}
func (r BillingAPIPostBillingCryptoGatewayRequest) BillingSignedPayment(billingSignedPayment BillingSignedPayment) BillingAPIPostBillingCryptoGatewayRequest {
r.billingSignedPayment = &billingSignedPayment
return r
}
func (r BillingAPIPostBillingCryptoGatewayRequest) Execute() (*BillingGatewayPayment, *http.Response, error) {
return r.ApiService.PostBillingCryptoGatewayExecute(r)
}
/*
PostBillingCryptoGateway Takes a signed USDC payment from the caller's Circle Gateway balance to the treasury, and answers what became of it.
Takes a signed USDC payment from the caller's Circle Gateway balance to the
treasury, and answers what became of it.
accepted: Circle Gateway LOCKED the USDC and the caller is credited — or,
once the caller holds $1,000 of credit Gateway has not confirmed, credited
when Gateway confirms this payment (deferred). pending: the outcome is not
known yet; read it back or present the same payment again — it resolves to
one credit either way. A refusal is 4xx with Gateway's reason
(insufficient_balance, invalid_signature, …) or ours (nonce_not_issued,
recipient_mismatch, amount_below_minimum, …); 503 means the rail is shut.
Who is credited is the caller, never a body value: the payer is resolved
server-side, and the payment's own nonce must be the one issued to it.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingCryptoGatewayRequest
*/
func (a *BillingAPIService) PostBillingCryptoGateway(ctx context.Context) BillingAPIPostBillingCryptoGatewayRequest {
return BillingAPIPostBillingCryptoGatewayRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingGatewayPayment
func (a *BillingAPIService) PostBillingCryptoGatewayExecute(r BillingAPIPostBillingCryptoGatewayRequest) (*BillingGatewayPayment, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingGatewayPayment
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingCryptoGateway")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/crypto/gateway"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingSignedPayment == nil {
return localVarReturnValue, nil, reportError("billingSignedPayment is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingSignedPayment
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingMethodsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIPostBillingMethodsRequest) Execute() (*http.Response, error) {
return r.ApiService.PostBillingMethodsExecute(r)
}
/*
PostBillingMethods Save a card or account for the caller
Vaults the instrument at the processor and stores the row.
A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.
The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.
`/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.
Saving a card ALREADY on file answers with the row that already holds it rather than stacking a duplicate — 200 for that, 201 for a genuinely new row, so a client can tell which happened. A card the processor declines is 402 and nothing is stored.
The org's cards are an admin's to add: a member billed from the org's account is refused 403 with a sentence naming who to ask. A member billed from a wallet of their own saves cards to that wallet.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingMethodsRequest
*/
func (a *BillingAPIService) PostBillingMethods(ctx context.Context) BillingAPIPostBillingMethodsRequest {
return BillingAPIPostBillingMethodsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) PostBillingMethodsExecute(r BillingAPIPostBillingMethodsRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingMethods")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/methods"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIPostBillingModeRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingModeIn *BillingModeIn
}
func (r BillingAPIPostBillingModeRequest) BillingModeIn(billingModeIn BillingModeIn) BillingAPIPostBillingModeRequest {
r.billingModeIn = &billingModeIn
return r
}
func (r BillingAPIPostBillingModeRequest) Execute() (*BillingMode, *http.Response, error) {
return r.ApiService.PostBillingModeExecute(r)
}
/*
PostBillingMode Moves this org between sandbox money and real money.
Moves this org between sandbox money and real money.
It decides whether a charge hits a real card, so it is the one posture change
that is not self-service: the platform bar, never an org owner, because an org
that could put itself in test mode could take priced work for free.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingModeRequest
*/
func (a *BillingAPIService) PostBillingMode(ctx context.Context) BillingAPIPostBillingModeRequest {
return BillingAPIPostBillingModeRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingMode
func (a *BillingAPIService) PostBillingModeExecute(r BillingAPIPostBillingModeRequest) (*BillingMode, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingMode
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingMode")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/mode"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingModeIn == nil {
return localVarReturnValue, nil, reportError("billingModeIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingModeIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingPaypalOrderRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingPaypalOrderIn *BillingPaypalOrderIn
xIdempotencyKey *string
}
func (r BillingAPIPostBillingPaypalOrderRequest) BillingPaypalOrderIn(billingPaypalOrderIn BillingPaypalOrderIn) BillingAPIPostBillingPaypalOrderRequest {
r.billingPaypalOrderIn = &billingPaypalOrderIn
return r
}
func (r BillingAPIPostBillingPaypalOrderRequest) XIdempotencyKey(xIdempotencyKey string) BillingAPIPostBillingPaypalOrderRequest {
r.xIdempotencyKey = &xIdempotencyKey
return r
}
func (r BillingAPIPostBillingPaypalOrderRequest) Execute() (*BillingPayPalOrderOut, *http.Response, error) {
return r.ApiService.PostBillingPaypalOrderExecute(r)
}
/*
PostBillingPaypalOrder Opens a server-priced PayPal REST v2 order for either a bounded credit top-up (intent CAPTURE) or a plan purchase's first period (intent AUTHORIZE).
Opens a server-priced PayPal REST v2 order for either a
bounded credit top-up (intent CAPTURE) or a plan purchase's first period
(intent AUTHORIZE).
No balance or subscription row is minted here: the browser hands the returned
`orderId` to the PayPal Smart Buttons SDK for buyer approval, then settles
the payment through POST /v1/billing/topup/token or
POST /v1/billing/subscribe/card with `provider: "paypal"`.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingPaypalOrderRequest
*/
func (a *BillingAPIService) PostBillingPaypalOrder(ctx context.Context) BillingAPIPostBillingPaypalOrderRequest {
return BillingAPIPostBillingPaypalOrderRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingPayPalOrderOut
func (a *BillingAPIService) PostBillingPaypalOrderExecute(r BillingAPIPostBillingPaypalOrderRequest) (*BillingPayPalOrderOut, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingPayPalOrderOut
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingPaypalOrder")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/paypal/order"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingPaypalOrderIn == nil {
return localVarReturnValue, nil, reportError("billingPaypalOrderIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.xIdempotencyKey != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Idempotency-Key", r.xIdempotencyKey, "simple", "")
}
// body params
localVarPostBody = r.billingPaypalOrderIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingPortalMethodsRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIPostBillingPortalMethodsRequest) Execute() (*http.Response, error) {
return r.ApiService.PostBillingPortalMethodsExecute(r)
}
/*
PostBillingPortalMethods Save a card or account for the caller
Vaults the instrument at the processor and stores the row.
A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.
The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.
`/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.
Saving a card ALREADY on file answers with the row that already holds it rather than stacking a duplicate — 200 for that, 201 for a genuinely new row, so a client can tell which happened. A card the processor declines is 402 and nothing is stored.
The org's cards are an admin's to add: a member billed from the org's account is refused 403 with a sentence naming who to ask. A member billed from a wallet of their own saves cards to that wallet.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingPortalMethodsRequest
*/
func (a *BillingAPIService) PostBillingPortalMethods(ctx context.Context) BillingAPIPostBillingPortalMethodsRequest {
return BillingAPIPostBillingPortalMethodsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) PostBillingPortalMethodsExecute(r BillingAPIPostBillingPortalMethodsRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingPortalMethods")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/portal/methods"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIPostBillingRechargeRunAllRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIPostBillingRechargeRunAllRequest) Execute() (*BillingRecharge, *http.Response, error) {
return r.ApiService.PostBillingRechargeRunAllExecute(r)
}
/*
PostBillingRechargeRunAll Sweeps every org's auto-recharge and answers what it did.
Sweeps every org's auto-recharge and answers what it did.
PLATFORM AUTHORITY ONLY. It charges saved cards across every tenant, so an org
owner reaching it could sweep-charge the estate; a caller without it is
refused before anything is charged.
The answer explains a sweep that charged nobody as readily as one that
charged: it names how many orgs were considered and how many needed charging,
with a row each.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingRechargeRunAllRequest
*/
func (a *BillingAPIService) PostBillingRechargeRunAll(ctx context.Context) BillingAPIPostBillingRechargeRunAllRequest {
return BillingAPIPostBillingRechargeRunAllRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingRecharge
func (a *BillingAPIService) PostBillingRechargeRunAllExecute(r BillingAPIPostBillingRechargeRunAllRequest) (*BillingRecharge, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingRecharge
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingRechargeRunAll")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/recharge/run-all"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingSubscribeCardRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIPostBillingSubscribeCardRequest) Execute() (*http.Response, error) {
return r.ApiService.PostBillingSubscribeCardExecute(r)
}
/*
PostBillingSubscribeCard Buy a plan with a card
Vaults the card (or reuses one already on file), charges the plan's FIRST period at the catalog price, and opens the subscription — one act, all of it server-side.
There is NO AMOUNT in the request. `level` picks which of the plan's published prices to buy at — an index, never a number — so what the card is charged is decided by the catalog and underpaying cannot be expressed.
`interval` picks the term: "month" (the default) or "year", which charges the plan's annual total now and renews yearly. A plan with no annual price refuses "year".
`lines` are a team's other seat types, bought on the same subscription: `[{"planId":"team-premium","quantity":1}]` beside `planId` "team" and `quantity` 1 is a team of one standard and one premium seat, charged both seats' prices. A team is at least two members across every seat type and at most 100; a line of a plan that is not a seat type of the team is 400 before any card is charged.
`coupon` is a plan coupon code (case-insensitive) for a percent off the FIRST month only; renewals bill the catalog price. It is a code, never an amount. A code that is unknown, expired, used up, not for this plan, or sent with annual billing or prepaid credit is 400, and one this org or this card has already redeemed is 409 — before any card is charged, never a silent full-price sale. The receipt names the coupon and its percent.
`wallet: true` says `sourceId` is a wallet's single-use token (Apple Pay, Google Pay, Cash App Pay). The first period is authorized on the wallet, any coupon is held against the org and the card behind it, and only then is the payment captured; a coupon already used by either voids the hold and is 409. Cash App Pay names no card, so a coupon with it is 400. The token is kept nowhere, so the plan renews only once a card plan follows it: a plan's period is charged to a card on file, never to the prepaid balance, which pays for usage. A `sourceId` of "balance" or "credits" is 400 `plan_needs_card`.
Bought while the account holds a plan paid outside checkout (a wire, a comp) or one the balance used to renew, the card plan starts when that plan ends: the card is kept now and charged then, nothing is charged today, and the receipt states `startsAt`, `startsCents` and `follows`.
`balanceCents` is an organization's starting usage balance, bought in the same payment as the seats: `amountCents` is seats x price plus it, the invoice holds the seats and the balance is credited to the organization's prepaid balance (`balanceCents`, `balanceId` on the receipt). It is whole dollars and at most the plan's `limits.balanceCeiling`; one that is not, a plan that states no ceiling, or a balance sent with a wallet token or on a plan that starts later is 400 before any card is charged. A plan whose limits state how an organization orders it (spend limits, balance months, a ceiling) is bought only for the organization, by its admin, on a request that selects it with X-Org-Id; one that selects none is 400 ("choose the organization to buy for") before any card is charged. Whether the buyer administers it is asked of IAM at the sale, not read off the token: 403 when IAM no longer names them an admin, 503 when it cannot answer.
`consent` is the choice the checkout page holds, as @hanzo/event spells it ("analytics,marketing,ads"). The sale reaches an ad platform only under it. It counts only from a browser (a request with Sec-Fetch-Site), and a browser that sends GPC or DNT has allowed nothing, whatever the page says.
A fresh sale answers 201 with the receipt. An identical retry answers 200 with the FIRST sale's body, byte for byte, so a client cannot read a replay as a second subscription having been opened. A caller already on a paid plan is 409 rather than charged again.
The org's plan is bought only by an admin of the org or the platform: a member billed from the org's account is refused 403, before any card is charged, with a sentence naming who to ask. A member billed from a wallet of their own buys a plan for that wallet.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingSubscribeCardRequest
*/
func (a *BillingAPIService) PostBillingSubscribeCard(ctx context.Context) BillingAPIPostBillingSubscribeCardRequest {
return BillingAPIPostBillingSubscribeCardRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) PostBillingSubscribeCardExecute(r BillingAPIPostBillingSubscribeCardRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingSubscribeCard")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/subscribe/card"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIPostBillingSubscribeInvoiceRequest struct {
ctx context.Context
ApiService *BillingAPIService
}
func (r BillingAPIPostBillingSubscribeInvoiceRequest) Execute() (*http.Response, error) {
return r.ApiService.PostBillingSubscribeInvoiceExecute(r)
}
/*
PostBillingSubscribeInvoice Order a plan by invoice, paid by wire
Raises an OPEN invoice for an organization's order — the seats at the plan's price and the starting balance — and sends it to the buyer. NOTHING STARTS until it is paid: "Your plan starts when we confirm your payment."
The body is a card sale's less the card and the coupon: `planId`, `quantity`, `lines`, `interval`, `balanceCents`. The organization is the one chosen with X-Org-Id (none chosen is 400), and only its admin, as IAM says now, orders (403). The answer carries the invoice, the amount due, the due date (the plan's `limits.invoiceDays`), when it is voided if unpaid (`limits.graceDays` later), the receiving bank with the reference to send exactly, the same as `howToPay` steps one field to a line, and `hostedUrl` and `pdfUrl`. A plan already paid for, or one with an invoice still open, is 409; a site that takes no order by invoice is 503. A retry under the same X-Idempotency-Key answers the same order as it stands at 200, with a new link and the bank read again; nothing is mailed again.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingSubscribeInvoiceRequest
*/
func (a *BillingAPIService) PostBillingSubscribeInvoice(ctx context.Context) BillingAPIPostBillingSubscribeInvoiceRequest {
return BillingAPIPostBillingSubscribeInvoiceRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *BillingAPIService) PostBillingSubscribeInvoiceExecute(r BillingAPIPostBillingSubscribeInvoiceRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingSubscribeInvoice")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/subscribe/invoice"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type BillingAPIPostBillingTopupRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingTopupIn *BillingTopupIn
xIdempotencyKey *string
}
func (r BillingAPIPostBillingTopupRequest) BillingTopupIn(billingTopupIn BillingTopupIn) BillingAPIPostBillingTopupRequest {
r.billingTopupIn = &billingTopupIn
return r
}
func (r BillingAPIPostBillingTopupRequest) XIdempotencyKey(xIdempotencyKey string) BillingAPIPostBillingTopupRequest {
r.xIdempotencyKey = &xIdempotencyKey
return r
}
func (r BillingAPIPostBillingTopupRequest) Execute() (*BillingCharged, *http.Response, error) {
return r.ApiService.PostBillingTopupExecute(r)
}
/*
PostBillingTopup Charges a card the caller already saved and credits the balance.
Charges a card the caller already saved and credits the
balance. Same receipt and the same retry safety as the token endpoint; the only
difference is which card, so a caller topping up from a saved method never
re-enters one.
The org's card on file is charged only by an admin of the org or the platform;
a member is refused with 403 and told to ask an admin. A member billed from a
wallet of their own charges that wallet's card. An org selected with X-Org-Id that
the sign-in does not list is 409, and nothing is charged.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingTopupRequest
*/
func (a *BillingAPIService) PostBillingTopup(ctx context.Context) BillingAPIPostBillingTopupRequest {
return BillingAPIPostBillingTopupRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingCharged
func (a *BillingAPIService) PostBillingTopupExecute(r BillingAPIPostBillingTopupRequest) (*BillingCharged, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCharged
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingTopup")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/topup"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingTopupIn == nil {
return localVarReturnValue, nil, reportError("billingTopupIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.xIdempotencyKey != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Idempotency-Key", r.xIdempotencyKey, "simple", "")
}
// body params
localVarPostBody = r.billingTopupIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingTopupTokenRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingTopupIn *BillingTopupIn
xIdempotencyKey *string
}
func (r BillingAPIPostBillingTopupTokenRequest) BillingTopupIn(billingTopupIn BillingTopupIn) BillingAPIPostBillingTopupTokenRequest {
r.billingTopupIn = &billingTopupIn
return r
}
func (r BillingAPIPostBillingTopupTokenRequest) XIdempotencyKey(xIdempotencyKey string) BillingAPIPostBillingTopupTokenRequest {
r.xIdempotencyKey = &xIdempotencyKey
return r
}
func (r BillingAPIPostBillingTopupTokenRequest) Execute() (*BillingCharged, *http.Response, error) {
return r.ApiService.PostBillingTopupTokenExecute(r)
}
/*
PostBillingTopupToken Charges a single-use card token and credits the caller's balance.
Charges a single-use card token and credits the caller's
balance.
The token comes from the payment form and is vaulted as part of the charge, so
no card number reaches this service and none is stored here. The receipt names
the ledger entry, the new balance, and the PROCESSOR's own reference — which is
the only field that proves money moved at the gateway rather than only in our
ledger.
Retry-safe on X-Idempotency-Key: the same key settles one charge and returns
the first receipt. An org selected with X-Org-Id that the sign-in does not list
is 409, and nothing is charged.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingTopupTokenRequest
*/
func (a *BillingAPIService) PostBillingTopupToken(ctx context.Context) BillingAPIPostBillingTopupTokenRequest {
return BillingAPIPostBillingTopupTokenRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingCharged
func (a *BillingAPIService) PostBillingTopupTokenExecute(r BillingAPIPostBillingTopupTokenRequest) (*BillingCharged, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingCharged
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingTopupToken")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/topup/token"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingTopupIn == nil {
return localVarReturnValue, nil, reportError("billingTopupIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.xIdempotencyKey != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "X-Idempotency-Key", r.xIdempotencyKey, "simple", "")
}
// body params
localVarPostBody = r.billingTopupIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPostBillingUsageRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingUsageReport *BillingUsageReport
}
func (r BillingAPIPostBillingUsageRequest) BillingUsageReport(billingUsageReport BillingUsageReport) BillingAPIPostBillingUsageRequest {
r.billingUsageReport = &billingUsageReport
return r
}
func (r BillingAPIPostBillingUsageRequest) Execute() (*BillingUsageReceipt, *http.Response, error) {
return r.ApiService.PostBillingUsageExecute(r)
}
/*
PostBillingUsage Debits one act an application metered to the org it acts for, and answers the receipt.
Debits one act an application metered to the org it acts for, and
answers the receipt.
The caller is an application acting as itself — an IAM client_credentials
token — and the org is the one that token acts in: the application's own, or
one that granted it membership, selected with X-Org-Id and named again in
`org`. A person, an API key, an unauthenticated caller, and a body naming an
org the token does not act in are all refused before anything is debited.
The debit lands in the same ledger every other meter writes, in the wallet GET
/v1/billing/balance reports for the same caller. It is exactly-once on `id`: a
retry answers the same receipt, and the same id for a different amount is 409.
Recording does not gate — the work already happened — so a caller that must
refuse unfunded work asks GET /v1/billing/balance and GET
/v1/billing/alerts/authorize first.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPostBillingUsageRequest
*/
func (a *BillingAPIService) PostBillingUsage(ctx context.Context) BillingAPIPostBillingUsageRequest {
return BillingAPIPostBillingUsageRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingUsageReceipt
func (a *BillingAPIService) PostBillingUsageExecute(r BillingAPIPostBillingUsageRequest) (*BillingUsageReceipt, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingUsageReceipt
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PostBillingUsage")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/usage"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingUsageReport == nil {
return localVarReturnValue, nil, reportError("billingUsageReport is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingUsageReport
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIPutBillingRechargeRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingAutoRechargeEdit *BillingAutoRechargeEdit
}
func (r BillingAPIPutBillingRechargeRequest) BillingAutoRechargeEdit(billingAutoRechargeEdit BillingAutoRechargeEdit) BillingAPIPutBillingRechargeRequest {
r.billingAutoRechargeEdit = &billingAutoRechargeEdit
return r
}
func (r BillingAPIPutBillingRechargeRequest) Execute() (*BillingAutoRecharge, *http.Response, error) {
return r.ApiService.PutBillingRechargeExecute(r)
}
/*
PutBillingRecharge Sets the auto-reload rule of the wallet the caller pays from, and answers with the rule as stored.
Sets the auto-reload rule of the wallet the caller pays from, and answers with the
rule as stored.
The org's own account's rule is its admins' to change, and the platform's; a
member billed from a wallet of their own (a person in the signup org) changes that
wallet's rule and no other (403 otherwise, with the plain sentence "Only an admin
of <org> can change its auto-reload. Ask an admin to do it."): the sweep charges
the payer's default card with nobody there.
ENABLING REQUIRES A CARD ON FILE (400), because the sweep charges off-session:
a rule naming no chargeable method is a promise the schedule cannot keep. The
amount is a top-up's own range, $5 to $5,000, and the balance it reloads below
is $0 to $5,000; a value outside either is refused the same way, the range in
the sentence. The sweep reloads at most `perDay` times in a UTC day.
The rule is the payer's OWN. The org and the wallet come from the validated
principal and the body names neither, so there is no field a write could be
steered through onto another payer's schedule.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIPutBillingRechargeRequest
*/
func (a *BillingAPIService) PutBillingRecharge(ctx context.Context) BillingAPIPutBillingRechargeRequest {
return BillingAPIPutBillingRechargeRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingAutoRecharge
func (a *BillingAPIService) PutBillingRechargeExecute(r BillingAPIPutBillingRechargeRequest) (*BillingAutoRecharge, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingAutoRecharge
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.PutBillingRecharge")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/recharge"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingAutoRechargeEdit == nil {
return localVarReturnValue, nil, reportError("billingAutoRechargeEdit is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingAutoRechargeEdit
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIRaiseInvoiceRequest struct {
ctx context.Context
ApiService *BillingAPIService
billingRaiseIn *BillingRaiseIn
}
func (r BillingAPIRaiseInvoiceRequest) BillingRaiseIn(billingRaiseIn BillingRaiseIn) BillingAPIRaiseInvoiceRequest {
r.billingRaiseIn = &billingRaiseIn
return r
}
func (r BillingAPIRaiseInvoiceRequest) Execute() (*BillingInvoice, *http.Response, error) {
return r.ApiService.RaiseInvoiceExecute(r)
}
/*
RaiseInvoice Raise a draft invoice against a customer
Raises a DRAFT invoice against a customer in the caller's own org. It is the
org admin's act; a member is refused 403.
The invoice is not collectible yet: a draft exists so it can be read and
corrected, and issueInvoice is the separate act that turns it into a demand for
payment. The subtotal and amount due are computed from the lines, so there is
no total to send and none to get wrong.
The billing org is the caller's, taken from the validated principal, so an
invoice can only ever be raised on the caller's own books.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return BillingAPIRaiseInvoiceRequest
*/
func (a *BillingAPIService) RaiseInvoice(ctx context.Context) BillingAPIRaiseInvoiceRequest {
return BillingAPIRaiseInvoiceRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return BillingInvoice
func (a *BillingAPIService) RaiseInvoiceExecute(r BillingAPIRaiseInvoiceRequest) (*BillingInvoice, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingInvoice
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.RaiseInvoice")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingRaiseIn == nil {
return localVarReturnValue, nil, reportError("billingRaiseIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingRaiseIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIReactivateSubscriptionRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingSubscriptionAct *BillingSubscriptionAct
}
func (r BillingAPIReactivateSubscriptionRequest) BillingSubscriptionAct(billingSubscriptionAct BillingSubscriptionAct) BillingAPIReactivateSubscriptionRequest {
r.billingSubscriptionAct = &billingSubscriptionAct
return r
}
func (r BillingAPIReactivateSubscriptionRequest) Execute() (*BillingSubscription, *http.Response, error) {
return r.ApiService.ReactivateSubscriptionExecute(r)
}
/*
ReactivateSubscription Put a canceled subscription back on its plan
Puts a canceled subscription back on its plan.
What asks for this is usually a recovered payment method or a support tool
rather than a browser, which is most of the argument for it having an address
at all. The engine decides whether the move is legal; a row it will not
reactivate comes back with its own reason.
Resuming the org's plan commits its card to the next renewal, so it takes the
authority ending it does: an admin of the org or the platform, or a member for
a wallet of their own. A member is refused with 403 and told to ask an admin.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the subscription, from the path.
@return BillingAPIReactivateSubscriptionRequest
*/
func (a *BillingAPIService) ReactivateSubscription(ctx context.Context, id string) BillingAPIReactivateSubscriptionRequest {
return BillingAPIReactivateSubscriptionRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingSubscription
func (a *BillingAPIService) ReactivateSubscriptionExecute(r BillingAPIReactivateSubscriptionRequest) (*BillingSubscription, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingSubscription
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.ReactivateSubscription")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/subscriptions/{id}/reactivate"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingSubscriptionAct == nil {
return localVarReturnValue, nil, reportError("billingSubscriptionAct is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingSubscriptionAct
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIResizeSubscriptionRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingResize *BillingResize
}
func (r BillingAPIResizeSubscriptionRequest) BillingResize(billingResize BillingResize) BillingAPIResizeSubscriptionRequest {
r.billingResize = &billingResize
return r
}
func (r BillingAPIResizeSubscriptionRequest) Execute() (*BillingSubscription, *http.Response, error) {
return r.ApiService.ResizeSubscriptionExecute(r)
}
/*
ResizeSubscription Change a team's seats
Changes a team's seats: how many standard and premium seats its next period
opens at.
`quantity` is the subscription's own seat type, 0 to keep it, and `lines` each
other seat type: `{"lines":[{"planId":"team-premium","quantity":1}]}` adds a
premium seat to a team bought with standard ones. The renewal that opens the
next period charges the seats asked for, and the period in hand keeps the ones
it was paid for, so nothing is charged now. A team is at least 2 seats and at
most 100 across every seat type; past either, or naming a plan that is not a
seat type of the team, is 400 and nothing changes.
The team's seats are its admins' to change, and the platform's. A member is
refused with 403 and told to ask an admin. A subscription from another org, or
held by a wallet the caller may not change, is not found.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return BillingAPIResizeSubscriptionRequest
*/
func (a *BillingAPIService) ResizeSubscription(ctx context.Context, id string) BillingAPIResizeSubscriptionRequest {
return BillingAPIResizeSubscriptionRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingSubscription
func (a *BillingAPIService) ResizeSubscriptionExecute(r BillingAPIResizeSubscriptionRequest) (*BillingSubscription, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingSubscription
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.ResizeSubscription")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/subscriptions/{id}/resize"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingResize == nil {
return localVarReturnValue, nil, reportError("billingResize is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingResize
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BillingAPIVoidInvoiceRequest struct {
ctx context.Context
ApiService *BillingAPIService
id string
billingInvoiceRef *BillingInvoiceRef
}
func (r BillingAPIVoidInvoiceRequest) BillingInvoiceRef(billingInvoiceRef BillingInvoiceRef) BillingAPIVoidInvoiceRequest {
r.billingInvoiceRef = &billingInvoiceRef
return r
}
func (r BillingAPIVoidInvoiceRequest) Execute() (*BillingInvoice, *http.Response, error) {
return r.ApiService.VoidInvoiceExecute(r)
}
/*
VoidInvoice Void a draft or issued invoice
Voids a draft or issued invoice — the cancel. It is the org admin's act; a
member is refused 403.
A paid invoice cannot be voided: money has moved, and the correction for that
is a refund, not an erasure. The state machine refuses it and that refusal is
the answer.
A named handler, not a closure, so zipdoc can lift this prose into the registry.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id ID is the invoice id.
@return BillingAPIVoidInvoiceRequest
*/
func (a *BillingAPIService) VoidInvoice(ctx context.Context, id string) BillingAPIVoidInvoiceRequest {
return BillingAPIVoidInvoiceRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return BillingInvoice
func (a *BillingAPIService) VoidInvoiceExecute(r BillingAPIVoidInvoiceRequest) (*BillingInvoice, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BillingInvoice
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BillingAPIService.VoidInvoice")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/billing/invoices/{id}/void"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.billingInvoiceRef == nil {
return localVarReturnValue, nil, reportError("billingInvoiceRef is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.billingInvoiceRef
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}