github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/client/external/get_top_block_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package external
     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  
    14  	strfmt "github.com/go-openapi/strfmt"
    15  
    16  	models "github.com/aeternity/aepp-sdk-go/swagguard/node/models"
    17  )
    18  
    19  // GetTopBlockReader is a Reader for the GetTopBlock structure.
    20  type GetTopBlockReader struct {
    21  	formats strfmt.Registry
    22  }
    23  
    24  // ReadResponse reads a server response into the received o.
    25  func (o *GetTopBlockReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    26  	switch response.Code() {
    27  
    28  	case 200:
    29  		result := NewGetTopBlockOK()
    30  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    31  			return nil, err
    32  		}
    33  		return result, nil
    34  
    35  	case 404:
    36  		result := NewGetTopBlockNotFound()
    37  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    38  			return nil, err
    39  		}
    40  		return nil, result
    41  
    42  	default:
    43  		return nil, runtime.NewAPIError("unknown error", response, response.Code())
    44  	}
    45  }
    46  
    47  // NewGetTopBlockOK creates a GetTopBlockOK with default headers values
    48  func NewGetTopBlockOK() *GetTopBlockOK {
    49  	return &GetTopBlockOK{}
    50  }
    51  
    52  /*GetTopBlockOK handles this case with default header values.
    53  
    54  Successful operation
    55  */
    56  type GetTopBlockOK struct {
    57  	Payload *models.KeyBlockOrMicroBlockHeader
    58  }
    59  
    60  func (o *GetTopBlockOK) Error() string {
    61  	return fmt.Sprintf("[GET /blocks/top][%d] getTopBlockOK  %+v", 200, o.Payload)
    62  }
    63  
    64  func (o *GetTopBlockOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    65  
    66  	o.Payload = new(models.KeyBlockOrMicroBlockHeader)
    67  
    68  	// response payload
    69  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    70  		return err
    71  	}
    72  
    73  	return nil
    74  }
    75  
    76  // NewGetTopBlockNotFound creates a GetTopBlockNotFound with default headers values
    77  func NewGetTopBlockNotFound() *GetTopBlockNotFound {
    78  	return &GetTopBlockNotFound{}
    79  }
    80  
    81  /*GetTopBlockNotFound handles this case with default header values.
    82  
    83  Block not found
    84  */
    85  type GetTopBlockNotFound struct {
    86  	Payload *models.Error
    87  }
    88  
    89  func (o *GetTopBlockNotFound) Error() string {
    90  	return fmt.Sprintf("[GET /blocks/top][%d] getTopBlockNotFound  %+v", 404, o.Payload)
    91  }
    92  
    93  func (o *GetTopBlockNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    94  
    95  	o.Payload = new(models.Error)
    96  
    97  	// response payload
    98  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    99  		return err
   100  	}
   101  
   102  	return nil
   103  }