Skip to content

Commit

Permalink
feat: events
Browse files Browse the repository at this point in the history
  • Loading branch information
brokeyourbike committed Apr 15, 2024
1 parent db9b42c commit 3f7e018
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 10 deletions.
5 changes: 3 additions & 2 deletions auth/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package auth
import "time"

type UserRegistered struct {
ID string
Date time.Time
ID string
Provider string
Timestamp time.Time
}
22 changes: 14 additions & 8 deletions bank/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,33 @@ import (
"github.com/google/uuid"
)

const AccountOpenEvent = "account-updated"
const AccountUpdatedEvent = "account-updated"
const AccountClosedEvent = "account-closed"

type AccountOpen struct {
ID uuid.UUID
Source string
Provider string
Name string
Owner string
Identifier string
Date time.Time
Currencies []string
Timestamp time.Time
}

type AccountUpdated struct {
ID uuid.UUID
Source string
Provider string
Name string
Owner string
Identifier string
Date time.Time
Currencies []string
Timestamp time.Time
}

type AccountClosed struct {
ID uuid.UUID
Source string
Reason string
Date time.Time
ID uuid.UUID
Provider string
Reason string
Timestamp time.Time
}
61 changes: 61 additions & 0 deletions bank/fx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package bank

import (
"time"

"github.com/google/uuid"
)

const FxCreatedEvent = "fx-created"
const FxSettledEvent = "fx-settled"
const FxFailedEvent = "fx-failed"

type FxCreated struct {
ID uuid.UUID
Provider string

BuyCurrency string
BuyAmount float64
SellCurrency string
SellAmount float64
MarginCurrency string
MarginAmount float64

Rate float64

SellAccountIdentifier string
BuyAccountIdentifier string
MarginAccountIdentifier string

ExternalIdentifier string
Timestamp time.Time
}

type FxSettled struct {
ID uuid.UUID
Provider string

BuyCurrency string
BuyAmount float64
SellCurrency string
SellAmount float64
MarginCurrency string
MarginAmount float64

Rate float64

SellAccountIdentifier string
BuyAccountIdentifier string
MarginAccountIdentifier string

ExternalIdentifier string
Timestamp time.Time
}

type FxFailed struct {
ID uuid.UUID
Provider string
Reason string
ExternalIdentifier string
Timestamp time.Time
}
47 changes: 47 additions & 0 deletions bank/transaction.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package bank

import (
"time"

"github.com/google/uuid"
)

const TransactionCreatedEvent = "transaction-created"
const TransactionSettledEvent = "transaction-settled"
const TransactionFailedEvent = "transaction-failed"

type TransactionCreated struct {
ID uuid.UUID
Provider string
Currency string
Amount float64
AccountIdentifier string
AccountOwner string
OppositeAccountIdentifier string
OppositeAccountOwner string
Reference string
ExternalIdentifier string
Timestamp time.Time
}

type TransactionSettled struct {
ID uuid.UUID
Provider string
Currency string
Amount float64
AccountIdentifier string
AccountOwner string
OppositeAccountIdentifier string
OppositeAccountOwner string
Reference string
ExternalIdentifier string
Timestamp time.Time
}

type TransactionFailed struct {
ID uuid.UUID
Provider string
Reason string
ExternalIdentifier string
Timestamp time.Time
}
2 changes: 2 additions & 0 deletions group.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package events

const (
BankingAuthEvents = "banking-events-auth"
BankingAccountEvents = "banking-events-accounts"
BankingTransactionEvents = "banking-events-transactions"
BankingFxEvents = "banking-events-fx"
)

0 comments on commit 3f7e018

Please sign in to comment.