Skip to content

Instantly share code, notes, and snippets.

@StephenBrown2
Last active June 8, 2021 06:33
Show Gist options
  • Save StephenBrown2/7f226ecb15d81c4f21152474134206b0 to your computer and use it in GitHub Desktop.
Save StephenBrown2/7f226ecb15d81c4f21152474134206b0 to your computer and use it in GitHub Desktop.
Simple transaction struct format from json
// This file was generated from JSON Schema using quicktype, do not modify it directly.
// To parse and unparse this JSON data, add this code to your project and do:
//
// txns, err := UnmarshalTransactionList(bytes)
// bytes, err = txns.Marshal()
package main
import "encoding/json"
func UnmarshalTransactionList(data []byte) (TransactionList, error) {
var r TransactionList
err := json.Unmarshal(data, &r)
return r, err
}
func (r *TransactionList) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type TransactionList struct {
Transactions []Transaction `json:"transactions"`
Offset int64 `json:"offset"`
}
type Transaction struct {
UUID string `json:"uuid"`
UserID string `json:"user_id"`
RecordType RecordType `json:"record_type"`
TransactionType TransactionType `json:"transaction_type"`
BookkeepingType BookkeepingType `json:"bookkeeping_type"`
IsHold bool `json:"is_hold"`
IsActive bool `json:"is_active"`
RunningBalance int64 `json:"running_balance"`
RawDescription string `json:"raw_description"`
Description string `json:"description"`
Categories []Category `json:"categories"`
Times Times `json:"times"`
Amounts Amounts `json:"amounts"`
CorrelationID string `json:"correlation_id"`
AccountID string `json:"account_id"`
Partner Partner `json:"partner"`
Attachments []interface{} `json:"attachments"` // This would be for check images or user-uploaded photos or files to associate with a transaction.
Badges []Badge `json:"badges"`
IsEngramEligible bool `json:"is_engram_eligible"`
Balances *Balances `json:"balances,omitempty"`
IndisputableReason *IndisputableReason `json:"indisputable_reason,omitempty"`
Geo *Geo `json:"geo,omitempty"`
InitiatedBy *string `json:"initiated_by,omitempty"`
Memo *string `json:"memo,omitempty"`
ArrowayID *ArrowayID `json:"arroway_id,omitempty"`
}
type Amounts struct {
Amount int64 `json:"amount"`
Cleared int64 `json:"cleared"`
Fees int64 `json:"fees"`
Cashback int64 `json:"cashback"`
Base int64 `json:"base"`
Tip *int64 `json:"tip,omitempty"`
}
type ArrowayID struct {
Type Type `json:"type"`
ID string `json:"id"`
}
type Badge struct {
Value Value `json:"value"`
Text Text `json:"text"`
Abbr Abbr `json:"abbr"`
Color *Color `json:"color"`
}
type Color struct {
R int64 `json:"r"`
G int64 `json:"g"`
B int64 `json:"b"`
A int64 `json:"a"`
}
type Balances struct {
Total int64 `json:"total"`
SafeToSpend int64 `json:"safe_to_spend"`
Bills int64 `json:"bills"`
Deposits int64 `json:"deposits"`
Pending int64 `json:"pending"`
Goals int64 `json:"goals"`
Expenses int64 `json:"expenses"`
Available int64 `json:"available"`
Protected int64 `json:"protected"`
ProtectedIncoming int64 `json:"protected_incoming"`
Overspent int64 `json:"overspent"`
}
type Category struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Folder Folder `json:"folder"`
FolderID int64 `json:"folder_id"`
Emoji EmojiEnum `json:"emoji"`
}
type Geo struct {
Street *string `json:"street,omitempty"`
City string `json:"city"`
State State `json:"state"`
Zip string `json:"zip"`
Timezone Timezone `json:"timezone"`
Country *Country `json:"country,omitempty"`
Lat *float64 `json:"lat,omitempty"`
Lon *float64 `json:"lon,omitempty"`
}
type Times struct {
WhenRecorded int64 `json:"when_recorded"`
WhenRecordedLocal string `json:"when_recorded_local"`
WhenReceived int64 `json:"when_received"`
LastModified int64 `json:"last_modified"`
LastTxvia int64 `json:"last_txvia"`
}
type Type string
const (
SharedAccountTransfer Type = "SHARED_ACCOUNT_TRANSFER"
)
type Abbr string
const (
AbbrPayment Abbr = "Payment"
AbbrPending Abbr = "Pending"
AbbrTransfer Abbr = "Transfer"
Check Abbr = "Check"
Fee Abbr = "Fee"
Tip Abbr = "Tip"
)
type Text string
const (
ATMFee Text = "ATM Fee"
CheckDeposit Text = "Check Deposit"
TextPayment Text = "Payment"
TextPending Text = "Pending"
TextTransfer Text = "Transfer"
Tipped Text = "Tipped"
)
type Value string
const (
Payment Value = "PAYMENT"
Transfer Value = "TRANSFER"
ValueATMFEE Value = "ATM_FEE"
ValueCHECKDEPOSIT Value = "CHECK_DEPOSIT"
ValueHOLD Value = "HOLD"
ValueTIP Value = "TIP"
)
type BookkeepingType string
const (
Credit BookkeepingType = "credit"
Debit BookkeepingType = "debit"
)
type EmojiEnum string
const (
Ambitious EmojiEnum = "\U0001f4b5"
Braggadocious EmojiEnum = "\U0001f4aa"
Cunning EmojiEnum = "✈️"
Emoji EmojiEnum = "\U0001f697"
Empty EmojiEnum = "\U0001f3db"
Fluffy EmojiEnum = "\U0001f37d"
Frisky EmojiEnum = "\U0001f381"
Hilarious EmojiEnum = "\U0001f50c"
Indecent EmojiEnum = "\U0001f3e2"
Indigo EmojiEnum = "\U0001f937"
Magenta EmojiEnum = "\U0001f3e0"
Mischievous EmojiEnum = "\U0001f6cd"
Purple EmojiEnum = "\U0001f30e"
Sticky EmojiEnum = "\U0001f4f1"
Tentacled EmojiEnum = "\U0001f4ce"
The1 EmojiEnum = "\U0001f3e5"
The2 EmojiEnum = "\U0001f4b8"
)
type Folder string
const (
Business Folder = "Business"
Culture Folder = "Culture"
Fees Folder = "Fees"
Financial Folder = "Financial"
FoodDrink Folder = "Food & Drink"
GiftsDonations Folder = "Gifts & Donations"
HealthMedical Folder = "Health & Medical"
Home Folder = "Home"
Income Folder = "Income"
Office Folder = "Office"
Personal Folder = "Personal"
SportsFitness Folder = "Sports & Fitness"
Technology Folder = "Technology"
Transportation Folder = "Transportation"
Travel Folder = "Travel"
Uncategorized Folder = "Uncategorized"
Utilities Folder = "Utilities"
)
type Country string
const (
Usa Country = "USA"
)
type State string
const (
Ar State = "AR"
Az State = "AZ"
CA State = "CA"
Co State = "CO"
IL State = "IL"
Mn State = "MN"
Ny State = "NY"
Tn State = "TN"
Tx State = "TX"
Ut State = "UT"
Wa State = "WA"
)
type Timezone string
const (
AmericaChicago Timezone = "America/Chicago"
AmericaDenver Timezone = "America/Denver"
AmericaLosAngeles Timezone = "America/Los_Angeles"
AmericaNewYork Timezone = "America/New_York"
AmericaPhoenix Timezone = "America/Phoenix"
)
type Partner string
const (
Bbva Partner = "bbva"
)
type RecordType string
const (
Journalentry RecordType = "JOURNALENTRY"
RecordTypeHOLD RecordType = "HOLD"
)
type TransactionType string
const (
ATMWithdrawal TransactionType = "atm_withdrawal"
Ach TransactionType = "ach"
BillPayment TransactionType = "bill_payment"
ForcePaid TransactionType = "force_paid"
InterestCredit TransactionType = "interest_credit"
PinPurchase TransactionType = "pin_purchase"
ProtectedGoalAccountTransfer TransactionType = "protected_goal_account_transfer"
Refund TransactionType = "refund"
SharedTransfer TransactionType = "shared_transfer"
SignatureCredit TransactionType = "signature_credit"
SignaturePurchase TransactionType = "signature_purchase"
TransactionTypeCheckDeposit TransactionType = "check_deposit"
TransactionTypeFee TransactionType = "fee"
)
type IndisputableReason string
const (
IndisputablePending IndisputableReason = "Pending transactions must finalize before they can be disputed."
IndisputableACH IndisputableReason = "Please contact Support to dispute ACH transfers."
IndisputableBillPay IndisputableReason = "Please contact Support to dispute bill pay transactions."
IndisputableInternal IndisputableReason = "This is an internal transaction that was initiated by Simple or an account owner and cannot be disputed."
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment