github.com/circl-dev/go-swagger@v0.31.0/examples/authentication/client/customers/customers_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package customers
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"github.com/go-openapi/strfmt"
    10  	"github.com/circl-dev/runtime"
    11  )
    12  
    13  // New creates a new customers API client.
    14  func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService {
    15  	return &Client{transport: transport, formats: formats}
    16  }
    17  
    18  /*
    19  Client for customers API
    20  */
    21  type Client struct {
    22  	transport runtime.ClientTransport
    23  	formats   strfmt.Registry
    24  }
    25  
    26  // ClientOption is the option for Client methods
    27  type ClientOption func(*runtime.ClientOperation)
    28  
    29  // ClientService is the interface for Client methods
    30  type ClientService interface {
    31  	Create(params *CreateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateCreated, error)
    32  
    33  	GetID(params *GetIDParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetIDOK, error)
    34  
    35  	SetTransport(transport runtime.ClientTransport)
    36  }
    37  
    38  /*
    39    Create creates a new customer to track
    40  */
    41  func (a *Client) Create(params *CreateParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateCreated, error) {
    42  	// TODO: Validate the params before sending
    43  	if params == nil {
    44  		params = NewCreateParams()
    45  	}
    46  	op := &runtime.ClientOperation{
    47  		ID:                 "create",
    48  		Method:             "POST",
    49  		PathPattern:        "/customers",
    50  		ProducesMediaTypes: []string{"application/keyauth.api.v1+json"},
    51  		ConsumesMediaTypes: []string{"application/keyauth.api.v1+json"},
    52  		Schemes:            []string{"http"},
    53  		Params:             params,
    54  		Reader:             &CreateReader{formats: a.formats},
    55  		AuthInfo:           authInfo,
    56  		Context:            params.Context,
    57  		Client:             params.HTTPClient,
    58  	}
    59  	for _, opt := range opts {
    60  		opt(op)
    61  	}
    62  
    63  	result, err := a.transport.Submit(op)
    64  	if err != nil {
    65  		return nil, err
    66  	}
    67  	success, ok := result.(*CreateCreated)
    68  	if ok {
    69  		return success, nil
    70  	}
    71  	// unexpected success response
    72  	unexpectedSuccess := result.(*CreateDefault)
    73  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
    74  }
    75  
    76  /*
    77    GetID gets a customer Id given an s s n
    78  */
    79  func (a *Client) GetID(params *GetIDParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetIDOK, error) {
    80  	// TODO: Validate the params before sending
    81  	if params == nil {
    82  		params = NewGetIDParams()
    83  	}
    84  	op := &runtime.ClientOperation{
    85  		ID:                 "getId",
    86  		Method:             "GET",
    87  		PathPattern:        "/customers",
    88  		ProducesMediaTypes: []string{"application/keyauth.api.v1+json"},
    89  		ConsumesMediaTypes: []string{"application/keyauth.api.v1+json"},
    90  		Schemes:            []string{"http"},
    91  		Params:             params,
    92  		Reader:             &GetIDReader{formats: a.formats},
    93  		AuthInfo:           authInfo,
    94  		Context:            params.Context,
    95  		Client:             params.HTTPClient,
    96  	}
    97  	for _, opt := range opts {
    98  		opt(op)
    99  	}
   100  
   101  	result, err := a.transport.Submit(op)
   102  	if err != nil {
   103  		return nil, err
   104  	}
   105  	success, ok := result.(*GetIDOK)
   106  	if ok {
   107  		return success, nil
   108  	}
   109  	// unexpected success response
   110  	unexpectedSuccess := result.(*GetIDDefault)
   111  	return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
   112  }
   113  
   114  // SetTransport changes the transport on the client
   115  func (a *Client) SetTransport(transport runtime.ClientTransport) {
   116  	a.transport = transport
   117  }