// Code generated by go-swagger; DO NOT EDIT.

package todos

import (
	"context"

	"github.com/go-openapi/runtime"

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

//go:generate mockery --name API --keeptree --with-expecter --case underscore

// API is the interface of the todos client
type API interface {
	/*
	   AddOne add one API*/
	AddOne(ctx context.Context, params *AddOneParams) (*AddOneCreated, *AddOneNoContent, error)
	/*
	   DestroyOne destroy one API*/
	DestroyOne(ctx context.Context, params *DestroyOneParams) (*DestroyOneNoContent, error)
	/*
	   Find find API*/
	Find(ctx context.Context, params *FindParams) (*FindOK, error)
	/*
	   UpdateOne update one API*/
	UpdateOne(ctx context.Context, params *UpdateOneParams) (*UpdateOneOK, *UpdateOneNoContent, error)
}

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

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

/*
AddOne add one API
*/
func (a *Client) AddOne(ctx context.Context, params *AddOneParams) (*AddOneCreated, *AddOneNoContent, error) {
	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "addOne",
		Method:             "POST",
		PathPattern:        "/",
		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &AddOneReader{formats: a.formats},
		AuthInfo:           a.authInfo,
		Context:            ctx,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, nil, err
	}

	switch value := result.(type) {
	case *AddOneCreated:
		return value, nil, nil
	case *AddOneNoContent:
		return nil, value, nil
	}

	// unexpected response.
	//
	// a default response is provided: fill this and return an error
	unexpectedSuccess := result.(*AddOneDefault)

	return nil, nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
DestroyOne destroy one API
*/
func (a *Client) DestroyOne(ctx context.Context, params *DestroyOneParams) (*DestroyOneNoContent, error) {
	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "destroyOne",
		Method:             "DELETE",
		PathPattern:        "/{id}",
		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &DestroyOneReader{formats: a.formats},
		AuthInfo:           a.authInfo,
		Context:            ctx,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	if value, ok := result.(*DestroyOneNoContent); ok {
		return value, nil
	}

	// unexpected response.
	//
	// a default response is provided: fill this and return an error
	unexpectedSuccess := result.(*DestroyOneDefault)

	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
Find find API
*/
func (a *Client) Find(ctx context.Context, params *FindParams) (*FindOK, error) {
	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "find",
		Method:             "GET",
		PathPattern:        "/",
		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &FindReader{formats: a.formats},
		AuthInfo:           a.authInfo,
		Context:            ctx,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	if value, ok := result.(*FindOK); ok {
		return value, nil
	}

	// unexpected response.
	//
	// a default response is provided: fill this and return an error
	unexpectedSuccess := result.(*FindDefault)

	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
UpdateOne update one API
*/
func (a *Client) UpdateOne(ctx context.Context, params *UpdateOneParams) (*UpdateOneOK, *UpdateOneNoContent, error) {
	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "updateOne",
		Method:             "PUT",
		PathPattern:        "/{id}",
		ProducesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		ConsumesMediaTypes: []string{"application/io.swagger.examples.todo-list.v1+json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &UpdateOneReader{formats: a.formats},
		AuthInfo:           a.authInfo,
		Context:            ctx,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, nil, err
	}

	switch value := result.(type) {
	case *UpdateOneOK:
		return value, nil, nil
	case *UpdateOneNoContent:
		return nil, value, nil
	}

	// unexpected response.
	//
	// a default response is provided: fill this and return an error
	unexpectedSuccess := result.(*UpdateOneDefault)

	return nil, nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}
