github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/oracle_extend_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  // OracleExtendTx oracle extend tx
    19  // swagger:model OracleExtendTx
    20  type OracleExtendTx 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  	// oracle ttl
    34  	// Required: true
    35  	OracleTTL *RelativeTTL `json:"oracle_ttl"`
    36  
    37  	// ttl
    38  	TTL Uint64 `json:"ttl,omitempty"`
    39  }
    40  
    41  // Validate validates this oracle extend tx
    42  func (m *OracleExtendTx) Validate(formats strfmt.Registry) error {
    43  	var res []error
    44  
    45  	if err := m.validateFee(formats); err != nil {
    46  		res = append(res, err)
    47  	}
    48  
    49  	if err := m.validateNonce(formats); err != nil {
    50  		res = append(res, err)
    51  	}
    52  
    53  	if err := m.validateOracleID(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateOracleTTL(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validateTTL(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if len(res) > 0 {
    66  		return errors.CompositeValidationError(res...)
    67  	}
    68  	return nil
    69  }
    70  
    71  func (m *OracleExtendTx) validateFee(formats strfmt.Registry) error {
    72  
    73  	if err := m.Fee.Validate(formats); err != nil {
    74  		if ve, ok := err.(*errors.Validation); ok {
    75  			return ve.ValidateName("fee")
    76  		}
    77  		return err
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  func (m *OracleExtendTx) validateNonce(formats strfmt.Registry) error {
    84  
    85  	if swag.IsZero(m.Nonce) { // not required
    86  		return nil
    87  	}
    88  
    89  	if err := m.Nonce.Validate(formats); err != nil {
    90  		if ve, ok := err.(*errors.Validation); ok {
    91  			return ve.ValidateName("nonce")
    92  		}
    93  		return err
    94  	}
    95  
    96  	return nil
    97  }
    98  
    99  func (m *OracleExtendTx) validateOracleID(formats strfmt.Registry) error {
   100  
   101  	if err := m.OracleID.Validate(formats); err != nil {
   102  		if ve, ok := err.(*errors.Validation); ok {
   103  			return ve.ValidateName("oracle_id")
   104  		}
   105  		return err
   106  	}
   107  
   108  	return nil
   109  }
   110  
   111  func (m *OracleExtendTx) validateOracleTTL(formats strfmt.Registry) error {
   112  
   113  	if err := validate.Required("oracle_ttl", "body", m.OracleTTL); err != nil {
   114  		return err
   115  	}
   116  
   117  	if m.OracleTTL != nil {
   118  		if err := m.OracleTTL.Validate(formats); err != nil {
   119  			if ve, ok := err.(*errors.Validation); ok {
   120  				return ve.ValidateName("oracle_ttl")
   121  			}
   122  			return err
   123  		}
   124  	}
   125  
   126  	return nil
   127  }
   128  
   129  func (m *OracleExtendTx) validateTTL(formats strfmt.Registry) error {
   130  
   131  	if swag.IsZero(m.TTL) { // not required
   132  		return nil
   133  	}
   134  
   135  	if err := m.TTL.Validate(formats); err != nil {
   136  		if ve, ok := err.(*errors.Validation); ok {
   137  			return ve.ValidateName("ttl")
   138  		}
   139  		return err
   140  	}
   141  
   142  	return nil
   143  }
   144  
   145  // MarshalBinary interface implementation
   146  func (m *OracleExtendTx) MarshalBinary() ([]byte, error) {
   147  	if m == nil {
   148  		return nil, nil
   149  	}
   150  	return swag.WriteJSON(m)
   151  }
   152  
   153  // UnmarshalBinary interface implementation
   154  func (m *OracleExtendTx) UnmarshalBinary(b []byte) error {
   155  	var res OracleExtendTx
   156  	if err := swag.ReadJSON(b, &res); err != nil {
   157  		return err
   158  	}
   159  	*m = res
   160  	return nil
   161  }