From f07668d120e4f8390a79dade673ba6ff50c831cf Mon Sep 17 00:00:00 2001 From: Francisca Otero Date: Fri, 6 Nov 2026 12:04:50 +0000 Subject: [PATCH] feat(organizations): add update for PATCH /v1/organizations/{id} Co-authored-by: fin-compose[bot] <255610621+fin-compose[bot]@users.noreply.github.com> --- README.md | 13 ++++++++++--- src/lib/managers/organizationsManager.ts | 2 +- src/spec/integration.spec.ts | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc3f89d..ef09096 100644 --- a/README.md +++ b/README.md @@ -422,11 +422,9 @@ const refreshIntent = await fintocClient.refreshIntents.create({ ### Organizations -Creating an organization requires a JWS private key and a live API key. It returns the created organization, or the existing one if it was already created: +Creating an organization returns the created organization, or the existing one if it was already created. With a test API key it returns a mock organization: ```javascript -const fintocClient = new Fintoc('your_api_key', 'path/to/private_key.pem'); - const organization = await fintocClient.organizations.create({ name: 'Empresa SpA', tax_id: '11.111.111-1', @@ -436,6 +434,15 @@ const organization = await fintocClient.organizations.create({ }); ``` +You can also update an organization's founder email: + +```javascript +const updatedOrganization = await fintocClient.organizations.update(organization.id, { + founder_email: 'richard@piedpiper.com', + previous_founder_email: 'jared@piedpiper.com', +}); +``` + ### Webhook Signature Validation To ensure the authenticity of incoming webhooks from Fintoc, you should always validate the signature. The SDK provides a `WebhookSignature` class to verify the `Fintoc-Signature` header diff --git a/src/lib/managers/organizationsManager.ts b/src/lib/managers/organizationsManager.ts index ea8a8a1..4326f49 100644 --- a/src/lib/managers/organizationsManager.ts +++ b/src/lib/managers/organizationsManager.ts @@ -3,5 +3,5 @@ import { Organization } from '../resources/organization'; export class OrganizationsManager extends ManagerMixin { static resource = 'organization'; - static methods = ['create']; + static methods = ['create', 'update']; } diff --git a/src/spec/integration.spec.ts b/src/spec/integration.spec.ts index 43373fb..8c34a9c 100644 --- a/src/spec/integration.spec.ts +++ b/src/spec/integration.spec.ts @@ -691,6 +691,21 @@ test('fintoc.organizations.create() with idempotency key', async (t) => { t.is(organization.json.idempotency_key, undefined); }); +test('fintoc.organizations.update()', async (t) => { + const ctx: any = t.context; + const organizationId = 'org_8anqVLlBC8ROodem'; + const organizationData = { + founder_email: 'new.founder@example.com', + previous_founder_email: 'founder@example.com', + }; + const organization = await ctx.fintoc.organizations.update(organizationId, organizationData); + + t.is(organization.method, 'patch'); + t.is(organization.url, `v1/organizations/${organizationId}`); + t.is(organization.json.founder_email, organizationData.founder_email); + t.is(organization.json.previous_founder_email, organizationData.previous_founder_email); +}); + test('fintoc.disputes.list()', async (t) => { const ctx: any = t.context; const disputes = await ctx.fintoc.disputes.list();