github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/contributed-templates/stratoscale/client/store/store_client.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package store
     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  	"context"
    10  	"fmt"
    11  
    12  	"github.com/go-openapi/runtime"
    13  
    14  	strfmt "github.com/go-openapi/strfmt"
    15  )
    16  
    17  //go:generate mockery --name API --keeptree --with-expecter --case underscore
    18  
    19  // API is the interface of the store client
    20  type API interface {
    21  	/*
    22  	   InventoryGet returns pet inventories by status*/
    23  	InventoryGet(ctx context.Context, params *InventoryGetParams) (*InventoryGetOK, error)
    24  	/*
    25  	   OrderCreate places an order for a pet*/
    26  	OrderCreate(ctx context.Context, params *OrderCreateParams) (*OrderCreateOK, error)
    27  	/*
    28  	   OrderDelete deletes purchase order by ID
    29  
    30  	   For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors*/
    31  	OrderDelete(ctx context.Context, params *OrderDeleteParams) (*OrderDeleteNoContent, error)
    32  	/*
    33  	   OrderGet finds purchase order by ID
    34  
    35  	   For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions*/
    36  	OrderGet(ctx context.Context, params *OrderGetParams) (*OrderGetOK, error)
    37  }
    38  
    39  // New creates a new store API client.
    40  func New(transport runtime.ClientTransport, formats strfmt.Registry, authInfo runtime.ClientAuthInfoWriter) *Client {
    41  	return &Client{
    42  		transport: transport,
    43  		formats:   formats,
    44  		authInfo:  authInfo,
    45  	}
    46  }
    47  
    48  /*
    49  Client for store API
    50  */
    51  type Client struct {
    52  	transport runtime.ClientTransport
    53  	formats   strfmt.Registry
    54  	authInfo  runtime.ClientAuthInfoWriter
    55  }
    56  
    57  /*
    58  InventoryGet returns pet inventories by status
    59  */
    60  func (a *Client) InventoryGet(ctx context.Context, params *InventoryGetParams) (*InventoryGetOK, error) {
    61  
    62  	result, err := a.transport.Submit(&runtime.ClientOperation{
    63  		ID:                 "InventoryGet",
    64  		Method:             "GET",
    65  		PathPattern:        "/store/inventory",
    66  		ProducesMediaTypes: []string{"application/json"},
    67  		ConsumesMediaTypes: []string{"application/json"},
    68  		Schemes:            []string{"http"},
    69  		Params:             params,
    70  		Reader:             &InventoryGetReader{formats: a.formats},
    71  		AuthInfo:           a.authInfo,
    72  		Context:            ctx,
    73  		Client:             params.HTTPClient,
    74  	})
    75  	if err != nil {
    76  		return nil, err
    77  	}
    78  	switch value := result.(type) {
    79  	case *InventoryGetOK:
    80  		return value, nil
    81  	}
    82  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
    83  	msg := fmt.Sprintf("unexpected success response for InventoryGet: API contract not enforced by server. Client expected to get an error, but got: %T", result)
    84  	panic(msg)
    85  }
    86  
    87  /*
    88  OrderCreate places an order for a pet
    89  */
    90  func (a *Client) OrderCreate(ctx context.Context, params *OrderCreateParams) (*OrderCreateOK, error) {
    91  
    92  	result, err := a.transport.Submit(&runtime.ClientOperation{
    93  		ID:                 "OrderCreate",
    94  		Method:             "POST",
    95  		PathPattern:        "/store/order",
    96  		ProducesMediaTypes: []string{"application/json"},
    97  		ConsumesMediaTypes: []string{"application/json"},
    98  		Schemes:            []string{"http"},
    99  		Params:             params,
   100  		Reader:             &OrderCreateReader{formats: a.formats},
   101  		AuthInfo:           a.authInfo,
   102  		Context:            ctx,
   103  		Client:             params.HTTPClient,
   104  	})
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	switch value := result.(type) {
   109  	case *OrderCreateOK:
   110  		return value, nil
   111  	case *OrderCreateBadRequest:
   112  		return nil, runtime.NewAPIError("unsuccessful response", value, value.Code())
   113  	}
   114  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   115  	msg := fmt.Sprintf("unexpected success response for OrderCreate: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   116  	panic(msg)
   117  }
   118  
   119  /*
   120  OrderDelete deletes purchase order by ID
   121  
   122  For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors
   123  */
   124  func (a *Client) OrderDelete(ctx context.Context, params *OrderDeleteParams) (*OrderDeleteNoContent, error) {
   125  
   126  	result, err := a.transport.Submit(&runtime.ClientOperation{
   127  		ID:                 "OrderDelete",
   128  		Method:             "DELETE",
   129  		PathPattern:        "/store/order/{orderId}",
   130  		ProducesMediaTypes: []string{"application/json"},
   131  		ConsumesMediaTypes: []string{"application/json"},
   132  		Schemes:            []string{"http"},
   133  		Params:             params,
   134  		Reader:             &OrderDeleteReader{formats: a.formats},
   135  		AuthInfo:           a.authInfo,
   136  		Context:            ctx,
   137  		Client:             params.HTTPClient,
   138  	})
   139  	if err != nil {
   140  		return nil, err
   141  	}
   142  	switch value := result.(type) {
   143  	case *OrderDeleteNoContent:
   144  		return value, nil
   145  	case *OrderDeleteBadRequest:
   146  		return nil, runtime.NewAPIError("unsuccessful response", value, value.Code())
   147  	case *OrderDeleteNotFound:
   148  		return nil, runtime.NewAPIError("unsuccessful response", value, value.Code())
   149  	}
   150  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   151  	msg := fmt.Sprintf("unexpected success response for OrderDelete: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   152  	panic(msg)
   153  }
   154  
   155  /*
   156  OrderGet finds purchase order by ID
   157  
   158  For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions
   159  */
   160  func (a *Client) OrderGet(ctx context.Context, params *OrderGetParams) (*OrderGetOK, error) {
   161  
   162  	result, err := a.transport.Submit(&runtime.ClientOperation{
   163  		ID:                 "OrderGet",
   164  		Method:             "GET",
   165  		PathPattern:        "/store/order/{orderId}",
   166  		ProducesMediaTypes: []string{"application/json"},
   167  		ConsumesMediaTypes: []string{"application/json"},
   168  		Schemes:            []string{"http"},
   169  		Params:             params,
   170  		Reader:             &OrderGetReader{formats: a.formats},
   171  		AuthInfo:           a.authInfo,
   172  		Context:            ctx,
   173  		Client:             params.HTTPClient,
   174  	})
   175  	if err != nil {
   176  		return nil, err
   177  	}
   178  	switch value := result.(type) {
   179  	case *OrderGetOK:
   180  		return value, nil
   181  	case *OrderGetBadRequest:
   182  		return nil, runtime.NewAPIError("unsuccessful response", value, value.Code())
   183  	case *OrderGetNotFound:
   184  		return nil, runtime.NewAPIError("unsuccessful response", value, value.Code())
   185  	}
   186  	// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
   187  	msg := fmt.Sprintf("unexpected success response for OrderGet: API contract not enforced by server. Client expected to get an error, but got: %T", result)
   188  	panic(msg)
   189  }