From b768607f16976cb90942725d80fd647936f18eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1ssio=20Marcos=20Goulart?= <3228151+CassioMG@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:49:47 -0300 Subject: [PATCH] Fix response objects returned on Customer functions (#142) --- .../src/walletSdk/Customer/index.ts | 6 +++--- .../typescript-wallet-sdk/test/customer.test.ts | 14 +++++++------- .../test/integration/anchorplatform.test.ts | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/@stellar/typescript-wallet-sdk/src/walletSdk/Customer/index.ts b/@stellar/typescript-wallet-sdk/src/walletSdk/Customer/index.ts index 1029bda..db36a3e 100644 --- a/@stellar/typescript-wallet-sdk/src/walletSdk/Customer/index.ts +++ b/@stellar/typescript-wallet-sdk/src/walletSdk/Customer/index.ts @@ -64,7 +64,7 @@ export class Sep12 { if (!resp.data.id) { throw new CustomerNotFoundError(params); } - return resp; + return resp.data; } /** @@ -104,7 +104,7 @@ export class Sep12 { : this.headers, }, ); - return resp; + return resp.data; } /** @@ -154,7 +154,7 @@ export class Sep12 { : this.headers, }, ); - return resp; + return resp.data; } /** diff --git a/@stellar/typescript-wallet-sdk/test/customer.test.ts b/@stellar/typescript-wallet-sdk/test/customer.test.ts index e2a0651..eb96976 100644 --- a/@stellar/typescript-wallet-sdk/test/customer.test.ts +++ b/@stellar/typescript-wallet-sdk/test/customer.test.ts @@ -35,18 +35,18 @@ describe("Customer", () => { type: customerType, }, }); - expect(resp.data.id).toBeTruthy(); - const { id } = resp.data; + expect(resp.id).toBeTruthy(); + const { id } = resp; // Get resp = await sep12.getCustomer({ id, type: customerType }); - expect(Object.keys(resp.data).sort()).toEqual( + expect(Object.keys(resp).sort()).toEqual( ["id", "provided_fields", "fields", "status"].sort(), ); - expect(Object.keys(resp.data?.provided_fields).sort()).toEqual( + expect(Object.keys(resp?.provided_fields).sort()).toEqual( ["first_name", "last_name", "email_address"].sort(), ); - expect(Object.keys(resp.data?.fields).sort()).toEqual( + expect(Object.keys(resp?.fields).sort()).toEqual( [ "bank_account_number", "bank_number", @@ -70,11 +70,11 @@ describe("Customer", () => { }, id, }); - expect(resp.data.id).toBeTruthy(); + expect(resp.id).toBeTruthy(); // Get again, check that the provided fields updated resp = await sep12.getCustomer({ id, type: customerType }); - expect(Object.keys(resp.data.fields).length).toBe(0); + expect(Object.keys(resp.fields).length).toBe(0); // Delete await sep12.delete(); diff --git a/@stellar/typescript-wallet-sdk/test/integration/anchorplatform.test.ts b/@stellar/typescript-wallet-sdk/test/integration/anchorplatform.test.ts index 6715f5d..a0256ee 100644 --- a/@stellar/typescript-wallet-sdk/test/integration/anchorplatform.test.ts +++ b/@stellar/typescript-wallet-sdk/test/integration/anchorplatform.test.ts @@ -60,7 +60,7 @@ describe("Anchor Platform Integration Tests", () => { bank_account_number: "12345", }, }); - expect(sep12Resp.data.id).toBeTruthy(); + expect(sep12Resp.id).toBeTruthy(); // SEP-6 deposit const sep6 = anchor.sep6();