UNPKG

open-banking-pfm-sdk

Version:

The Open Banking PFM SDK uses Client classes and with **Promises** to get responses from the Open Banking PFM API in an easier way and structured as data models.

85 lines (68 loc) 2.51 kB
# Helpers ![Language](https://img.shields.io/badge/Language-JavaScript-yellow.svg) Helpers are functions that can complement the use of clients. ## How to use ### Build Clients This function is used to instantiate all clients with a single call. ```javascript import { buildClients } from "open-banking-pfm-sdk"; ... //The constructor receives an api key to validate access to all of its functions. This parameter is required. If you want to change the API Server Url you can do it passing it as second parameter. const SERVER_URL="http://tecbantest@ec2-3-21-18-54.us-east-2.compute.amazonaws.com:8081/api/v1/"; const clients = buildClients('XXXX-XXXX-XXXX', SERVER_URL) console.log(clients); ``` Output: ```console ClientDictionary { accountsClient: AccountsClient, banksClient: BanksClient, budgetsClient: IBudgetsClient; categoriesClient: ICategoriesClient; transactionsClient: TransactionsClient, usersClient: UsersClient } ``` ### Sign Up This function is used to register a client and returns an api key that must go in the header for access to the other functions. The following properties can be used in the request: | Name | Type | Required | Description | | --------------------- | ---------------------------------- | ---------------------------------- |---------------------------------- | | **name** | _string_ | **true** | Name to register. | | **firstLastName** | _string_ | **true** | First last name to register. | | **secondLastName** | _string_ | **true** | Second last name to register | | **email** | _string_ | **true** | The minimum amount of the transaction. | | **companyName** | _string_ | **true** | Company name to register. | | **username** | _string_ | **true** | Username to register. | | **password** | _string_ | **true** | Password to register. | | **countryShortName** | _string_ | **true** | Short name of country. | ```javascript import { signUp } from "open-banking-pfm-sdk"; ... const userForm = { name: "Juan", firstLastName: "Lopez", secondLastName: "Peres", email: "juan@email.com", companyName: "company", username: "juanlopez", password: "password", countryShortName: "MX" }; signUp(userForm) .then((data) => console.log(data)) .catch((error) => console.log(error)); ``` Output: ```console ClientUser { id: 350192605, name: "Juan", firstLastName: "Lopez", secondLastName: "Peres", email: "juan@email.com", companyName: "company", username: "juanlopez", apiKey: "b70e5b4d-a2b4-4249-b550-b0e588f68025" } ```