NAV
typescript csharp

Packages (@tfso/events, Tfso.Events)

This repo currently produces two packages, one for .NET/C# and one for TS/JS. The package includes:

Examples of publishing events

import { 
    TfsoEventBridgeClient,
    TfsoEventApiClient,
    TfsoModules
} from "@tfso/events"
import { 
    BankTestCreatedV1Event,
    BankTestCreatedV1Detail,
    BankTestCreatedV1FavoriteColor 
} from '@tfso/events/lib/models/bank-test-created-v1'

// Creating the event
const paymentReceivedDetail = new BankTestCreatedV1Detail({
    content: { 
        firstName: "Karl", 
        lastName: "Marx", 
        registrationDate: new Date(), 
        favoriteColor: BankTestCreatedV1FavoriteColor.Red,
    },
    timestamp: new Date(),
    metadata: {}
})
const paymentReceivedEvent = new BankTestCreatedV1Event({ detail: paymentReceivedDetail })

// Creating the API client
const apiClient = new TfsoEventApiClient({
    environment: 'dev',
    auth0ApplicationId: '<CLIENT_ID>',
    auth0SecretId: '<SECRET_ID>',
})

// Publishing with the API client
await apiClient.publish(paymentReceivedEvent)

// Creating the EventBridge Client
const eventBridgeClient = new TfsoEventBridgeClient({
    busEnvironment: 'dev',
    eventBusName: `tfso-${TfsoModules.Bank}-events`
})

// Publishing with the Event Bridge Client
await eventBridgeClient.publish(paymentReceivedEvent)

Auth

To use the TfsoApiClient - or send events to POST https://events.tfso.io/events, the caller needs to authenticate first. This is done by using Auth0, using an M2M token with the https://events.24sevenoffice.com audience, and scope that matches the module your event is in. I.e. if your event is crm.customer:created@v1 - your Auth0 application needs to have the crm scope for the events audience.

The AWS Event Hub is available in 3 environments, dev, pre-prod and prod:

This means that you'll need to add the Events audience and the scope in both tenants.

com.24sevenoffice.banktransfer

bank.test:created@v1

{
  "firstName": "John",
  "lastName": "Doe",
  "age": 30,
  "accountStatement": 100000,
  "favoriteColor": "Red",
  "registrationDate": "2023-07-04T08:05:58.330Z",
  "address": {
    "street": "221B Baker Street",
    "city": "London"
  }
}

User details schema

Properties

Name Type Required Restrictions Description
firstName string true none First name of the user
lastName string true none Last name of the user
age number false none Age of the user, which they can choose to leave out
accountStatement number(decimal) false none How much moneys they have, since it is decimal format,
favoriteColor string true none An enum representing a color
registrationDate string(date) true none Registration date of the user
address object false none Optional address details
» street string true none Street address
» city string true none City

Enumerated Values

Property Value
favoriteColor Red
favoriteColor Green
favoriteColor Blue

bank.transaction:created@v1

{
  "transactionId": "123e4567-e89b-12d3-a456-426614174000",
  "license": "2947b4ae-0d40-447b-886f-dcd3aa11648b;693081080913543;1198",
  "status": {
    "text": "created",
    "code": 100
  },
  "sourceUris": [
    "urn:;693081080913543;@tfso:generalledger:voucherid;transactionid:185B6BAE-C8B5-4CFC-98D2-89092D0046D0;5EBC82E1-C189-4373-9AAE-2AFF95259C9C"
  ]
}

User details schema

Properties

Name Type Required Restrictions Description
transactionId string true none the id of the transaction. Found in id.value in a transaction
license string true none The license of the user performing the action. Same as 24SevenOffice's x-tfso-license request header
status object true none The new status of the transaction after the event occurred
» text string true none A textual name of the status
» code number true none A numerical code of the status
sourceUris [string] true none none

Enumerated Values

Property Value
text created

bank.transaction:deleted@v1

{
  "transactionId": "123e4567-e89b-12d3-a456-426614174000",
  "license": "2947b4ae-0d40-447b-886f-dcd3aa11648b;693081080913543;1198",
  "status": {
    "text": "created",
    "code": 100
  }
}

User details schema

Properties

Name Type Required Restrictions Description
transactionId string true none the id of the transaction. Found in id.value in a transaction
license string true none The license of the user performing the action. Same as 24SevenOffice's x-tfso-license request header
status object true none The new status of the transaction after the event occurred
» text string true none A textual name of the status
» code number true none A numerical code of the status

Enumerated Values

Property Value
text created
text approved
text inProgress
text stopped
text confirmedPaid
text posted

bank.transaction:statuschanged@v1

{
  "transactionId": "123e4567-e89b-12d3-a456-426614174000",
  "license": "2947b4ae-0d40-447b-886f-dcd3aa11648b;693081080913543;1198",
  "status": {
    "text": "approved",
    "code": 200
  },
  "deletionStatus": {
    "new": "deleted",
    "old": "active"
  }
}

User details schema

Properties

Name Type Required Restrictions Description
transactionId string true none the id of the transaction. Found in id.value in a transaction
license string true none The license of the user performing the action. Same as 24SevenOffice's x-tfso-license request header
status object true none The new status of the transaction after the event occurred
» text string true none A textual name of the status
» code number true none A numerical code of the status
deletionStatus object true none The deletion status of the transaction before and after the event occurred
» new string true none The new delete state of the transaction after the event occurred
» old string true none The old delete state of the transaction before the event occurred

Enumerated Values

Property Value
text approved
text inProgress
text stopped
text confirmedPaid
text posted
new deleted
new active
old deleted
old active