Skip to content

Commit

Permalink
feat: add identity recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabrielpanga committed Sep 30, 2020
1 parent 34765a4 commit ab438b4
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 92 deletions.
8 changes: 4 additions & 4 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"repository": "https://github.com/pluggyai/pluggy-sdk-node",
"dependencies": {
"dotenv": "^8.2.0",
"pluggy-sdk": "^0.3.0",
"pluggy-sdk": "^0.4.0",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
},
Expand Down
4 changes: 4 additions & 0 deletions example/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ void (async function(): Promise<void> {
})
}

console.log(`Retrieving identity for item # ${item.id}`)
const identity = await client.fetchIdentityByItemId(item.id)
console.log(`Identity of the account name is ${identity.fullName}`)

console.log(`Deleting retrieved data for item #${item.id}`)
await client.deleteItem(item.id)
console.log(`Item deleted succesfully`)
Expand Down
2 changes: 1 addition & 1 deletion lib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pluggy-sdk",
"version": "0.3.0",
"version": "0.4.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down
8 changes: 4 additions & 4 deletions lib/src/baseApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import fetch from 'node-fetch'
type QueryParameters = { [key: string]: number | number[] | string | string[] | boolean }

export type ClientParams = {
clientId: string;
clientSecret: string;
baseUrl?: string;
showUrls?: boolean;
clientId: string
clientSecret: string
baseUrl?: string
showUrls?: boolean
}

export class BaseApi {
Expand Down
22 changes: 21 additions & 1 deletion lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
PageResponse,
Webhook,
WebhookEvent,
IdentityResponse,
} from './types'

/**
Expand Down Expand Up @@ -88,7 +89,10 @@ export class PluggyClient extends BaseApi {
* @param parameters A map of name and value for the mfa requested
* @returns {Item} a item object
*/
async updateItemMFA(id: string, parameters: { [key: string]: string } = undefined): Promise<Item> {
async updateItemMFA(
id: string,
parameters: { [key: string]: string } = undefined
): Promise<Item> {
return this.createPostRequest(`items/${id}/mfa`, null, parameters)
}

Expand Down Expand Up @@ -154,6 +158,22 @@ export class PluggyClient extends BaseApi {
return this.createGetRequest(`investments/${id}`)
}

/**
* Fetch the identity resource
* @returns {IdentityResponse} an identity object
*/
async fetchIdentity(id: string): Promise<IdentityResponse> {
return this.createGetRequest(`identity/${id}`)
}

/**
* Fetch the identity resource by it's Item ID
* @returns {IdentityResponse} an identity object
*/
async fetchIdentityByItemId(itemId: string): Promise<IdentityResponse> {
return this.createGetRequest(`identity?itemId=${itemId}`)
}

/**
* Fetch all available categories
* @returns {Categories[]} an paging response of categories
Expand Down
Loading

0 comments on commit ab438b4

Please sign in to comment.