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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package pet
     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  	"encoding/json"
    10  	"fmt"
    11  	"io"
    12  
    13  	"github.com/go-openapi/runtime"
    14  	"github.com/go-openapi/strfmt"
    15  
    16  	"github.com/thetreep/go-swagger/examples/contributed-templates/stratoscale/models"
    17  )
    18  
    19  // PetUploadImageReader is a Reader for the PetUploadImage structure.
    20  type PetUploadImageReader struct {
    21  	formats strfmt.Registry
    22  }
    23  
    24  // ReadResponse reads a server response into the received o.
    25  func (o *PetUploadImageReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    26  	switch response.Code() {
    27  	case 200:
    28  		result := NewPetUploadImageOK()
    29  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    30  			return nil, err
    31  		}
    32  		return result, nil
    33  	default:
    34  		return nil, runtime.NewAPIError("[POST /pet/{petId}/image] PetUploadImage", response, response.Code())
    35  	}
    36  }
    37  
    38  // NewPetUploadImageOK creates a PetUploadImageOK with default headers values
    39  func NewPetUploadImageOK() *PetUploadImageOK {
    40  	return &PetUploadImageOK{}
    41  }
    42  
    43  /*
    44  PetUploadImageOK describes a response with status code 200, with default header values.
    45  
    46  successful operation
    47  */
    48  type PetUploadImageOK struct {
    49  	Payload *models.APIResponse
    50  }
    51  
    52  // IsSuccess returns true when this pet upload image o k response has a 2xx status code
    53  func (o *PetUploadImageOK) IsSuccess() bool {
    54  	return true
    55  }
    56  
    57  // IsRedirect returns true when this pet upload image o k response has a 3xx status code
    58  func (o *PetUploadImageOK) IsRedirect() bool {
    59  	return false
    60  }
    61  
    62  // IsClientError returns true when this pet upload image o k response has a 4xx status code
    63  func (o *PetUploadImageOK) IsClientError() bool {
    64  	return false
    65  }
    66  
    67  // IsServerError returns true when this pet upload image o k response has a 5xx status code
    68  func (o *PetUploadImageOK) IsServerError() bool {
    69  	return false
    70  }
    71  
    72  // IsCode returns true when this pet upload image o k response a status code equal to that given
    73  func (o *PetUploadImageOK) IsCode(code int) bool {
    74  	return code == 200
    75  }
    76  
    77  // Code gets the status code for the pet upload image o k response
    78  func (o *PetUploadImageOK) Code() int {
    79  	return 200
    80  }
    81  
    82  func (o *PetUploadImageOK) Error() string {
    83  	payload, _ := json.Marshal(o.Payload)
    84  	return fmt.Sprintf("[POST /pet/{petId}/image][%d] petUploadImageOK %s", 200, payload)
    85  }
    86  
    87  func (o *PetUploadImageOK) String() string {
    88  	payload, _ := json.Marshal(o.Payload)
    89  	return fmt.Sprintf("[POST /pet/{petId}/image][%d] petUploadImageOK %s", 200, payload)
    90  }
    91  
    92  func (o *PetUploadImageOK) GetPayload() *models.APIResponse {
    93  	return o.Payload
    94  }
    95  
    96  func (o *PetUploadImageOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    97  
    98  	o.Payload = new(models.APIResponse)
    99  
   100  	// response payload
   101  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   102  		return err
   103  	}
   104  
   105  	return nil
   106  }