// Code generated by go-swagger; DO NOT EDIT. // (c) 2012-2020 by Taxnexus, Inc. // All rights reserved worldwide. // Proprietary product; unlicensed use is not allowed package invoices import ( "context" "fmt" "time" "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" ) // New creates a new invoices API client. func New(transport runtime.ContextualTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } // New creates a new invoices API client with basic auth credentials. // // It takes the following parameters: // - host: http host (github.com). // - basePath: any base path for the API client ("/v1", "/v3"). // - scheme: http scheme ("http", "https"). // - user: user for basic authentication header. // - password: password for basic authentication header. func NewClientWithBasicAuth(host, basePath, scheme, user, password string) ClientService { transport := httptransport.New(host, basePath, []string{scheme}) transport.DefaultAuthentication = httptransport.BasicAuth(user, password) return &Client{transport: transport, formats: strfmt.Default} } // New creates a new invoices API client with a bearer token for authentication. // // It takes the following parameters: // - host: http host (github.com). // - basePath: any base path for the API client ("/v1", "/v3"). // - scheme: http scheme ("http", "https"). // - bearerToken: bearer token for Bearer authentication header. func NewClientWithBearerToken(host, basePath, scheme, bearerToken string) ClientService { transport := httptransport.New(host, basePath, []string{scheme}) transport.DefaultAuthentication = httptransport.BearerToken(bearerToken) return &Client{transport: transport, formats: strfmt.Default} } // Client for invoices API. type Client struct { transport runtime.ContextualTransport formats strfmt.Registry } // ClientOption may be used to customize the behavior of Client methods. type ClientOption func(*runtime.ClientOperation) // ClientService is the interface for Client methods. type ClientService interface { // GetInvoices get a list invoices. GetInvoices(params *GetInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInvoicesOK, error) // GetInvoicesContext get a list invoices. GetInvoicesContext(ctx context.Context, params *GetInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInvoicesOK, error) // PostInvoices create new invoices. PostInvoices(params *PostInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostInvoicesOK, error) // PostInvoicesContext create new invoices. PostInvoicesContext(ctx context.Context, params *PostInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostInvoicesOK, error) // PutInvoices update invoice. PutInvoices(params *PutInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutInvoicesOK, error) // PutInvoicesContext update invoice. PutInvoicesContext(ctx context.Context, params *PutInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutInvoicesOK, error) SetTransport(transport runtime.ContextualTransport) } // GetInvoices gets a list invoices. // // Return a list of Invoice records from the datastore. // // This method does not support injected context. // However, timeout and opentracing contexts are honored whenever enabled. // // If you need to pass a specific context, use [Client.GetInvoicesContext] instead. func (a *Client) GetInvoices(params *GetInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInvoicesOK, error) { var ctx context.Context if params.inner.ctx != nil { ctx = params.inner.ctx } else { ctx = context.Background() } return a.GetInvoicesContext(ctx, params, authInfo, opts...) } // GetInvoicesContext gets a list invoices. // // Return a list of Invoice records from the datastore. // // Do not use the deprecated [GetInvoicesParams.Context] with this method: it would be ignored. func (a *Client) GetInvoicesContext(ctx context.Context, params *GetInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetInvoicesOK, error) { // NOTE: parameters are not validated before sending if params == nil { params = NewGetInvoicesParams() } op := &runtime.ClientOperation{ ID: "getInvoices", Method: "GET", PathPattern: "/invoices", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, Reader: &GetInvoicesReader{formats: a.formats}, AuthInfo: authInfo, Client: params.HTTPClient, } for _, opt := range opts { opt(op) } result, err := a.transport.SubmitContext(ctx, op) if err != nil { return nil, err } // only one success response has to be checked success, ok := result.(*GetInvoicesOK) if ok { return success, nil } // unexpected success response. // no default response is defined. // // safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue msg := fmt.Sprintf("unexpected success response for getInvoices: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } // PostInvoices creates new invoices. // // Create Invoices. // // This method does not support injected context. // However, timeout and opentracing contexts are honored whenever enabled. // // If you need to pass a specific context, use [Client.PostInvoicesContext] instead. func (a *Client) PostInvoices(params *PostInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostInvoicesOK, error) { var ctx context.Context if params.inner.ctx != nil { ctx = params.inner.ctx } else { ctx = context.Background() } return a.PostInvoicesContext(ctx, params, authInfo, opts...) } // PostInvoicesContext creates new invoices. // // Create Invoices. // // Do not use the deprecated [PostInvoicesParams.Context] with this method: it would be ignored. func (a *Client) PostInvoicesContext(ctx context.Context, params *PostInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostInvoicesOK, error) { // NOTE: parameters are not validated before sending if params == nil { params = NewPostInvoicesParams() } op := &runtime.ClientOperation{ ID: "postInvoices", Method: "POST", PathPattern: "/invoices", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, Reader: &PostInvoicesReader{formats: a.formats}, AuthInfo: authInfo, Client: params.HTTPClient, } for _, opt := range opts { opt(op) } result, err := a.transport.SubmitContext(ctx, op) if err != nil { return nil, err } // only one success response has to be checked success, ok := result.(*PostInvoicesOK) if ok { return success, nil } // unexpected success response. // no default response is defined. // // safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue msg := fmt.Sprintf("unexpected success response for postInvoices: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } // PutInvoices updates invoice. // // Update Invoice. // // This method does not support injected context. // However, timeout and opentracing contexts are honored whenever enabled. // // If you need to pass a specific context, use [Client.PutInvoicesContext] instead. func (a *Client) PutInvoices(params *PutInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutInvoicesOK, error) { var ctx context.Context if params.inner.ctx != nil { ctx = params.inner.ctx } else { ctx = context.Background() } return a.PutInvoicesContext(ctx, params, authInfo, opts...) } // PutInvoicesContext updates invoice. // // Update Invoice. // // Do not use the deprecated [PutInvoicesParams.Context] with this method: it would be ignored. func (a *Client) PutInvoicesContext(ctx context.Context, params *PutInvoicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutInvoicesOK, error) { // NOTE: parameters are not validated before sending if params == nil { params = NewPutInvoicesParams() } op := &runtime.ClientOperation{ ID: "putInvoices", Method: "PUT", PathPattern: "/invoices", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, Reader: &PutInvoicesReader{formats: a.formats}, AuthInfo: authInfo, Client: params.HTTPClient, } for _, opt := range opts { opt(op) } result, err := a.transport.SubmitContext(ctx, op) if err != nil { return nil, err } // only one success response has to be checked success, ok := result.(*PutInvoicesOK) if ok { return success, nil } // unexpected success response. // no default response is defined. // // safeguard: normally, in the absence of a default response, unknown success responses return an error above: so this is a codegen issue msg := fmt.Sprintf("unexpected success response for putInvoices: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ContextualTransport) { a.transport = transport } // innerParams captures internal fields so they don't conflict with user-supplied parameters. type innerParams struct { timeout time.Duration // Deprecated: use the operation call with context to pass the context instead of [InvoicesParams]. ctx context.Context }