github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/oracle_query_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  // OracleQueryTx oracle query tx
    19  // swagger:model OracleQueryTx
    20  type OracleQueryTx struct {
    21  
    22  	// fee
    23  	// Required: true
    24  	Fee utils.BigInt `json:"fee"`
    25  
    26  	// Sender nonce
    27  	Nonce Uint64 `json:"nonce,omitempty"`
    28  
    29  	// oracle id
    30  	// Required: true
    31  	OracleID EncodedPubkey `json:"oracle_id"`
    32  
    33  	// query
    34  	// Required: true
    35  	Query *string `json:"query"`
    36  
    37  	// query fee
    38  	// Required: true
    39  	QueryFee utils.BigInt `json:"query_fee"`
    40  
    41  	// query ttl
    42  	// Required: true
    43  	QueryTTL *TTL `json:"query_ttl"`
    44  
    45  	// response ttl
    46  	// Required: true
    47  	ResponseTTL *RelativeTTL `json:"response_ttl"`
    48  
    49  	// sender id
    50  	// Required: true
    51  	SenderID EncodedPubkey `json:"sender_id"`
    52  
    53  	// ttl
    54  	TTL Uint64 `json:"ttl,omitempty"`
    55  }
    56  
    57  // Validate validates this oracle query tx
    58  func (m *OracleQueryTx) Validate(formats strfmt.Registry) error {
    59  	var res []error
    60  
    61  	if err := m.validateFee(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if err := m.validateNonce(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if err := m.validateOracleID(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if err := m.validateQuery(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if err := m.validateQueryFee(formats); err != nil {
    78  		res = append(res, err)
    79  	}
    80  
    81  	if err := m.validateQueryTTL(formats); err != nil {
    82  		res = append(res, err)
    83  	}
    84  
    85  	if err := m.validateResponseTTL(formats); err != nil {
    86  		res = append(res, err)
    87  	}
    88  
    89  	if err := m.validateSenderID(formats); err != nil {
    90  		res = append(res, err)
    91  	}
    92  
    93  	if err := m.validateTTL(formats); err != nil {
    94  		res = append(res, err)
    95  	}
    96  
    97  	if len(res) > 0 {
    98  		return errors.CompositeValidationError(res...)
    99  	}
   100  	return nil
   101  }
   102  
   103  func (m *OracleQueryTx) validateFee(formats strfmt.Registry) error {
   104  
   105  	if err := m.Fee.Validate(formats); err != nil {
   106  		if ve, ok := err.(*errors.Validation); ok {
   107  			return ve.ValidateName("fee")
   108  		}
   109  		return err
   110  	}
   111  
   112  	return nil
   113  }
   114  
   115  func (m *OracleQueryTx) validateNonce(formats strfmt.Registry) error {
   116  
   117  	if swag.IsZero(m.Nonce) { // not required
   118  		return nil
   119  	}
   120  
   121  	if err := m.Nonce.Validate(formats); err != nil {
   122  		if ve, ok := err.(*errors.Validation); ok {
   123  			return ve.ValidateName("nonce")
   124  		}
   125  		return err
   126  	}
   127  
   128  	return nil
   129  }
   130  
   131  func (m *OracleQueryTx) validateOracleID(formats strfmt.Registry) error {
   132  
   133  	if err := m.OracleID.Validate(formats); err != nil {
   134  		if ve, ok := err.(*errors.Validation); ok {
   135  			return ve.ValidateName("oracle_id")
   136  		}
   137  		return err
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *OracleQueryTx) validateQuery(formats strfmt.Registry) error {
   144  
   145  	if err := validate.Required("query", "body", m.Query); err != nil {
   146  		return err
   147  	}
   148  
   149  	return nil
   150  }
   151  
   152  func (m *OracleQueryTx) validateQueryFee(formats strfmt.Registry) error {
   153  
   154  	if err := m.QueryFee.Validate(formats); err != nil {
   155  		if ve, ok := err.(*errors.Validation); ok {
   156  			return ve.ValidateName("query_fee")
   157  		}
   158  		return err
   159  	}
   160  
   161  	return nil
   162  }
   163  
   164  func (m *OracleQueryTx) validateQueryTTL(formats strfmt.Registry) error {
   165  
   166  	if err := validate.Required("query_ttl", "body", m.QueryTTL); err != nil {
   167  		return err
   168  	}
   169  
   170  	if m.QueryTTL != nil {
   171  		if err := m.QueryTTL.Validate(formats); err != nil {
   172  			if ve, ok := err.(*errors.Validation); ok {
   173  				return ve.ValidateName("query_ttl")
   174  			}
   175  			return err
   176  		}
   177  	}
   178  
   179  	return nil
   180  }
   181  
   182  func (m *OracleQueryTx) validateResponseTTL(formats strfmt.Registry) error {
   183  
   184  	if err := validate.Required("response_ttl", "body", m.ResponseTTL); err != nil {
   185  		return err
   186  	}
   187  
   188  	if m.ResponseTTL != nil {
   189  		if err := m.ResponseTTL.Validate(formats); err != nil {
   190  			if ve, ok := err.(*errors.Validation); ok {
   191  				return ve.ValidateName("response_ttl")
   192  			}
   193  			return err
   194  		}
   195  	}
   196  
   197  	return nil
   198  }
   199  
   200  func (m *OracleQueryTx) validateSenderID(formats strfmt.Registry) error {
   201  
   202  	if err := m.SenderID.Validate(formats); err != nil {
   203  		if ve, ok := err.(*errors.Validation); ok {
   204  			return ve.ValidateName("sender_id")
   205  		}
   206  		return err
   207  	}
   208  
   209  	return nil
   210  }
   211  
   212  func (m *OracleQueryTx) validateTTL(formats strfmt.Registry) error {
   213  
   214  	if swag.IsZero(m.TTL) { // not required
   215  		return nil
   216  	}
   217  
   218  	if err := m.TTL.Validate(formats); err != nil {
   219  		if ve, ok := err.(*errors.Validation); ok {
   220  			return ve.ValidateName("ttl")
   221  		}
   222  		return err
   223  	}
   224  
   225  	return nil
   226  }
   227  
   228  // MarshalBinary interface implementation
   229  func (m *OracleQueryTx) MarshalBinary() ([]byte, error) {
   230  	if m == nil {
   231  		return nil, nil
   232  	}
   233  	return swag.WriteJSON(m)
   234  }
   235  
   236  // UnmarshalBinary interface implementation
   237  func (m *OracleQueryTx) UnmarshalBinary(b []byte) error {
   238  	var res OracleQueryTx
   239  	if err := swag.ReadJSON(b, &res); err != nil {
   240  		return err
   241  	}
   242  	*m = res
   243  	return nil
   244  }