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

package device

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

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

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

/*
Client for device API
*/
type Client struct {
	transport runtime.ClientTransport
	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 {
	AddDevice(params *AddDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AddDeviceOK, error)

	DeleteDevice(params *DeleteDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteDeviceOK, error)

	ListDevices(params *ListDevicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListDevicesOK, error)

	RegisterDevice(params *RegisterDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RegisterDeviceOK, error)

	TestDevice(params *TestDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TestDeviceOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
AddDevice adds new device for approval flow
*/
func (a *Client) AddDevice(params *AddDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AddDeviceOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewAddDeviceParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "AddDevice",
		Method:             "POST",
		PathPattern:        "/v1alpha1/device",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &AddDeviceReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*AddDeviceOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*AddDeviceDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
DeleteDevice deletes a registered device
*/
func (a *Client) DeleteDevice(params *DeleteDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteDeviceOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewDeleteDeviceParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "DeleteDevice",
		Method:             "DELETE",
		PathPattern:        "/v1alpha1/device/{deviceId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &DeleteDeviceReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*DeleteDeviceOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*DeleteDeviceDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
ListDevices lists all registered devices
*/
func (a *Client) ListDevices(params *ListDevicesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListDevicesOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewListDevicesParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "ListDevices",
		Method:             "GET",
		PathPattern:        "/v1alpha1/device",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &ListDevicesReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*ListDevicesOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*ListDevicesDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
RegisterDevice registers device for approval flow
*/
func (a *Client) RegisterDevice(params *RegisterDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*RegisterDeviceOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewRegisterDeviceParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "RegisterDevice",
		Method:             "POST",
		PathPattern:        "/v1alpha1/device/{deviceId}",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &RegisterDeviceReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*RegisterDeviceOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*RegisterDeviceDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
TestDevice sends a test notification to a registered device to see if it s well configured
*/
func (a *Client) TestDevice(params *TestDeviceParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TestDeviceOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewTestDeviceParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "TestDevice",
		Method:             "POST",
		PathPattern:        "/v1alpha1/device/{deviceId}/test",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &TestDeviceReader{formats: a.formats},
		AuthInfo:           authInfo,
		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.(*TestDeviceOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*TestDeviceDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
	a.transport = transport
}
