// 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 leads 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 leads API client. func New(transport runtime.ContextualTransport, formats strfmt.Registry) ClientService { return &Client{transport: transport, formats: formats} } // New creates a new leads 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 leads 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 leads 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 { // DeleteLead delete a contact. DeleteLead(params *DeleteLeadParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteLeadOK, error) // DeleteLeadContext delete a contact. DeleteLeadContext(ctx context.Context, params *DeleteLeadParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteLeadOK, error) // GetLeads get a list of contacts. GetLeads(params *GetLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetLeadsOK, error) // GetLeadsContext get a list of contacts. GetLeadsContext(ctx context.Context, params *GetLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetLeadsOK, error) // PostLeads add new leads. PostLeads(params *PostLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostLeadsOK, error) // PostLeadsContext add new leads. PostLeadsContext(ctx context.Context, params *PostLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostLeadsOK, error) // PutLeads update leads. PutLeads(params *PutLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutLeadsOK, error) // PutLeadsContext update leads. PutLeadsContext(ctx context.Context, params *PutLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutLeadsOK, error) SetTransport(transport runtime.ContextualTransport) } // DeleteLead deletes a contact. // // Delete SalesforceDevops.net Lead record. // // 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.DeleteLeadContext] instead. func (a *Client) DeleteLead(params *DeleteLeadParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteLeadOK, error) { var ctx context.Context if params.inner.ctx != nil { ctx = params.inner.ctx } else { ctx = context.Background() } return a.DeleteLeadContext(ctx, params, authInfo, opts...) } // DeleteLeadContext deletes a contact. // // Delete SalesforceDevops.net Lead record. // // Do not use the deprecated [DeleteLeadParams.Context] with this method: it would be ignored. func (a *Client) DeleteLeadContext(ctx context.Context, params *DeleteLeadParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteLeadOK, error) { // NOTE: parameters are not validated before sending if params == nil { params = NewDeleteLeadParams() } op := &runtime.ClientOperation{ ID: "deleteLead", Method: "DELETE", PathPattern: "/leads", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, Reader: &DeleteLeadReader{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.(*DeleteLeadOK) 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 deleteLead: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } // GetLeads gets a list of contacts. // // Return a list of all available Leads. // // 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.GetLeadsContext] instead. func (a *Client) GetLeads(params *GetLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetLeadsOK, error) { var ctx context.Context if params.inner.ctx != nil { ctx = params.inner.ctx } else { ctx = context.Background() } return a.GetLeadsContext(ctx, params, authInfo, opts...) } // GetLeadsContext gets a list of contacts. // // Return a list of all available Leads. // // Do not use the deprecated [GetLeadsParams.Context] with this method: it would be ignored. func (a *Client) GetLeadsContext(ctx context.Context, params *GetLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetLeadsOK, error) { // NOTE: parameters are not validated before sending if params == nil { params = NewGetLeadsParams() } op := &runtime.ClientOperation{ ID: "getLeads", Method: "GET", PathPattern: "/leads", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, Reader: &GetLeadsReader{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.(*GetLeadsOK) 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 getLeads: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } // PostLeads adds new leads. // // Lead records to be added. // // 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.PostLeadsContext] instead. func (a *Client) PostLeads(params *PostLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostLeadsOK, error) { var ctx context.Context if params.inner.ctx != nil { ctx = params.inner.ctx } else { ctx = context.Background() } return a.PostLeadsContext(ctx, params, authInfo, opts...) } // PostLeadsContext adds new leads. // // Lead records to be added. // // Do not use the deprecated [PostLeadsParams.Context] with this method: it would be ignored. func (a *Client) PostLeadsContext(ctx context.Context, params *PostLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostLeadsOK, error) { // NOTE: parameters are not validated before sending if params == nil { params = NewPostLeadsParams() } op := &runtime.ClientOperation{ ID: "postLeads", Method: "POST", PathPattern: "/leads", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, Reader: &PostLeadsReader{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.(*PostLeadsOK) 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 postLeads: API contract not enforced by server. Client expected to get an error, but got: %T", result) panic(msg) } // PutLeads updates leads. // // Update Lead records. // // 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.PutLeadsContext] instead. func (a *Client) PutLeads(params *PutLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutLeadsOK, error) { var ctx context.Context if params.inner.ctx != nil { ctx = params.inner.ctx } else { ctx = context.Background() } return a.PutLeadsContext(ctx, params, authInfo, opts...) } // PutLeadsContext updates leads. // // Update Lead records. // // Do not use the deprecated [PutLeadsParams.Context] with this method: it would be ignored. func (a *Client) PutLeadsContext(ctx context.Context, params *PutLeadsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PutLeadsOK, error) { // NOTE: parameters are not validated before sending if params == nil { params = NewPutLeadsParams() } op := &runtime.ClientOperation{ ID: "putLeads", Method: "PUT", PathPattern: "/leads", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, Params: params, Reader: &PutLeadsReader{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.(*PutLeadsOK) 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 putLeads: 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 [LeadsParams]. ctx context.Context }