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

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"fmt"

	"github.com/go-openapi/runtime"
	"github.com/go-openapi/strfmt"
)

// New creates a new invoices API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
	return &Client{transport: transport, formats: formats}
}

/*
Client for invoices API
*/
type Client struct {
	transport runtime.ClientTransport
	formats   strfmt.Registry
}

// ClientOption is the option for Client methods
type ClientOption func(*runtime.ClientOperation)

// ClientService is the interface for Client methods
type ClientService interface {
	CreateInvoice(params *CreateInvoiceParams, opts ...ClientOption) (*CreateInvoiceCreated, error)

	DeleteInvoice(params *DeleteInvoiceParams, opts ...ClientOption) (*DeleteInvoiceNoContent, error)

	GetInvoices(params *GetInvoicesParams, opts ...ClientOption) (*GetInvoicesOK, error)

	UpdateInvoice(params *UpdateInvoiceParams, opts ...ClientOption) (*UpdateInvoiceOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
CreateInvoice creates a new invoice
*/
func (a *Client) CreateInvoice(params *CreateInvoiceParams, opts ...ClientOption) (*CreateInvoiceCreated, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewCreateInvoiceParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "createInvoice",
		Method:             "POST",
		PathPattern:        "/invoices",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &CreateInvoiceReader{formats: a.formats},
		Context:            params.Context,
		Client:             params.HTTPClient,
	}
	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.Submit(op)
	if err != nil {
		return nil, err
	}
	success, ok := result.(*CreateInvoiceCreated)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for createInvoice: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
DeleteInvoice deletes a invoice
*/
func (a *Client) DeleteInvoice(params *DeleteInvoiceParams, opts ...ClientOption) (*DeleteInvoiceNoContent, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewDeleteInvoiceParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "deleteInvoice",
		Method:             "DELETE",
		PathPattern:        "/invoices",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &DeleteInvoiceReader{formats: a.formats},
		Context:            params.Context,
		Client:             params.HTTPClient,
	}
	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.Submit(op)
	if err != nil {
		return nil, err
	}
	success, ok := result.(*DeleteInvoiceNoContent)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for deleteInvoice: API contract not enforced by server. Client expected to get an error, but got: %T", result)
	panic(msg)
}

/*
GetInvoices gets a list of invoices
*/
func (a *Client) GetInvoices(params *GetInvoicesParams, opts ...ClientOption) (*GetInvoicesOK, error) {
	// TODO: Validate the params 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},
		Context:            params.Context,
		Client:             params.HTTPClient,
	}
	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.Submit(op)
	if err != nil {
		return nil, err
	}
	success, ok := result.(*GetInvoicesOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent 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)
}

/*
UpdateInvoice updates an existing invoice
*/
func (a *Client) UpdateInvoice(params *UpdateInvoiceParams, opts ...ClientOption) (*UpdateInvoiceOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewUpdateInvoiceParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "updateInvoice",
		Method:             "PUT",
		PathPattern:        "/invoices",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &UpdateInvoiceReader{formats: a.formats},
		Context:            params.Context,
		Client:             params.HTTPClient,
	}
	for _, opt := range opts {
		opt(op)
	}

	result, err := a.transport.Submit(op)
	if err != nil {
		return nil, err
	}
	success, ok := result.(*UpdateInvoiceOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
	msg := fmt.Sprintf("unexpected success response for updateInvoice: 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.ClientTransport) {
	a.transport = transport
}
