models.go265 lines, 6.9 KB
| 1 | // Code generated by sqlc. DO NOT EDIT. |
| 2 | // versions: |
| 3 | // sqlc v1.31.1 |
| 4 | |
| 5 | package walletdb |
| 6 | |
| 7 | import ( |
| 8 | "database/sql/driver" |
| 9 | "fmt" |
| 10 | "time" |
| 11 | |
| 12 | "github.com/fiston-user/payments/internal/fx" |
| 13 | "github.com/google/uuid" |
| 14 | "github.com/jackc/pgx/v5/pgtype" |
| 15 | "go.opentelemetry.io/otel/propagation" |
| 16 | ) |
| 17 | |
| 18 | type AccountKind string |
| 19 | |
| 20 | const ( |
| 21 | AccountKindWallet AccountKind = "wallet" |
| 22 | AccountKindSystem AccountKind = "system" |
| 23 | ) |
| 24 | |
| 25 | func (e *AccountKind) Scan(src interface{}) error { |
| 26 | switch s := src.(type) { |
| 27 | case []byte: |
| 28 | *e = AccountKind(s) |
| 29 | case string: |
| 30 | *e = AccountKind(s) |
| 31 | default: |
| 32 | return fmt.Errorf("unsupported scan type for AccountKind: %T", src) |
| 33 | } |
| 34 | return nil |
| 35 | } |
| 36 | |
| 37 | type NullAccountKind struct { |
| 38 | AccountKind AccountKind `json:"account_kind"` |
| 39 | Valid bool `json:"valid"` // Valid is true if AccountKind is not NULL |
| 40 | } |
| 41 | |
| 42 | // Scan implements the Scanner interface. |
| 43 | func (ns *NullAccountKind) Scan(value interface{}) error { |
| 44 | if value == nil { |
| 45 | ns.AccountKind, ns.Valid = "", false |
| 46 | return nil |
| 47 | } |
| 48 | ns.Valid = true |
| 49 | return ns.AccountKind.Scan(value) |
| 50 | } |
| 51 | |
| 52 | // Value implements the driver Valuer interface. |
| 53 | func (ns NullAccountKind) Value() (driver.Value, error) { |
| 54 | if !ns.Valid { |
| 55 | return nil, nil |
| 56 | } |
| 57 | return string(ns.AccountKind), nil |
| 58 | } |
| 59 | |
| 60 | func (e AccountKind) Valid() bool { |
| 61 | switch e { |
| 62 | case AccountKindWallet, |
| 63 | AccountKindSystem: |
| 64 | return true |
| 65 | } |
| 66 | return false |
| 67 | } |
| 68 | |
| 69 | type EntryDirection string |
| 70 | |
| 71 | const ( |
| 72 | EntryDirectionDebit EntryDirection = "debit" |
| 73 | EntryDirectionCredit EntryDirection = "credit" |
| 74 | ) |
| 75 | |
| 76 | func (e *EntryDirection) Scan(src interface{}) error { |
| 77 | switch s := src.(type) { |
| 78 | case []byte: |
| 79 | *e = EntryDirection(s) |
| 80 | case string: |
| 81 | *e = EntryDirection(s) |
| 82 | default: |
| 83 | return fmt.Errorf("unsupported scan type for EntryDirection: %T", src) |
| 84 | } |
| 85 | return nil |
| 86 | } |
| 87 | |
| 88 | type NullEntryDirection struct { |
| 89 | EntryDirection EntryDirection `json:"entry_direction"` |
| 90 | Valid bool `json:"valid"` // Valid is true if EntryDirection is not NULL |
| 91 | } |
| 92 | |
| 93 | // Scan implements the Scanner interface. |
| 94 | func (ns *NullEntryDirection) Scan(value interface{}) error { |
| 95 | if value == nil { |
| 96 | ns.EntryDirection, ns.Valid = "", false |
| 97 | return nil |
| 98 | } |
| 99 | ns.Valid = true |
| 100 | return ns.EntryDirection.Scan(value) |
| 101 | } |
| 102 | |
| 103 | // Value implements the driver Valuer interface. |
| 104 | func (ns NullEntryDirection) Value() (driver.Value, error) { |
| 105 | if !ns.Valid { |
| 106 | return nil, nil |
| 107 | } |
| 108 | return string(ns.EntryDirection), nil |
| 109 | } |
| 110 | |
| 111 | func (e EntryDirection) Valid() bool { |
| 112 | switch e { |
| 113 | case EntryDirectionDebit, |
| 114 | EntryDirectionCredit: |
| 115 | return true |
| 116 | } |
| 117 | return false |
| 118 | } |
| 119 | |
| 120 | type HoldStatus string |
| 121 | |
| 122 | const ( |
| 123 | HoldStatusHeld HoldStatus = "held" |
| 124 | HoldStatusCaptured HoldStatus = "captured" |
| 125 | HoldStatusReleased HoldStatus = "released" |
| 126 | ) |
| 127 | |
| 128 | func (e *HoldStatus) Scan(src interface{}) error { |
| 129 | switch s := src.(type) { |
| 130 | case []byte: |
| 131 | *e = HoldStatus(s) |
| 132 | case string: |
| 133 | *e = HoldStatus(s) |
| 134 | default: |
| 135 | return fmt.Errorf("unsupported scan type for HoldStatus: %T", src) |
| 136 | } |
| 137 | return nil |
| 138 | } |
| 139 | |
| 140 | type NullHoldStatus struct { |
| 141 | HoldStatus HoldStatus `json:"hold_status"` |
| 142 | Valid bool `json:"valid"` // Valid is true if HoldStatus is not NULL |
| 143 | } |
| 144 | |
| 145 | // Scan implements the Scanner interface. |
| 146 | func (ns *NullHoldStatus) Scan(value interface{}) error { |
| 147 | if value == nil { |
| 148 | ns.HoldStatus, ns.Valid = "", false |
| 149 | return nil |
| 150 | } |
| 151 | ns.Valid = true |
| 152 | return ns.HoldStatus.Scan(value) |
| 153 | } |
| 154 | |
| 155 | // Value implements the driver Valuer interface. |
| 156 | func (ns NullHoldStatus) Value() (driver.Value, error) { |
| 157 | if !ns.Valid { |
| 158 | return nil, nil |
| 159 | } |
| 160 | return string(ns.HoldStatus), nil |
| 161 | } |
| 162 | |
| 163 | func (e HoldStatus) Valid() bool { |
| 164 | switch e { |
| 165 | case HoldStatusHeld, |
| 166 | HoldStatusCaptured, |
| 167 | HoldStatusReleased: |
| 168 | return true |
| 169 | } |
| 170 | return false |
| 171 | } |
| 172 | |
| 173 | type Account struct { |
| 174 | ID uuid.UUID `json:"id"` |
| 175 | OwnerID *uuid.UUID `json:"owner_id"` |
| 176 | Name string `json:"name"` |
| 177 | Currency string `json:"currency"` |
| 178 | NormalBalance EntryDirection `json:"normal_balance"` |
| 179 | CreatedAt time.Time `json:"created_at"` |
| 180 | Kind AccountKind `json:"kind"` |
| 181 | Frozen bool `json:"frozen"` |
| 182 | } |
| 183 | |
| 184 | type AccountBalance struct { |
| 185 | AccountID uuid.UUID `json:"account_id"` |
| 186 | Name string `json:"name"` |
| 187 | Currency string `json:"currency"` |
| 188 | Balance int64 `json:"balance"` |
| 189 | } |
| 190 | |
| 191 | type Entry struct { |
| 192 | ID int64 `json:"id"` |
| 193 | TransactionID uuid.UUID `json:"transaction_id"` |
| 194 | AccountID uuid.UUID `json:"account_id"` |
| 195 | Direction EntryDirection `json:"direction"` |
| 196 | Amount int64 `json:"amount"` |
| 197 | Currency string `json:"currency"` |
| 198 | CreatedAt time.Time `json:"created_at"` |
| 199 | } |
| 200 | |
| 201 | type FXQuote struct { |
| 202 | ID uuid.UUID `json:"id"` |
| 203 | OwnerID uuid.UUID `json:"owner_id"` |
| 204 | SellCurrency string `json:"sell_currency"` |
| 205 | SellAmount int64 `json:"sell_amount"` |
| 206 | BuyCurrency string `json:"buy_currency"` |
| 207 | BuyAmount int64 `json:"buy_amount"` |
| 208 | Fee int64 `json:"fee"` |
| 209 | Rate fx.Rate `json:"rate"` |
| 210 | ExpiresAt time.Time `json:"expires_at"` |
| 211 | CreatedAt time.Time `json:"created_at"` |
| 212 | TransactionID *uuid.UUID `json:"transaction_id"` |
| 213 | } |
| 214 | |
| 215 | type Hold struct { |
| 216 | ID uuid.UUID `json:"id"` |
| 217 | WalletID uuid.UUID `json:"wallet_id"` |
| 218 | Amount int64 `json:"amount"` |
| 219 | Currency string `json:"currency"` |
| 220 | Status HoldStatus `json:"status"` |
| 221 | HoldTxID uuid.UUID `json:"hold_tx_id"` |
| 222 | SettledTo *uuid.UUID `json:"settled_to"` |
| 223 | SettleTxID *uuid.UUID `json:"settle_tx_id"` |
| 224 | CreatedAt time.Time `json:"created_at"` |
| 225 | SettledAt pgtype.Timestamptz `json:"settled_at"` |
| 226 | } |
| 227 | |
| 228 | type IdempotencyKey struct { |
| 229 | Scope string `json:"scope"` |
| 230 | Key string `json:"key"` |
| 231 | Fingerprint []byte `json:"fingerprint"` |
| 232 | Status string `json:"status"` |
| 233 | ResponseCode pgtype.Int4 `json:"response_code"` |
| 234 | ResponseBody []byte `json:"response_body"` |
| 235 | CreatedAt time.Time `json:"created_at"` |
| 236 | LockedAt time.Time `json:"locked_at"` |
| 237 | CompletedAt pgtype.Timestamptz `json:"completed_at"` |
| 238 | ExpiresAt time.Time `json:"expires_at"` |
| 239 | } |
| 240 | |
| 241 | type JobRun struct { |
| 242 | ID int64 `json:"id"` |
| 243 | Job string `json:"job"` |
| 244 | Slot time.Time `json:"slot"` |
| 245 | Status string `json:"status"` |
| 246 | Summary []byte `json:"summary"` |
| 247 | StartedAt time.Time `json:"started_at"` |
| 248 | FinishedAt pgtype.Timestamptz `json:"finished_at"` |
| 249 | } |
| 250 | |
| 251 | type Outbox struct { |
| 252 | Seq int64 `json:"seq"` |
| 253 | EventID uuid.UUID `json:"event_id"` |
| 254 | Subject string `json:"subject"` |
| 255 | Payload []byte `json:"payload"` |
| 256 | CreatedAt time.Time `json:"created_at"` |
| 257 | PublishedAt pgtype.Timestamptz `json:"published_at"` |
| 258 | TraceContext propagation.MapCarrier `json:"trace_context"` |
| 259 | } |
| 260 | |
| 261 | type Transaction struct { |
| 262 | ID uuid.UUID `json:"id"` |
| 263 | Description string `json:"description"` |
| 264 | CreatedAt time.Time `json:"created_at"` |
| 265 | } |