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

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

// New creates a new company product proposals 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 company product proposals 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 company product proposals 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 {

	// GetCompanyProductProposal get a company product proposal.
	GetCompanyProductProposal(params *GetCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalOK, error)

	// GetCompanyProductProposalContext get a company product proposal.
	GetCompanyProductProposalContext(ctx context.Context, params *GetCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalOK, error)

	// GetCompanyProductProposals list company product proposals.
	GetCompanyProductProposals(params *GetCompanyProductProposalsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalsOK, error)

	// GetCompanyProductProposalsContext list company product proposals.
	GetCompanyProductProposalsContext(ctx context.Context, params *GetCompanyProductProposalsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalsOK, error)

	// PostCompanyProductProposal create a company product draft proposal.
	PostCompanyProductProposal(params *PostCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostCompanyProductProposalCreated, error)

	// PostCompanyProductProposalContext create a company product draft proposal.
	PostCompanyProductProposalContext(ctx context.Context, params *PostCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostCompanyProductProposalCreated, error)

	// ReviewCompanyProductProposal review a company product proposal.
	ReviewCompanyProductProposal(params *ReviewCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ReviewCompanyProductProposalOK, error)

	// ReviewCompanyProductProposalContext review a company product proposal.
	ReviewCompanyProductProposalContext(ctx context.Context, params *ReviewCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ReviewCompanyProductProposalOK, error)

	// SubmitCompanyProductProposal submit a company product proposal.
	SubmitCompanyProductProposal(params *SubmitCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SubmitCompanyProductProposalOK, error)

	// SubmitCompanyProductProposalContext submit a company product proposal.
	SubmitCompanyProductProposalContext(ctx context.Context, params *SubmitCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SubmitCompanyProductProposalOK, error)

	SetTransport(transport runtime.ContextualTransport)
}

// GetCompanyProductProposal gets a company product proposal.
//
// Return one visible CompanyProduct proposal.
//
// 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.GetCompanyProductProposalContext] instead.
func (a *Client) GetCompanyProductProposal(params *GetCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// GetCompanyProductProposalContext gets a company product proposal.
//
// Return one visible CompanyProduct proposal.
//
// Do not use the deprecated [GetCompanyProductProposalParams.Context] with this method: it would be ignored.
func (a *Client) GetCompanyProductProposalContext(ctx context.Context, params *GetCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetCompanyProductProposalParams()
	}

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

// GetCompanyProductProposals lists company product proposals.
//
// Return actor-owned proposals or the submitted tenant review queue.
//
// 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.GetCompanyProductProposalsContext] instead.
func (a *Client) GetCompanyProductProposals(params *GetCompanyProductProposalsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalsOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// GetCompanyProductProposalsContext lists company product proposals.
//
// Return actor-owned proposals or the submitted tenant review queue.
//
// Do not use the deprecated [GetCompanyProductProposalsParams.Context] with this method: it would be ignored.
func (a *Client) GetCompanyProductProposalsContext(ctx context.Context, params *GetCompanyProductProposalsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetCompanyProductProposalsOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewGetCompanyProductProposalsParams()
	}

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

// PostCompanyProductProposal creates a company product draft proposal.
//
// Create a draft proposal without changing the authoritative CompanyProduct.
//
// 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.PostCompanyProductProposalContext] instead.
func (a *Client) PostCompanyProductProposal(params *PostCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostCompanyProductProposalCreated, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// PostCompanyProductProposalContext creates a company product draft proposal.
//
// Create a draft proposal without changing the authoritative CompanyProduct.
//
// Do not use the deprecated [PostCompanyProductProposalParams.Context] with this method: it would be ignored.
func (a *Client) PostCompanyProductProposalContext(ctx context.Context, params *PostCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*PostCompanyProductProposalCreated, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewPostCompanyProductProposalParams()
	}

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

// ReviewCompanyProductProposal reviews a company product proposal.
//
// Decide every field on a submitted proposal without changing the authoritative CompanyProduct.
//
// 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.ReviewCompanyProductProposalContext] instead.
func (a *Client) ReviewCompanyProductProposal(params *ReviewCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ReviewCompanyProductProposalOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// ReviewCompanyProductProposalContext reviews a company product proposal.
//
// Decide every field on a submitted proposal without changing the authoritative CompanyProduct.
//
// Do not use the deprecated [ReviewCompanyProductProposalParams.Context] with this method: it would be ignored.
func (a *Client) ReviewCompanyProductProposalContext(ctx context.Context, params *ReviewCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ReviewCompanyProductProposalOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewReviewCompanyProductProposalParams()
	}

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

// SubmitCompanyProductProposal submits a company product proposal.
//
// Submit an actor-owned draft without changing the authoritative CompanyProduct.
//
// 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.SubmitCompanyProductProposalContext] instead.
func (a *Client) SubmitCompanyProductProposal(params *SubmitCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SubmitCompanyProductProposalOK, error) {
	var ctx context.Context
	if params.inner.ctx != nil {
		ctx = params.inner.ctx
	} else {
		ctx = context.Background()
	}

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

// SubmitCompanyProductProposalContext submits a company product proposal.
//
// Submit an actor-owned draft without changing the authoritative CompanyProduct.
//
// Do not use the deprecated [SubmitCompanyProductProposalParams.Context] with this method: it would be ignored.
func (a *Client) SubmitCompanyProductProposalContext(ctx context.Context, params *SubmitCompanyProductProposalParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*SubmitCompanyProductProposalOK, error) {
	// NOTE: parameters are not validated before sending
	if params == nil {
		params = NewSubmitCompanyProductProposalParams()
	}

	op := &runtime.ClientOperation{
		ID:                 "submitCompanyProductProposal",
		Method:             "POST",
		PathPattern:        "/companyproductproposals/{companyProductProposalId}/submit",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &SubmitCompanyProductProposalReader{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.(*SubmitCompanyProductProposalOK)
	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 submitCompanyProductProposal: 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 [CompanyProductProposalsParams].
	ctx context.Context
}
