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

package issuer_service

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

/*
Client for issuer service 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 {
	GetIssuerWellKnown(params *GetIssuerWellKnownParams, opts ...ClientOption) (*GetIssuerWellKnownOK, error)

	RegisterIssuer(params *RegisterIssuerParams, opts ...ClientOption) (*RegisterIssuerOK, error)

	SetTransport(transport runtime.ClientTransport)
}

/*
GetIssuerWellKnown returns the well known document for an issuer in Json web key set j w k s format
*/
func (a *Client) GetIssuerWellKnown(params *GetIssuerWellKnownParams, opts ...ClientOption) (*GetIssuerWellKnownOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetIssuerWellKnownParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "GetIssuerWellKnown",
		Method:             "GET",
		PathPattern:        "/v1alpha1/issuer/{commonName}/.well-known/jwks.json",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &GetIssuerWellKnownReader{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.(*GetIssuerWellKnownOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*GetIssuerWellKnownDefault)
	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
}

/*
RegisterIssuer registers an issuer by providing the issuer details
*/
func (a *Client) RegisterIssuer(params *RegisterIssuerParams, opts ...ClientOption) (*RegisterIssuerOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewRegisterIssuerParams()
	}
	op := &runtime.ClientOperation{
		ID:                 "RegisterIssuer",
		Method:             "POST",
		PathPattern:        "/v1alpha1/issuer/register",
		ProducesMediaTypes: []string{"application/json"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http"},
		Params:             params,
		Reader:             &RegisterIssuerReader{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.(*RegisterIssuerOK)
	if ok {
		return success, nil
	}
	// unexpected success response
	unexpectedSuccess := result.(*RegisterIssuerDefault)
	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
}
