Skip to content

Commit a6dd189

Browse files
committed
fix(organizations): keep the get(id, callback) overload alongside testmode
Adding `testmode` through the usual params-only overload pair dropped the released `get(id, callback)` signature, turning that call into a TS2559 compile error and leaving the binder internally inconsistent (getCurrent and getPartnerStatus still accept a bare callback). Restore it with a four-overload form so both `get(id, callback)` and `get(id, params, callback)` type-check. Also cover OrganizationHelper.getDashboardUrl() for both the populated link and the null-when-absent case, matching the payments and orders helper tests.
1 parent dbd0b6b commit a6dd189

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/binders/organizations/OrganizationsBinder.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ export default class OrganizationsBinder extends Binder<OrganizationData, Organi
2222
* @since 3.2.0
2323
* @see https://docs.mollie.com/reference/get-organization
2424
*/
25-
public get(id: string, parameters?: GetParameters): Promise<Organization>;
25+
// Four overloads (rather than the params-only pair used by other binders) so the released
26+
// `get(id, callback)` signature keeps compiling while `testmode` is also accepted.
27+
public get(id: string): Promise<Organization>;
28+
public get(id: string, callback: Callback<Organization>): void;
29+
public get(id: string, parameters: GetParameters): Promise<Organization>;
2630
public get(id: string, parameters: GetParameters, callback: Callback<Organization>): void;
27-
public get(id: string, parameters?: GetParameters) {
31+
public get(id: string, parameters?: GetParameters | Callback<Organization>) {
2832
if (renege(this, this.get, ...arguments)) return;
2933
assertWellFormedId(id, 'organization');
30-
return this.networkClient.get<OrganizationData, Organization>(`${pathSegment}/${id}`, parameters);
34+
return this.networkClient.get<OrganizationData, Organization>(`${pathSegment}/${id}`, parameters as GetParameters | undefined);
3135
}
3236

3337
/**

tests/unit/resources/organizations.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const response = {
2323
href: 'https://docs.mollie.com/reference/v2/organizations-api/get-organization',
2424
type: 'text/html',
2525
},
26+
dashboard: {
27+
href: 'https://www.mollie.com/dashboard/org_12345678',
28+
type: 'text/html',
29+
},
2630
},
2731
};
2832

@@ -47,6 +51,7 @@ function testOrganization(organization) {
4751
href: 'https://docs.mollie.com/reference/v2/organizations-api/get-organization',
4852
type: 'text/html',
4953
});
54+
expect(organization.getDashboardUrl()).toBe('https://www.mollie.com/dashboard/org_12345678');
5055
}
5156

5257
test('getOrganization', () => {
@@ -69,6 +74,20 @@ test('getCurrentOrganization', () => {
6974
});
7075
});
7176

77+
test('getDashboardUrl returns null when the organization has no dashboard link', () => {
78+
return new NetworkMocker(getApiKeyClientProvider()).use(async ([mollieClient, networkMocker]) => {
79+
const responseWithoutDashboard = {
80+
...response,
81+
_links: { self: response._links.self, documentation: response._links.documentation },
82+
};
83+
networkMocker.intercept('GET', '/organizations/org_12345678', 200, responseWithoutDashboard).twice();
84+
85+
const organization = await bluster(mollieClient.organizations.get.bind(mollieClient.organizations))('org_12345678');
86+
87+
expect(organization.getDashboardUrl()).toBeNull();
88+
});
89+
});
90+
7291
test('getPartnerStatus', () => {
7392
const partnerStatusResponse = {
7493
resource: 'partner',

0 commit comments

Comments
 (0)