diff --git a/client.gen.go b/client.gen.go index 6c1f6be..bd58277 100644 --- a/client.gen.go +++ b/client.gen.go @@ -271,6 +271,9 @@ type ClientInterface interface { // CancelTeamInvitation request CancelTeamInvitation(ctx context.Context, teamName TeamName, email Email, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListInvoicesByTeam request + ListInvoicesByTeam(ctx context.Context, teamName TeamName, params *ListInvoicesByTeamParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetTeamMemberships request GetTeamMemberships(ctx context.Context, teamName TeamName, params *GetTeamMembershipsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1149,6 +1152,18 @@ func (c *Client) CancelTeamInvitation(ctx context.Context, teamName TeamName, em return c.Client.Do(req) } +func (c *Client) ListInvoicesByTeam(ctx context.Context, teamName TeamName, params *ListInvoicesByTeamParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListInvoicesByTeamRequest(c.Server, teamName, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) GetTeamMemberships(ctx context.Context, teamName TeamName, params *GetTeamMembershipsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetTeamMembershipsRequest(c.Server, teamName, params) if err != nil { @@ -4442,6 +4457,78 @@ func NewCancelTeamInvitationRequest(server string, teamName TeamName, email Emai return req, nil } +// NewListInvoicesByTeamRequest generates requests for ListInvoicesByTeam +func NewListInvoicesByTeamRequest(server string, teamName TeamName, params *ListInvoicesByTeamParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "team_name", runtime.ParamLocationPath, teamName) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/teams/%s/invoices", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Page != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "page", runtime.ParamLocationQuery, *params.Page); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.PerPage != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "per_page", runtime.ParamLocationQuery, *params.PerPage); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewGetTeamMembershipsRequest generates requests for GetTeamMemberships func NewGetTeamMembershipsRequest(server string, teamName TeamName, params *GetTeamMembershipsParams) (*http.Request, error) { var err error @@ -5872,6 +5959,9 @@ type ClientWithResponsesInterface interface { // CancelTeamInvitationWithResponse request CancelTeamInvitationWithResponse(ctx context.Context, teamName TeamName, email Email, reqEditors ...RequestEditorFn) (*CancelTeamInvitationResponse, error) + // ListInvoicesByTeamWithResponse request + ListInvoicesByTeamWithResponse(ctx context.Context, teamName TeamName, params *ListInvoicesByTeamParams, reqEditors ...RequestEditorFn) (*ListInvoicesByTeamResponse, error) + // GetTeamMembershipsWithResponse request GetTeamMembershipsWithResponse(ctx context.Context, teamName TeamName, params *GetTeamMembershipsParams, reqEditors ...RequestEditorFn) (*GetTeamMembershipsResponse, error) @@ -7229,6 +7319,35 @@ func (r CancelTeamInvitationResponse) StatusCode() int { return 0 } +type ListInvoicesByTeamResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Items []Invoice `json:"items"` + Metadata ListMetadata `json:"metadata"` + } + JSON401 *RequiresAuthentication + JSON403 *Forbidden + JSON404 *NotFound + JSON500 *InternalError +} + +// Status returns HTTPResponse.Status +func (r ListInvoicesByTeamResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListInvoicesByTeamResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type GetTeamMembershipsResponse struct { Body []byte HTTPResponse *http.Response @@ -8382,6 +8501,15 @@ func (c *ClientWithResponses) CancelTeamInvitationWithResponse(ctx context.Conte return ParseCancelTeamInvitationResponse(rsp) } +// ListInvoicesByTeamWithResponse request returning *ListInvoicesByTeamResponse +func (c *ClientWithResponses) ListInvoicesByTeamWithResponse(ctx context.Context, teamName TeamName, params *ListInvoicesByTeamParams, reqEditors ...RequestEditorFn) (*ListInvoicesByTeamResponse, error) { + rsp, err := c.ListInvoicesByTeam(ctx, teamName, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListInvoicesByTeamResponse(rsp) +} + // GetTeamMembershipsWithResponse request returning *GetTeamMembershipsResponse func (c *ClientWithResponses) GetTeamMembershipsWithResponse(ctx context.Context, teamName TeamName, params *GetTeamMembershipsParams, reqEditors ...RequestEditorFn) (*GetTeamMembershipsResponse, error) { rsp, err := c.GetTeamMemberships(ctx, teamName, params, reqEditors...) @@ -11211,6 +11339,63 @@ func ParseCancelTeamInvitationResponse(rsp *http.Response) (*CancelTeamInvitatio return response, nil } +// ParseListInvoicesByTeamResponse parses an HTTP response from a ListInvoicesByTeamWithResponse call +func ParseListInvoicesByTeamResponse(rsp *http.Response) (*ListInvoicesByTeamResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListInvoicesByTeamResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Items []Invoice `json:"items"` + Metadata ListMetadata `json:"metadata"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest RequiresAuthentication + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + // ParseGetTeamMembershipsResponse parses an HTTP response from a GetTeamMembershipsWithResponse call func ParseGetTeamMembershipsResponse(rsp *http.Response) (*GetTeamMembershipsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/models.gen.go b/models.gen.go index 260078e..c117718 100644 --- a/models.gen.go +++ b/models.gen.go @@ -466,6 +466,20 @@ type InvitationWithToken struct { Token openapi_types.UUID `json:"token"` } +// Invoice Invoice details +type Invoice struct { + // AmountDue Amount due in cents. This is the amount that will be charged, unless there are pending invoice items. If the invoice’s total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the amount_due may be 0. The charge that gets generated for the invoice will be for the amount specified in amount_due. + AmountDue int64 `json:"amount_due"` + CreatedAt time.Time `json:"created_at"` + Currency string `json:"currency"` + + // InvoicePdf The link to download the PDF for the invoice. + InvoicePDF string `json:"invoice_pdf"` + + // Paid Whether or not payment was successfully collected for this invoice. + Paid bool `json:"paid"` +} + // ListAddon defines model for ListAddon. type ListAddon struct { // AddonFormat Supported formats for addons @@ -1396,6 +1410,15 @@ type AcceptTeamInvitationJSONBody struct { Token openapi_types.UUID `json:"token"` } +// ListInvoicesByTeamParams defines parameters for ListInvoicesByTeam. +type ListInvoicesByTeamParams struct { + // Page Page number of the results to fetch + Page *Page `form:"page,omitempty" json:"page,omitempty"` + + // PerPage The number of results per page (max 1000). + PerPage *PerPage `form:"per_page,omitempty" json:"per_page,omitempty"` +} + // GetTeamMembershipsParams defines parameters for GetTeamMemberships. type GetTeamMembershipsParams struct { // Page Page number of the results to fetch diff --git a/spec.json b/spec.json index 1a571bb..19f9398 100644 --- a/spec.json +++ b/spec.json @@ -2848,6 +2848,64 @@ ] } }, + "/teams/{team_name}/invoices": { + "get": { + "description": "List all past invoices for the team.", + "operationId": "ListInvoicesByTeam", + "parameters": [ + { + "$ref": "#/components/parameters/team_name" + }, + { + "$ref": "#/components/parameters/page" + }, + { + "$ref": "#/components/parameters/per_page" + } + ], + "responses": { + "200": { + "description": "Response", + "content": { + "application/json": { + "schema": { + "required": [ + "items", + "metadata" + ], + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/Invoice" + }, + "type": "array" + }, + "metadata": { + "$ref": "#/components/schemas/ListMetadata" + } + } + } + } + } + }, + "401": { + "$ref": "#/components/responses/RequiresAuthentication" + }, + "403": { + "$ref": "#/components/responses/Forbidden" + }, + "404": { + "$ref": "#/components/responses/NotFound" + }, + "500": { + "$ref": "#/components/responses/InternalError" + } + }, + "tags": [ + "teams" + ] + } + }, "/teams/{team_name}/usage": { "get": { "description": "List plugin usage for the current calendar month.", @@ -5414,6 +5472,47 @@ } } }, + "Invoice": { + "additionalProperties": false, + "title": "Invoice", + "description": "Invoice details", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "example": "2017-07-14T16:53:42Z" + }, + "amount_due": { + "type": "integer", + "format": "int64", + "example": 1000, + "description": "Amount due in cents. This is the amount that will be charged, unless there are pending invoice items. If the invoice’s total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the amount_due may be 0. The charge that gets generated for the invoice will be for the amount specified in amount_due." + }, + "currency": { + "type": "string", + "example": "usd" + }, + "invoice_pdf": { + "type": "string", + "format": "uri", + "description": "The link to download the PDF for the invoice.", + "x-go-name": "InvoicePDF" + }, + "paid": { + "type": "boolean", + "example": true, + "description": "Whether or not payment was successfully collected for this invoice." + } + }, + "required": [ + "created_at", + "amount_due", + "currency", + "invoice_pdf", + "paid" + ], + "type": "object" + }, "UsageCurrent": { "title": "CloudQuery Plugin Usage", "description": "The usage of a plugin within the current calendar month.",