// 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 emails

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 emails API client.
func New(transport runtime.ContextualTransport, formats strfmt.Registry) ClientService {
	return &Client{transport: transport, formats: formats}
}

// New creates a new emails 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 emails 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 emails 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 {

	// GetEmailMessages get email messages from data store.
	GetEmailMessages(params *GetEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEmailMessagesOK, error)

	// GetEmailMessagesContext get email messages from data store.
	GetEmailMessagesContext(ctx context.Context, params *GetEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEmailMessagesOK, error)

	// GetOutgoingEmailMessages get email messages from data store.
	GetOutgoingEmailMessages(params *GetOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOutgoingEmailMessagesOK, error)

	// GetOutgoingEmailMessagesContext get email messages from data store.
	GetOutgoingEmailMessagesContext(ctx context.Context, params *GetOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOutgoingEmailMessagesOK, error)

	// PostEmailMessages add new email messages to the outgoing queue.
	PostEmailMessages(params *PostEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostEmailMessagesOK, error)

	// PostEmailMessagesContext add new email messages to the outgoing queue.
	PostEmailMessagesContext(ctx context.Context, params *PostEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostEmailMessagesOK, error)

	// PostOutgoingEmailMessages add new email messages to the outgoing queue.
	PostOutgoingEmailMessages(params *PostOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostOutgoingEmailMessagesOK, error)

	// PostOutgoingEmailMessagesContext add new email messages to the outgoing queue.
	PostOutgoingEmailMessagesContext(ctx context.Context, params *PostOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostOutgoingEmailMessagesOK, error)

	SetTransport(transport runtime.ContextualTransport)
}

// GetEmailMessages gets email messages from data store.
//
// Retrieves email messages from workflow storage.
//
// 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.GetEmailMessagesContext] instead.
func (a *Client) GetEmailMessages(params *GetEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEmailMessagesOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.GetEmailMessagesContext(ctx, params, authInfo, opts...)
}

// GetEmailMessagesContext gets email messages from data store.
//
// Retrieves email messages from workflow storage.
//
// Do not use the deprecated [GetEmailMessagesParams.Context] with this method: it would be ignored.
func (a *Client) GetEmailMessagesContext(ctx context.Context, params *GetEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEmailMessagesOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetEmailMessagesParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "getEmailMessages",
		Method:             "GET",
		PathPattern:        "/emailmessages",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetEmailMessagesReader{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.(*GetEmailMessagesOK)
	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 getEmailMessages: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// GetOutgoingEmailMessages gets email messages from data store.
//
// Retrieves email messages from workflow storage.
//
// 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.GetOutgoingEmailMessagesContext] instead.
func (a *Client) GetOutgoingEmailMessages(params *GetOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOutgoingEmailMessagesOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.GetOutgoingEmailMessagesContext(ctx, params, authInfo, opts...)
}

// GetOutgoingEmailMessagesContext gets email messages from data store.
//
// Retrieves email messages from workflow storage.
//
// Do not use the deprecated [GetOutgoingEmailMessagesParams.Context] with this method: it would be ignored.
func (a *Client) GetOutgoingEmailMessagesContext(ctx context.Context, params *GetOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOutgoingEmailMessagesOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetOutgoingEmailMessagesParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "getOutgoingEmailMessages",
		Method:             "GET",
		PathPattern:        "/outgoingemailmessages",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetOutgoingEmailMessagesReader{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.(*GetOutgoingEmailMessagesOK)
	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 getOutgoingEmailMessages: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PostEmailMessages adds new email messages to the outgoing queue.
//
// Insert new email messages into workflow storage.
//
// 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.PostEmailMessagesContext] instead.
func (a *Client) PostEmailMessages(params *PostEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostEmailMessagesOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.PostEmailMessagesContext(ctx, params, authInfo, opts...)
}

// PostEmailMessagesContext adds new email messages to the outgoing queue.
//
// Insert new email messages into workflow storage.
//
// Do not use the deprecated [PostEmailMessagesParams.Context] with this method: it would be ignored.
func (a *Client) PostEmailMessagesContext(ctx context.Context, params *PostEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostEmailMessagesOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPostEmailMessagesParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "postEmailMessages",
		Method:             "POST",
		PathPattern:        "/emailmessages",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PostEmailMessagesReader{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.(*PostEmailMessagesOK)
	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 postEmailMessages: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

// PostOutgoingEmailMessages adds new email messages to the outgoing queue.
//
// Insert new email messages into workflow storage.
//
// 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.PostOutgoingEmailMessagesContext] instead.
func (a *Client) PostOutgoingEmailMessages(params *PostOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostOutgoingEmailMessagesOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

	return a.PostOutgoingEmailMessagesContext(ctx, params, authInfo, opts...)
}

// PostOutgoingEmailMessagesContext adds new email messages to the outgoing queue.
//
// Insert new email messages into workflow storage.
//
// Do not use the deprecated [PostOutgoingEmailMessagesParams.Context] with this method: it would be ignored.
func (a *Client) PostOutgoingEmailMessagesContext(ctx context.Context, params *PostOutgoingEmailMessagesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostOutgoingEmailMessagesOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPostOutgoingEmailMessagesParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "postOutgoingEmailMessages",
		Method:             "POST",
		PathPattern:        "/outgoingemailmessages",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &PostOutgoingEmailMessagesReader{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.(*PostOutgoingEmailMessagesOK)
	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 postOutgoingEmailMessages: 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 [EmailsParams].
	ctx context.Context
}
