github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/examples/contributed-templates/stratoscale/client/store/order_create_responses.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  	"fmt"
    10  	"io"
    11  
    12  	"github.com/go-openapi/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  
    15  	"github.com/go-swagger/go-swagger/examples/contributed-templates/stratoscale/models"
    16  )
    17  
    18  // OrderCreateReader is a Reader for the OrderCreate structure.
    19  type OrderCreateReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *OrderCreateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 200:
    27  		result := NewOrderCreateOK()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	case 400:
    33  		result := NewOrderCreateBadRequest()
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		return nil, result
    38  	default:
    39  		return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
    40  	}
    41  }
    42  
    43  // NewOrderCreateOK creates a OrderCreateOK with default headers values
    44  func NewOrderCreateOK() *OrderCreateOK {
    45  	return &OrderCreateOK{}
    46  }
    47  
    48  /*
    49  OrderCreateOK describes a response with status code 200, with default header values.
    50  
    51  successful operation
    52  */
    53  type OrderCreateOK struct {
    54  	Payload *models.Order
    55  }
    56  
    57  // IsSuccess returns true when this order create o k response has a 2xx status code
    58  func (o *OrderCreateOK) IsSuccess() bool {
    59  	return true
    60  }
    61  
    62  // IsRedirect returns true when this order create o k response has a 3xx status code
    63  func (o *OrderCreateOK) IsRedirect() bool {
    64  	return false
    65  }
    66  
    67  // IsClientError returns true when this order create o k response has a 4xx status code
    68  func (o *OrderCreateOK) IsClientError() bool {
    69  	return false
    70  }
    71  
    72  // IsServerError returns true when this order create o k response has a 5xx status code
    73  func (o *OrderCreateOK) IsServerError() bool {
    74  	return false
    75  }
    76  
    77  // IsCode returns true when this order create o k response a status code equal to that given
    78  func (o *OrderCreateOK) IsCode(code int) bool {
    79  	return code == 200
    80  }
    81  
    82  // Code gets the status code for the order create o k response
    83  func (o *OrderCreateOK) Code() int {
    84  	return 200
    85  }
    86  
    87  func (o *OrderCreateOK) Error() string {
    88  	return fmt.Sprintf("[POST /store/order][%d] orderCreateOK  %+v", 200, o.Payload)
    89  }
    90  
    91  func (o *OrderCreateOK) String() string {
    92  	return fmt.Sprintf("[POST /store/order][%d] orderCreateOK  %+v", 200, o.Payload)
    93  }
    94  
    95  func (o *OrderCreateOK) GetPayload() *models.Order {
    96  	return o.Payload
    97  }
    98  
    99  func (o *OrderCreateOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   100  
   101  	o.Payload = new(models.Order)
   102  
   103  	// response payload
   104  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   105  		return err
   106  	}
   107  
   108  	return nil
   109  }
   110  
   111  // NewOrderCreateBadRequest creates a OrderCreateBadRequest with default headers values
   112  func NewOrderCreateBadRequest() *OrderCreateBadRequest {
   113  	return &OrderCreateBadRequest{}
   114  }
   115  
   116  /*
   117  OrderCreateBadRequest describes a response with status code 400, with default header values.
   118  
   119  Invalid Order
   120  */
   121  type OrderCreateBadRequest struct {
   122  }
   123  
   124  // IsSuccess returns true when this order create bad request response has a 2xx status code
   125  func (o *OrderCreateBadRequest) IsSuccess() bool {
   126  	return false
   127  }
   128  
   129  // IsRedirect returns true when this order create bad request response has a 3xx status code
   130  func (o *OrderCreateBadRequest) IsRedirect() bool {
   131  	return false
   132  }
   133  
   134  // IsClientError returns true when this order create bad request response has a 4xx status code
   135  func (o *OrderCreateBadRequest) IsClientError() bool {
   136  	return true
   137  }
   138  
   139  // IsServerError returns true when this order create bad request response has a 5xx status code
   140  func (o *OrderCreateBadRequest) IsServerError() bool {
   141  	return false
   142  }
   143  
   144  // IsCode returns true when this order create bad request response a status code equal to that given
   145  func (o *OrderCreateBadRequest) IsCode(code int) bool {
   146  	return code == 400
   147  }
   148  
   149  // Code gets the status code for the order create bad request response
   150  func (o *OrderCreateBadRequest) Code() int {
   151  	return 400
   152  }
   153  
   154  func (o *OrderCreateBadRequest) Error() string {
   155  	return fmt.Sprintf("[POST /store/order][%d] orderCreateBadRequest ", 400)
   156  }
   157  
   158  func (o *OrderCreateBadRequest) String() string {
   159  	return fmt.Sprintf("[POST /store/order][%d] orderCreateBadRequest ", 400)
   160  }
   161  
   162  func (o *OrderCreateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   163  
   164  	return nil
   165  }