Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib/managers/organizationsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { Organization } from '../resources/organization';

export class OrganizationsManager extends ManagerMixin<Organization> {
static resource = 'organization';
static methods = ['create'];
static methods = ['create', 'update'];
}
15 changes: 15 additions & 0 deletions src/spec/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading