Skip to content

Commit

Permalink
feat(sq-connect-plus): add Team API support
Browse files Browse the repository at this point in the history
  • Loading branch information
nadyaceban committed Aug 16, 2024
1 parent b6812cc commit ccc812c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@goparrot/square-connect-plus",
"version": "1.7.0",
"version": "1.8.0",
"private": false,
"description": "Extends the official Square Node.js SDK library with additional functionality",
"keywords": [
Expand Down Expand Up @@ -69,7 +69,7 @@
"devDependencies": {
"@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1",
"@goparrot/eslint-config": "^1.0.3",
"@goparrot/eslint-config": "1.1.1",
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.5",
"@types/lodash.camelcase": "^4.3.6",
Expand Down
16 changes: 16 additions & 0 deletions src/client/SquareClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
OrdersApi,
PaymentsApi,
RefundsApi,
TeamApi,
TransactionsApi,
} from 'square';
import { Client, DEFAULT_CONFIGURATION } from 'square';
Expand Down Expand Up @@ -207,6 +208,21 @@ export class SquareClient {
return this.proxy('invoicesApi', retryableMethods);
}

getTeamApi(
retryableMethods: FunctionKeys<TeamApi>[] = [
'createTeamMember',
'bulkCreateTeamMembers',
'bulkUpdateTeamMembers',
'searchTeamMembers',
'retrieveTeamMember',
'updateTeamMember',
'retrieveWageSetting',
'updateWageSetting',
],
): TeamApi {
return this.proxy('teamApi', retryableMethods);
}

private createOriginClient(accessToken: string, { configuration }: Partial<ISquareClientConfig>): Client {
return new Client({ ...configuration, accessToken });
}
Expand Down
9 changes: 8 additions & 1 deletion test/unit/client/SquareClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
OrdersApi,
PaymentsApi,
RefundsApi,
TeamApi,
TransactionsApi,
} from 'square';
import { describe } from 'mocha';
Expand Down Expand Up @@ -236,9 +237,15 @@ describe('SquareClient (unit)', (): void => {
});
});

describe('getInvoiceApi', (): void => {
describe('#getInvoiceApi', (): void => {
it('should return getInvoiceApi', (): void => {
expect(new SquareClient(accessToken).getInvoiceApi()).to.be.instanceOf(InvoicesApi);
});
});

describe('#getTeamApi', (): void => {
it('should return getTeamApi', (): void => {
expect(new SquareClient(accessToken).getTeamApi()).to.be.instanceOf(TeamApi);
});
});
});

0 comments on commit ccc812c

Please sign in to comment.