github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/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 string `json:"contract_id,omitempty"` 33 34 // Public key 35 // Required: true 36 ID *string `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.validateID(formats); err != nil { 56 res = append(res, err) 57 } 58 59 if err := m.validateKind(formats); err != nil { 60 res = append(res, err) 61 } 62 63 if err := m.validateNonce(formats); err != nil { 64 res = append(res, err) 65 } 66 67 if len(res) > 0 { 68 return errors.CompositeValidationError(res...) 69 } 70 return nil 71 } 72 73 func (m *Account) validateBalance(formats strfmt.Registry) error { 74 75 if err := m.Balance.Validate(formats); err != nil { 76 if ve, ok := err.(*errors.Validation); ok { 77 return ve.ValidateName("balance") 78 } 79 return err 80 } 81 82 return nil 83 } 84 85 func (m *Account) validateID(formats strfmt.Registry) error { 86 87 if err := validate.Required("id", "body", m.ID); err != nil { 88 return err 89 } 90 91 return nil 92 } 93 94 var accountTypeKindPropEnum []interface{} 95 96 func init() { 97 var res []string 98 if err := json.Unmarshal([]byte(`["basic","generalized"]`), &res); err != nil { 99 panic(err) 100 } 101 for _, v := range res { 102 accountTypeKindPropEnum = append(accountTypeKindPropEnum, v) 103 } 104 } 105 106 const ( 107 108 // AccountKindBasic captures enum value "basic" 109 AccountKindBasic string = "basic" 110 111 // AccountKindGeneralized captures enum value "generalized" 112 AccountKindGeneralized string = "generalized" 113 ) 114 115 // prop value enum 116 func (m *Account) validateKindEnum(path, location string, value string) error { 117 if err := validate.Enum(path, location, value, accountTypeKindPropEnum); err != nil { 118 return err 119 } 120 return nil 121 } 122 123 func (m *Account) validateKind(formats strfmt.Registry) error { 124 125 if swag.IsZero(m.Kind) { // not required 126 return nil 127 } 128 129 // value enum 130 if err := m.validateKindEnum("kind", "body", m.Kind); err != nil { 131 return err 132 } 133 134 return nil 135 } 136 137 func (m *Account) validateNonce(formats strfmt.Registry) error { 138 139 if err := validate.Required("nonce", "body", m.Nonce); err != nil { 140 return err 141 } 142 143 return nil 144 } 145 146 // MarshalBinary interface implementation 147 func (m *Account) MarshalBinary() ([]byte, error) { 148 if m == nil { 149 return nil, nil 150 } 151 return swag.WriteJSON(m) 152 } 153 154 // UnmarshalBinary interface implementation 155 func (m *Account) UnmarshalBinary(b []byte) error { 156 var res Account 157 if err := swag.ReadJSON(b, &res); err != nil { 158 return err 159 } 160 *m = res 161 return nil 162 }