github.com/emreu/go-swagger@v0.22.1/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/runtime" 10 11 strfmt "github.com/go-openapi/strfmt" 12 ) 13 14 // New creates a new customers API client. 15 func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { 16 return &Client{transport: transport, formats: formats} 17 } 18 19 /* 20 Client for customers API 21 */ 22 type Client struct { 23 transport runtime.ClientTransport 24 formats strfmt.Registry 25 } 26 27 /* 28 Create creates a new customer to track 29 */ 30 func (a *Client) Create(params *CreateParams, authInfo runtime.ClientAuthInfoWriter) (*CreateCreated, error) { 31 // TODO: Validate the params before sending 32 if params == nil { 33 params = NewCreateParams() 34 } 35 36 result, err := a.transport.Submit(&runtime.ClientOperation{ 37 ID: "create", 38 Method: "POST", 39 PathPattern: "/customers", 40 ProducesMediaTypes: []string{"application/keyauth.api.v1+json"}, 41 ConsumesMediaTypes: []string{"application/keyauth.api.v1+json"}, 42 Schemes: []string{"http"}, 43 Params: params, 44 Reader: &CreateReader{formats: a.formats}, 45 AuthInfo: authInfo, 46 Context: params.Context, 47 Client: params.HTTPClient, 48 }) 49 if err != nil { 50 return nil, err 51 } 52 success, ok := result.(*CreateCreated) 53 if ok { 54 return success, nil 55 } 56 // unexpected success response 57 unexpectedSuccess := result.(*CreateDefault) 58 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 59 } 60 61 /* 62 GetID gets a customer Id given an s s n 63 */ 64 func (a *Client) GetID(params *GetIDParams, authInfo runtime.ClientAuthInfoWriter) (*GetIDOK, error) { 65 // TODO: Validate the params before sending 66 if params == nil { 67 params = NewGetIDParams() 68 } 69 70 result, err := a.transport.Submit(&runtime.ClientOperation{ 71 ID: "getId", 72 Method: "GET", 73 PathPattern: "/customers", 74 ProducesMediaTypes: []string{"application/keyauth.api.v1+json"}, 75 ConsumesMediaTypes: []string{"application/keyauth.api.v1+json"}, 76 Schemes: []string{"http"}, 77 Params: params, 78 Reader: &GetIDReader{formats: a.formats}, 79 AuthInfo: authInfo, 80 Context: params.Context, 81 Client: params.HTTPClient, 82 }) 83 if err != nil { 84 return nil, err 85 } 86 success, ok := result.(*GetIDOK) 87 if ok { 88 return success, nil 89 } 90 // unexpected success response 91 unexpectedSuccess := result.(*GetIDDefault) 92 return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) 93 } 94 95 // SetTransport changes the transport on the client 96 func (a *Client) SetTransport(transport runtime.ClientTransport) { 97 a.transport = transport 98 }