import { Component, OnInit } from '@angular/core';
declare var PFMSDK: any;
@Component({
selector: 'app-root',
standalone: true,
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class MyComponent implements OnInit {
private pfmInstance: any;
token: string | null = null;
constructor() {}
ngOnInit() {}
fetchToken() {
fetch('https://<your_backend_api_that_calls_sdk_init_api_and_returns_token>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify('<API Body as per your API contracts>')
})
.then(response => response.json())
.then(data => {
this.token = data.token;
this.pfmInstance = new PFMSDK(this.token, env);
})
.catch(error => console.error('Error fetching token:', error));
}
openPFM() {
if (this.pfmInstance) {
this.pfmInstance.openPFM(
(error: any) => console.error('PFM SDK Error:', error),
() => console.log('PFM SDK Closed')
);
} else {
console.error('PFM SDK is not initialized!');
}
}
}