Skip to content

Commit ab438b4

Browse files
committed
feat: add identity recovery
1 parent 34765a4 commit ab438b4

File tree

8 files changed

+156
-92
lines changed

8 files changed

+156
-92
lines changed

example/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"repository": "https://github.com/pluggyai/pluggy-sdk-node",
2222
"dependencies": {
2323
"dotenv": "^8.2.0",
24-
"pluggy-sdk": "^0.3.0",
24+
"pluggy-sdk": "^0.4.0",
2525
"ts-node": "^8.10.2",
2626
"typescript": "^3.9.7"
2727
},

example/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ void (async function(): Promise<void> {
5858
})
5959
}
6060

61+
console.log(`Retrieving identity for item # ${item.id}`)
62+
const identity = await client.fetchIdentityByItemId(item.id)
63+
console.log(`Identity of the account name is ${identity.fullName}`)
64+
6165
console.log(`Deleting retrieved data for item #${item.id}`)
6266
await client.deleteItem(item.id)
6367
console.log(`Item deleted succesfully`)

lib/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pluggy-sdk",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",
66
"files": [

lib/src/baseApi.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import fetch from 'node-fetch'
33
type QueryParameters = { [key: string]: number | number[] | string | string[] | boolean }
44

55
export type ClientParams = {
6-
clientId: string;
7-
clientSecret: string;
8-
baseUrl?: string;
9-
showUrls?: boolean;
6+
clientId: string
7+
clientSecret: string
8+
baseUrl?: string
9+
showUrls?: boolean
1010
}
1111

1212
export class BaseApi {

lib/src/index.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
PageResponse,
1414
Webhook,
1515
WebhookEvent,
16+
IdentityResponse,
1617
} from './types'
1718

1819
/**
@@ -88,7 +89,10 @@ export class PluggyClient extends BaseApi {
8889
* @param parameters A map of name and value for the mfa requested
8990
* @returns {Item} a item object
9091
*/
91-
async updateItemMFA(id: string, parameters: { [key: string]: string } = undefined): Promise<Item> {
92+
async updateItemMFA(
93+
id: string,
94+
parameters: { [key: string]: string } = undefined
95+
): Promise<Item> {
9296
return this.createPostRequest(`items/${id}/mfa`, null, parameters)
9397
}
9498

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

161+
/**
162+
* Fetch the identity resource
163+
* @returns {IdentityResponse} an identity object
164+
*/
165+
async fetchIdentity(id: string): Promise<IdentityResponse> {
166+
return this.createGetRequest(`identity/${id}`)
167+
}
168+
169+
/**
170+
* Fetch the identity resource by it's Item ID
171+
* @returns {IdentityResponse} an identity object
172+
*/
173+
async fetchIdentityByItemId(itemId: string): Promise<IdentityResponse> {
174+
return this.createGetRequest(`identity?itemId=${itemId}`)
175+
}
176+
157177
/**
158178
* Fetch all available categories
159179
* @returns {Categories[]} an paging response of categories

0 commit comments

Comments
 (0)