Skip to content

Commit

Permalink
Merge pull request #8 from finos-labs/update-dataformat
Browse files Browse the repository at this point in the history
updated data formats. restored accidentally overwritten changes to apps
  • Loading branch information
nkolba authored Sep 29, 2024
2 parents c6f0989 + b7905de commit 254fec9
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 85 deletions.
94 changes: 72 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,35 @@ Purchase ('fdc3.purchase')
```ts
interface Purchase {
type: string; //'fdc3.purchase'
amount: number;
vendor: string;
timestamp: number;
purchaser: string; //is there a common identifier for the purchaser? do we even want to include this (or is this too much PII)?
merchant: string; //identifier for the merchant/point of purchase - is there a common identifier
category?: string;
data: {
amount: number;
vendor: string;
date: string;
time: string;
userID: string; //is there a common identifier for the purchaser? do we even want to include this (or is this too much PII)?
pointOfSale: string; //identifier for the merchant/point of purchase - is there a common identifier
category?: 'Groceries'
| 'Dining'
| 'Home'
| 'Shopping'
| 'Travel'
| 'Fuel';
}


//example
{
type: 'fdc3.purchase',
data: {
amount: 30,
vendor: 'My Favorite Vendor',
date: '9/29/2024',
time: '3:28:10 PM',
userId: '[email protected]',
pointOfSale: 'POS_ID',
category: 'Groceries'
}
}
}

//example
Expand Down Expand Up @@ -71,29 +94,30 @@ Terms ('fdc3.Terms')
```ts
interface Terms {
type: string; //'fdc3.terms
points: number;
rate: number;
provider: Provider; //identifiers and display information of bank providing terms
}

interface Provider {
id: string;
name: string;
logo?: string;
data: {
points: number;
rate: number;
provider: string; //display name of bank providing terms
providerId: string; //identifier of bank providing terms
}
}

//example
{
type: 'fdc3.terms',
points: 13,
rate: 1,
provider: {
name: 'E*TRADE',
id: 'testApp1',
logo: './images/etrade.png'
}
data: {
points: 13,
rate: 1,
provider: {
name: 'E*TRADE',
id: 'testApp1',
logo: './images/etrade.png'
}
}
}


```

intent: MakePurchase (result)
Expand All @@ -113,7 +137,33 @@ intent: MakePurchase (result)
logo: './images/etrade.png'
}

```

```ts
intent: MakePurchase (result)
```ts
interface PurchaseConfirmation {
type: string; //fdc3.purchaseConfirmation
data: {
provider: Provider;
}
}

//example
{
type: 'fdc3.purchaseConfirmation',
data: {
provider: {
name: 'E*TRADE',
id: 'testApp1',
logo: './images/etrade.png'
}
}
}

```
## Roadmap
Expand Down
29 changes: 17 additions & 12 deletions app/bank-app1.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,28 @@
fdc3.addIntentListener('GetTerms', async (ctx) => {
return {
type: 'fdc3.terms',
points: 13,
rate: 1,
provider: {
name: 'E*TRADE',
id: 'testApp1',
logo: './images/etrade.png'
}
data: {
points: 13,
rate: 1,
provider: {
name: 'E*TRADE',
id: 'testApp1',
logo: './images/etrade.png'
}
}

};
});
fdc3.addIntentListener('MakePurchase', async (ctx) => {
return {
type: 'fdc3.purchaseConfirmation',
provider: {
name: 'E*TRADE',
id: 'testApp1',
logo: './images/etrade.png'
}
data: {
provider: {
name: 'E*TRADE',
id: 'testApp1',
logo: './images/etrade.png'
}
}
};
});
}
Expand Down
28 changes: 16 additions & 12 deletions app/bank-app2.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,27 @@
fdc3.addIntentListener('GetTerms', async (ctx) => {
return {
type: 'fdc3.terms',
points: 25,
rate: .8,
provider: {
name: 'Capital One',
id: 'testApp2',
logo: './images/capitalone.png'
}
data: {
points: 25,
rate: .8,
provider: {
name: 'Capital One',
id: 'testApp2',
logo: './images/capitalone.png'
}
}
};
});
fdc3.addIntentListener('MakePurchase', async (ctx) => {
return {
type: 'fdc3.purchaseConfirmation',
provider: {
name: 'Capital One',
id: 'testApp2',
logo: './images/capitalone.png'
}
data: {
provider: {
name: 'Capital One',
id: 'testApp2',
logo: './images/capitalone.png'
}
}
};
});
}
Expand Down
28 changes: 16 additions & 12 deletions app/bank-app3.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,27 @@
fdc3.addIntentListener('GetTerms', async (ctx) => {
return {
type: 'fdc3.terms',
points: 11,
rate: .6,
provider: {
name: 'Klarna',
id: 'testApp3',
logo: './images/klarna.png'
}
data: {
points: 11,
rate: .6,
provider: {
name: 'Klarna',
id: 'testApp3',
logo: './images/klarna.png'
}
}
};
});
fdc3.addIntentListener('MakePurchase', async (ctx) => {
return {
type: 'fdc3.purchaseConfirmation',
provider: {
name: 'Klarna',
id: 'testApp3',
logo: './images/klarna.png'
}
data: {
provider: {
name: 'Klarna',
id: 'testApp3',
logo: './images/klarna.png'
}
}
};
});
}
Expand Down
2 changes: 0 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
onChannelJoined: (evt) => console.log('channel joined', evt),
onChannelLeft: () => console.log('channel left'),
onFDC3Ready: async (fdc3) => {
const info = await fdc3.getInfo();
console.log('onFDC3Ready - info', info);
window.fdc3 = fdc3;
const purchaseButton = document.getElementById('initPurchaseButton');
if (purchaseButton){
Expand Down
55 changes: 30 additions & 25 deletions app/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
let selected = null;
const purchase = {
type: 'fdc3.purchase',
amount: 30,
vendor: 'My Favorite Vendor',
timestamp: new Date().getDate(),
purchaser: 'me',
merchant: 'you',
category: 'stuff'
data: {
amount: 30,
vendor: 'My Favorite Vendor',
time: new Date().toLocaleTimeString(),
date: new Date().toLocaleDateString(),
userID: '[email protected]',
pointOfSale: 'POS1',
category: 'Groceries'
}
};


const selectCard = (id) => {
const modal = document.getElementById('modal');
const cards = modal.querySelectorAll('.card');
Expand All @@ -29,23 +33,24 @@ const launchBankApp = (index) => {
};

const showSuccessModal = (message, purchaseResult) => {
const modal = document.getElementById('successModal');
const modalCTA = document.getElementById('successCTA');
modalCTA.addEventListener('click', () => { hideModal('successModal');});
if (purchaseResult.provider.logo){
const logoContainer = modal.querySelector('.logo');
if (logoContainer){
let target = logoContainer.querySelector('img');
if (!target){
target = document.createElement('img');
logoContainer.appendChild(target);
}
target.src = purchaseResult.provider.logo;

const modal = document.getElementById('successModal');
const modalCTA = document.getElementById('successCTA');
modalCTA.addEventListener('click', () => { hideModal('successModal');});
if (purchaseResult.provider.logo){
const logoContainer = modal.querySelector('.logo');
if (logoContainer){
let target = logoContainer.querySelector('img');
if (!target){
target = document.createElement('img');
logoContainer.appendChild(target);
}
target.src = purchaseResult.provider.logo;
}
}
}
const modalText = modal.querySelector('.textContainer .text');
modalText.textContent = message;
showModal('successModal');
const modalText = modal.querySelector('.textContainer .text');
modalText.textContent = message;
showModal('successModal');
}

const initializeModal = () => {
Expand Down Expand Up @@ -86,7 +91,7 @@ const initializeModal = () => {
const purchaseResponse = await fdc3?.raiseIntent('MakePurchase', purchase, selected);
const purchaseResult = await purchaseResponse.getResult();
hideModal();
showSuccessModal('Purchase Successful', purchaseResult);
showSuccessModal('Purchase Successful', purchaseResult.data);
});
actionRow.appendChild(purchaseButton);
modal.appendChild(actionRow);
Expand Down Expand Up @@ -164,8 +169,8 @@ const getTerms = async () => {
initializeModal();
appIntents.apps.forEach(async (app) => {
const result = await fdc3.raiseIntent('GetTerms', purchase, {appId: app.appId});
const data = await result.getResult();
renderBankResult(data);
const contextData = await result.getResult();
renderBankResult(contextData.data);
});
showModal();
};
15 changes: 15 additions & 0 deletions app/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ body {
font-size: 24px;
}

.card .header .logo img {
max-height: 60px;
}

.card .content {
display: flex;
flex-flow: column;
Expand Down Expand Up @@ -234,6 +238,17 @@ body {
font-size: 24px;
font-weight: 700;
}

#succesModal .row {
display: flex;
flex-flow: row;
justify-content: center;
}


#successModal .logo img {
height: 60px;
}

#successModal .cta {
display: flex;
Expand Down

0 comments on commit 254fec9

Please sign in to comment.