1- import { ApplicationDocumentStatus } from "./application"
2- import { Relationship } from "./common"
1+ import { Relationship , Tags , UnimplementedFields , UnimplementedRelationships } from "./common"
2+
3+ export type UnitEvent =
4+ AccountClosed |
5+ ApplicationDenied |
6+ ApplicationAwaitingDocuments |
7+ AuthorizationCreated |
8+ CardActivated |
9+ CardStatusChanged |
10+ CustomerCreated |
11+ DocumentApproved |
12+ DocumentRejected |
13+ PaymentClearing |
14+ PaymentReturned |
15+ PaymentSent |
16+ StatementsCreated |
17+ TransactionCreated
18+
19+ export interface BaseEvent {
20+ id : string
21+ type : string
22+ attributes : BaseEventAttributes
23+ relationships ?: UnimplementedRelationships
24+ }
325
4- export type UnitEvent = AccountClosed | ApplicationDenied | ApplicationDocumentStatus | ApplicationAwaitingDocuments | AuthorizationCreated | CardActivated | CardStatusChanged | CustomerCreated |
5- DocumentApproved | DocumentRejected | PaymentClearing | PaymentReturned | PaymentSent | StatementsCreated | TransactionCreated
26+ export interface BaseEventAttributes extends UnimplementedFields {
27+ createdAt : string
28+ tags ?: Tags
29+ }
630
7- interface AccountClosed {
8- id : string
31+
32+ export type AccountClosed = BaseEvent & {
933 type : "account.closed"
1034 attributes : {
11- createdAt : string
1235 closeReason : string
1336 }
1437 relationships : {
@@ -17,35 +40,29 @@ interface AccountClosed {
1740 }
1841}
1942
20- interface ApplicationDenied {
21- id : string
22- type : "authorization.created"
23- attributes : {
24- createdAt : string
25- }
43+ export type ApplicationDenied = BaseEvent & {
44+ type : "application.denied"
2645 relationships : {
2746 application : Relationship
28-
2947 }
3048}
3149
32- interface ApplicationAwaitingDocuments {
33- id : string
50+ export type ApplicationAwaitingDocuments = BaseEvent & {
3451 type : "application.awaitingDocuments"
35- attributes : {
36- createdAt : string
37- }
3852 relationships : {
3953 application : Relationship
4054 }
4155}
4256
43- interface AuthorizationCreated {
44- id : string
57+ export type AuthorizationCreated = BaseEvent & {
4558 type : "authorization.created"
4659 attributes : {
47- createdAt : string
60+ amount : number
4861 cardLast4Digits : string
62+ merchant : {
63+ name : string
64+ type : string
65+ }
4966 recurring : boolean
5067 }
5168 relationships : {
@@ -55,24 +72,18 @@ interface AuthorizationCreated {
5572 }
5673}
5774
58- interface CardActivated {
59- id : string
75+ export type CardActivated = BaseEvent & {
6076 type : "card.activated"
61- attributes : {
62- createdAt : string
63- }
6477 relationships : {
6578 card : Relationship
6679 account : Relationship
6780 customer : Relationship
6881 }
6982}
7083
71- interface CardStatusChanged {
72- id : string
84+ export type CardStatusChanged = BaseEvent & {
7385 type : "card.statusChanged"
7486 attributes : {
75- createdAt : string
7687 newStatus : string
7788 previousStatus : string
7889 }
@@ -83,35 +94,25 @@ interface CardStatusChanged {
8394 }
8495}
8596
86- interface CustomerCreated {
87- id : string
97+ export type CustomerCreated = BaseEvent & {
8898 type : "customer.created"
89- attributes : {
90- createdAt : string
91- }
9299 relationships : {
93100 customer : Relationship
94101 application : Relationship
95102 }
96103}
97104
98- interface DocumentApproved {
99- id : string
105+ export type DocumentApproved = BaseEvent & {
100106 type : "document.approved"
101- attributes : {
102- createdAt : string
103- }
104107 relationships : {
105108 document : Relationship
106109 application : Relationship
107110 }
108111}
109112
110- interface DocumentRejected {
111- id : string
113+ export type DocumentRejected = BaseEvent & {
112114 type : "document.rejected"
113115 attributes : {
114- createdAt : string
115116 reason : string
116117 reasonCode : string
117118 }
@@ -121,11 +122,9 @@ interface DocumentRejected {
121122 }
122123}
123124
124- interface PaymentClearing {
125- id : string
125+ export type PaymentClearing = BaseEvent & {
126126 type : "payment.clearing"
127127 attributes : {
128- createdAt : string
129128 previousStatus : string
130129 }
131130 relationships : {
@@ -135,11 +134,9 @@ interface PaymentClearing {
135134 }
136135}
137136
138- interface PaymentSent {
139- id : string
137+ export type PaymentSent = BaseEvent & {
140138 type : "payment.sent"
141139 attributes : {
142- createdAt : string
143140 previousStatus : string
144141 }
145142 relationships : {
@@ -149,11 +146,9 @@ interface PaymentSent {
149146 }
150147}
151148
152- interface PaymentReturned {
153- id : string
149+ export type PaymentReturned = BaseEvent & {
154150 type : "payment.returned"
155151 attributes : {
156- createdAt : string
157152 previousStatus : string
158153 }
159154 relationships : {
@@ -163,19 +158,16 @@ interface PaymentReturned {
163158 }
164159}
165160
166- interface StatementsCreated {
167- id : string
161+ export type StatementsCreated = BaseEvent & {
168162 type : "statements.created"
169163 attributes : {
170- createdAt : string
164+ period : string
171165 }
172166}
173167
174- interface TransactionCreated {
175- id : string
168+ export type TransactionCreated = BaseEvent & {
176169 type : "transaction.created"
177170 attributes : {
178- createdAt : string
179171 summary : string
180172 direction : "Credit" | "Debit"
181173 amount : string
0 commit comments