github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/account.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  	"encoding/json"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  
    17  	utils "github.com/aeternity/aepp-sdk-go/utils"
    18  )
    19  
    20  // Account account
    21  // swagger:model Account
    22  type Account struct {
    23  
    24  	// Name of authorization function for generalized account
    25  	AuthFun string `json:"auth_fun,omitempty"`
    26  
    27  	// Balance
    28  	// Required: true
    29  	Balance utils.BigInt `json:"balance"`
    30  
    31  	// Id of authorization contract for generalized account
    32  	ContractID EncodedPubkey `json:"contract_id,omitempty"`
    33  
    34  	// Public key
    35  	// Required: true
    36  	ID EncodedPubkey `json:"id"`
    37  
    38  	// kind
    39  	// Enum: [basic generalized]
    40  	Kind string `json:"kind,omitempty"`
    41  
    42  	// Nonce
    43  	// Required: true
    44  	Nonce Uint64 `json:"nonce"`
    45  }
    46  
    47  // Validate validates this account
    48  func (m *Account) Validate(formats strfmt.Registry) error {
    49  	var res []error
    50  
    51  	if err := m.validateBalance(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if err := m.validateContractID(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if err := m.validateID(formats); err != nil {
    60  		res = append(res, err)
    61  	}
    62  
    63  	if err := m.validateKind(formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	if err := m.validateNonce(formats); err != nil {
    68  		res = append(res, err)
    69  	}
    70  
    71  	if len(res) > 0 {
    72  		return errors.CompositeValidationError(res...)
    73  	}
    74  	return nil
    75  }
    76  
    77  func (m *Account) validateBalance(formats strfmt.Registry) error {
    78  
    79  	if err := m.Balance.Validate(formats); err != nil {
    80  		if ve, ok := err.(*errors.Validation); ok {
    81  			return ve.ValidateName("balance")
    82  		}
    83  		return err
    84  	}
    85  
    86  	return nil
    87  }
    88  
    89  func (m *Account) validateContractID(formats strfmt.Registry) error {
    90  
    91  	if swag.IsZero(m.ContractID) { // not required
    92  		return nil
    93  	}
    94  
    95  	if err := m.ContractID.Validate(formats); err != nil {
    96  		if ve, ok := err.(*errors.Validation); ok {
    97  			return ve.ValidateName("contract_id")
    98  		}
    99  		return err
   100  	}
   101  
   102  	return nil
   103  }
   104  
   105  func (m *Account) validateID(formats strfmt.Registry) error {
   106  
   107  	if err := m.ID.Validate(formats); err != nil {
   108  		if ve, ok := err.(*errors.Validation); ok {
   109  			return ve.ValidateName("id")
   110  		}
   111  		return err
   112  	}
   113  
   114  	return nil
   115  }
   116  
   117  var accountTypeKindPropEnum []interface{}
   118  
   119  func init() {
   120  	var res []string
   121  	if err := json.Unmarshal([]byte(`["basic","generalized"]`), &res); err != nil {
   122  		panic(err)
   123  	}
   124  	for _, v := range res {
   125  		accountTypeKindPropEnum = append(accountTypeKindPropEnum, v)
   126  	}
   127  }
   128  
   129  const (
   130  
   131  	// AccountKindBasic captures enum value "basic"
   132  	AccountKindBasic string = "basic"
   133  
   134  	// AccountKindGeneralized captures enum value "generalized"
   135  	AccountKindGeneralized string = "generalized"
   136  )
   137  
   138  // prop value enum
   139  func (m *Account) validateKindEnum(path, location string, value string) error {
   140  	if err := validate.Enum(path, location, value, accountTypeKindPropEnum); err != nil {
   141  		return err
   142  	}
   143  	return nil
   144  }
   145  
   146  func (m *Account) validateKind(formats strfmt.Registry) error {
   147  
   148  	if swag.IsZero(m.Kind) { // not required
   149  		return nil
   150  	}
   151  
   152  	// value enum
   153  	if err := m.validateKindEnum("kind", "body", m.Kind); err != nil {
   154  		return err
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  func (m *Account) validateNonce(formats strfmt.Registry) error {
   161  
   162  	if err := m.Nonce.Validate(formats); err != nil {
   163  		if ve, ok := err.(*errors.Validation); ok {
   164  			return ve.ValidateName("nonce")
   165  		}
   166  		return err
   167  	}
   168  
   169  	return nil
   170  }
   171  
   172  // MarshalBinary interface implementation
   173  func (m *Account) MarshalBinary() ([]byte, error) {
   174  	if m == nil {
   175  		return nil, nil
   176  	}
   177  	return swag.WriteJSON(m)
   178  }
   179  
   180  // UnmarshalBinary interface implementation
   181  func (m *Account) UnmarshalBinary(b []byte) error {
   182  	var res Account
   183  	if err := swag.ReadJSON(b, &res); err != nil {
   184  		return err
   185  	}
   186  	*m = res
   187  	return nil
   188  }