github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/oracle_respond_tx.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     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  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  	"github.com/go-openapi/validate"
    14  
    15  	utils "github.com/aeternity/aepp-sdk-go/utils"
    16  )
    17  
    18  // OracleRespondTx oracle respond tx
    19  // swagger:model OracleRespondTx
    20  type OracleRespondTx struct {
    21  
    22  	// fee
    23  	// Required: true
    24  	Fee utils.BigInt `json:"fee"`
    25  
    26  	// nonce
    27  	Nonce Uint64 `json:"nonce,omitempty"`
    28  
    29  	// oracle id
    30  	// Required: true
    31  	OracleID EncodedPubkey `json:"oracle_id"`
    32  
    33  	// query id
    34  	// Required: true
    35  	QueryID EncodedValue `json:"query_id"`
    36  
    37  	// response
    38  	// Required: true
    39  	Response *string `json:"response"`
    40  
    41  	// response ttl
    42  	// Required: true
    43  	ResponseTTL *RelativeTTL `json:"response_ttl"`
    44  
    45  	// ttl
    46  	TTL Uint64 `json:"ttl,omitempty"`
    47  }
    48  
    49  // Validate validates this oracle respond tx
    50  func (m *OracleRespondTx) Validate(formats strfmt.Registry) error {
    51  	var res []error
    52  
    53  	if err := m.validateFee(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateNonce(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validateOracleID(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if err := m.validateQueryID(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if err := m.validateResponse(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if err := m.validateResponseTTL(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if err := m.validateTTL(formats); err != nil {
    78  		res = append(res, err)
    79  	}
    80  
    81  	if len(res) > 0 {
    82  		return errors.CompositeValidationError(res...)
    83  	}
    84  	return nil
    85  }
    86  
    87  func (m *OracleRespondTx) validateFee(formats strfmt.Registry) error {
    88  
    89  	if err := m.Fee.Validate(formats); err != nil {
    90  		if ve, ok := err.(*errors.Validation); ok {
    91  			return ve.ValidateName("fee")
    92  		}
    93  		return err
    94  	}
    95  
    96  	return nil
    97  }
    98  
    99  func (m *OracleRespondTx) validateNonce(formats strfmt.Registry) error {
   100  
   101  	if swag.IsZero(m.Nonce) { // not required
   102  		return nil
   103  	}
   104  
   105  	if err := m.Nonce.Validate(formats); err != nil {
   106  		if ve, ok := err.(*errors.Validation); ok {
   107  			return ve.ValidateName("nonce")
   108  		}
   109  		return err
   110  	}
   111  
   112  	return nil
   113  }
   114  
   115  func (m *OracleRespondTx) validateOracleID(formats strfmt.Registry) error {
   116  
   117  	if err := m.OracleID.Validate(formats); err != nil {
   118  		if ve, ok := err.(*errors.Validation); ok {
   119  			return ve.ValidateName("oracle_id")
   120  		}
   121  		return err
   122  	}
   123  
   124  	return nil
   125  }
   126  
   127  func (m *OracleRespondTx) validateQueryID(formats strfmt.Registry) error {
   128  
   129  	if err := m.QueryID.Validate(formats); err != nil {
   130  		if ve, ok := err.(*errors.Validation); ok {
   131  			return ve.ValidateName("query_id")
   132  		}
   133  		return err
   134  	}
   135  
   136  	return nil
   137  }
   138  
   139  func (m *OracleRespondTx) validateResponse(formats strfmt.Registry) error {
   140  
   141  	if err := validate.Required("response", "body", m.Response); err != nil {
   142  		return err
   143  	}
   144  
   145  	return nil
   146  }
   147  
   148  func (m *OracleRespondTx) validateResponseTTL(formats strfmt.Registry) error {
   149  
   150  	if err := validate.Required("response_ttl", "body", m.ResponseTTL); err != nil {
   151  		return err
   152  	}
   153  
   154  	if m.ResponseTTL != nil {
   155  		if err := m.ResponseTTL.Validate(formats); err != nil {
   156  			if ve, ok := err.(*errors.Validation); ok {
   157  				return ve.ValidateName("response_ttl")
   158  			}
   159  			return err
   160  		}
   161  	}
   162  
   163  	return nil
   164  }
   165  
   166  func (m *OracleRespondTx) validateTTL(formats strfmt.Registry) error {
   167  
   168  	if swag.IsZero(m.TTL) { // not required
   169  		return nil
   170  	}
   171  
   172  	if err := m.TTL.Validate(formats); err != nil {
   173  		if ve, ok := err.(*errors.Validation); ok {
   174  			return ve.ValidateName("ttl")
   175  		}
   176  		return err
   177  	}
   178  
   179  	return nil
   180  }
   181  
   182  // MarshalBinary interface implementation
   183  func (m *OracleRespondTx) MarshalBinary() ([]byte, error) {
   184  	if m == nil {
   185  		return nil, nil
   186  	}
   187  	return swag.WriteJSON(m)
   188  }
   189  
   190  // UnmarshalBinary interface implementation
   191  func (m *OracleRespondTx) UnmarshalBinary(b []byte) error {
   192  	var res OracleRespondTx
   193  	if err := swag.ReadJSON(b, &res); err != nil {
   194  		return err
   195  	}
   196  	*m = res
   197  	return nil
   198  }