@tryfinch/finch-api 5.22.5 → 5.22.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/client.d.ts +204 -0
- package/client.d.ts.map +1 -0
- package/client.js +218 -0
- package/client.js.map +1 -0
- package/client.mjs +191 -0
- package/client.mjs.map +1 -0
- package/index.d.mts +5 -203
- package/index.d.ts +5 -203
- package/index.d.ts.map +1 -1
- package/index.js +10 -192
- package/index.js.map +1 -1
- package/index.mjs +5 -189
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +369 -0
- package/src/index.ts +6 -367
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/index.js
CHANGED
|
@@ -23,201 +23,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
__setModuleDefault(result, mod);
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
|
-
var
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
27
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
const Core = __importStar(require("./core.js"));
|
|
30
|
+
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.FinchError = exports.fileFromPath = exports.toFile = exports.Finch = void 0;
|
|
30
31
|
const Errors = __importStar(require("./error.js"));
|
|
31
32
|
const Uploads = __importStar(require("./uploads.js"));
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* API Client for interfacing with the Finch API.
|
|
38
|
-
*
|
|
39
|
-
* @param {string | null | undefined} [opts.accessToken]
|
|
40
|
-
* @param {string | null | undefined} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
|
|
41
|
-
* @param {string | null | undefined} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
|
|
42
|
-
* @param {string | null | undefined} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
|
|
43
|
-
* @param {string | null | undefined} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
|
|
44
|
-
* @param {string | null | undefined} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
|
|
45
|
-
* @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
|
|
46
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
47
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
48
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
49
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
50
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
51
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
52
|
-
*/
|
|
53
|
-
constructor({ baseURL = Core.readEnv('FINCH_BASE_URL'), accessToken = null, clientId = Core.readEnv('FINCH_CLIENT_ID') ?? null, clientSecret = Core.readEnv('FINCH_CLIENT_SECRET') ?? null, sandboxClientId = Core.readEnv('FINCH_SANDBOX_CLIENT_ID') ?? null, sandboxClientSecret = Core.readEnv('FINCH_SANDBOX_CLIENT_SECRET') ?? null, webhookSecret = Core.readEnv('FINCH_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
|
|
54
|
-
const options = {
|
|
55
|
-
accessToken,
|
|
56
|
-
clientId,
|
|
57
|
-
clientSecret,
|
|
58
|
-
sandboxClientId,
|
|
59
|
-
sandboxClientSecret,
|
|
60
|
-
webhookSecret,
|
|
61
|
-
...opts,
|
|
62
|
-
baseURL: baseURL || `https://api.tryfinch.com`,
|
|
63
|
-
};
|
|
64
|
-
super({
|
|
65
|
-
baseURL: options.baseURL,
|
|
66
|
-
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
67
|
-
httpAgent: options.httpAgent,
|
|
68
|
-
maxRetries: options.maxRetries,
|
|
69
|
-
fetch: options.fetch,
|
|
70
|
-
});
|
|
71
|
-
this.accessTokens = new API.AccessTokens(this);
|
|
72
|
-
this.hris = new API.HRIS(this);
|
|
73
|
-
this.providers = new API.Providers(this);
|
|
74
|
-
this.account = new API.Account(this);
|
|
75
|
-
this.webhooks = new API.Webhooks(this);
|
|
76
|
-
this.requestForwarding = new API.RequestForwarding(this);
|
|
77
|
-
this.jobs = new API.Jobs(this);
|
|
78
|
-
this.sandbox = new API.Sandbox(this);
|
|
79
|
-
this._options = options;
|
|
80
|
-
this.accessToken = accessToken;
|
|
81
|
-
this.clientId = clientId;
|
|
82
|
-
this.clientSecret = clientSecret;
|
|
83
|
-
this.sandboxClientId = sandboxClientId;
|
|
84
|
-
this.sandboxClientSecret = sandboxClientSecret;
|
|
85
|
-
this.webhookSecret = webhookSecret;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* DEPRECATED: use client.accessTokens.create instead.
|
|
89
|
-
*/
|
|
90
|
-
getAccessToken(code, options) {
|
|
91
|
-
if (!this.clientId) {
|
|
92
|
-
throw new Error('Expected the clientId to be set in order to call getAccessToken');
|
|
93
|
-
}
|
|
94
|
-
if (!this.clientSecret) {
|
|
95
|
-
throw new Error('Expected the clientSecret to be set in order to call getAccessToken');
|
|
96
|
-
}
|
|
97
|
-
return this.post('/auth/token', {
|
|
98
|
-
body: {
|
|
99
|
-
client_id: this.clientId,
|
|
100
|
-
client_secret: this.clientSecret,
|
|
101
|
-
code: code,
|
|
102
|
-
redirect_uri: options?.redirectUri,
|
|
103
|
-
},
|
|
104
|
-
headers: {
|
|
105
|
-
authorization: null,
|
|
106
|
-
},
|
|
107
|
-
}).then((response) => response.access_token);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Returns the authorization url which can be visited in order to obtain an
|
|
111
|
-
* authorization code from Finch. The authorization code can then be exchanged for
|
|
112
|
-
* an access token for the Finch api by calling get_access_token().
|
|
113
|
-
*/
|
|
114
|
-
getAuthURL({ products, redirectUri, sandbox, }) {
|
|
115
|
-
if (!this.clientId) {
|
|
116
|
-
throw new Error('Expected the clientId to be set in order to call getAuthUrl');
|
|
117
|
-
}
|
|
118
|
-
const url = new URL('/authorize', 'https://connect.tryfinch.com/authorize');
|
|
119
|
-
url.search = this.stringifyQuery({
|
|
120
|
-
client_id: this.clientId,
|
|
121
|
-
products: products,
|
|
122
|
-
redirect_uri: redirectUri,
|
|
123
|
-
sandbox: sandbox,
|
|
124
|
-
});
|
|
125
|
-
return url.toString();
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Returns a copy of the current Finch client with the given access token for
|
|
129
|
-
* authentication.
|
|
130
|
-
*/
|
|
131
|
-
withAccessToken(accessToken) {
|
|
132
|
-
return new Finch({ ...this._options, accessToken });
|
|
133
|
-
}
|
|
134
|
-
defaultQuery() {
|
|
135
|
-
return this._options.defaultQuery;
|
|
136
|
-
}
|
|
137
|
-
defaultHeaders(opts) {
|
|
138
|
-
return {
|
|
139
|
-
...super.defaultHeaders(opts),
|
|
140
|
-
'Finch-API-Version': '2020-09-17',
|
|
141
|
-
...this._options.defaultHeaders,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
validateHeaders(headers, customHeaders) {
|
|
145
|
-
if (this.accessToken && headers['authorization']) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (customHeaders['authorization'] === null) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (this.sandboxClientId && this.sandboxClientSecret && headers['authorization']) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (customHeaders['authorization'] === null) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
throw new Error('Could not resolve authentication method. Expected either accessToken, sandboxClientId or sandboxClientSecret to be set. Or for one of the "Authorization" or "Authorization" headers to be explicitly omitted');
|
|
158
|
-
}
|
|
159
|
-
authHeaders(opts) {
|
|
160
|
-
const bearerAuth = this.bearerAuth(opts);
|
|
161
|
-
const basicAuth = this.basicAuth(opts);
|
|
162
|
-
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
163
|
-
return bearerAuth;
|
|
164
|
-
}
|
|
165
|
-
return {};
|
|
166
|
-
}
|
|
167
|
-
bearerAuth(opts) {
|
|
168
|
-
if (this.accessToken == null) {
|
|
169
|
-
return {};
|
|
170
|
-
}
|
|
171
|
-
return { Authorization: `Bearer ${this.accessToken}` };
|
|
172
|
-
}
|
|
173
|
-
basicAuth(opts) {
|
|
174
|
-
if (!this.sandboxClientId) {
|
|
175
|
-
return {};
|
|
176
|
-
}
|
|
177
|
-
if (!this.sandboxClientSecret) {
|
|
178
|
-
return {};
|
|
179
|
-
}
|
|
180
|
-
const credentials = `${this.sandboxClientId}:${this.sandboxClientSecret}`;
|
|
181
|
-
const Authorization = `Basic ${Core.toBase64(credentials)}`;
|
|
182
|
-
return { Authorization };
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
exports.Finch = Finch;
|
|
186
|
-
_a = Finch;
|
|
187
|
-
Finch.Finch = _a;
|
|
188
|
-
Finch.FinchError = Errors.FinchError;
|
|
189
|
-
Finch.APIError = Errors.APIError;
|
|
190
|
-
Finch.APIConnectionError = Errors.APIConnectionError;
|
|
191
|
-
Finch.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
192
|
-
Finch.APIUserAbortError = Errors.APIUserAbortError;
|
|
193
|
-
Finch.NotFoundError = Errors.NotFoundError;
|
|
194
|
-
Finch.ConflictError = Errors.ConflictError;
|
|
195
|
-
Finch.RateLimitError = Errors.RateLimitError;
|
|
196
|
-
Finch.BadRequestError = Errors.BadRequestError;
|
|
197
|
-
Finch.AuthenticationError = Errors.AuthenticationError;
|
|
198
|
-
Finch.InternalServerError = Errors.InternalServerError;
|
|
199
|
-
Finch.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
200
|
-
Finch.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
201
|
-
Finch.toFile = Uploads.toFile;
|
|
202
|
-
Finch.fileFromPath = Uploads.fileFromPath;
|
|
203
|
-
exports.FinchError = Errors.FinchError, exports.APIError = Errors.APIError, exports.APIConnectionError = Errors.APIConnectionError, exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError, exports.APIUserAbortError = Errors.APIUserAbortError, exports.NotFoundError = Errors.NotFoundError, exports.ConflictError = Errors.ConflictError, exports.RateLimitError = Errors.RateLimitError, exports.BadRequestError = Errors.BadRequestError, exports.AuthenticationError = Errors.AuthenticationError, exports.InternalServerError = Errors.InternalServerError, exports.PermissionDeniedError = Errors.PermissionDeniedError, exports.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
33
|
+
const client_1 = require("./client.js");
|
|
34
|
+
Object.defineProperty(exports, "Finch", { enumerable: true, get: function () { return client_1.Finch; } });
|
|
35
|
+
exports = module.exports = client_1;
|
|
36
|
+
exports.default = client_1.Finch;
|
|
204
37
|
exports.toFile = Uploads.toFile;
|
|
205
38
|
exports.fileFromPath = Uploads.fileFromPath;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
Finch.ResponsesPage = Pagination.ResponsesPage;
|
|
209
|
-
Finch.IndividualsPage = Pagination.IndividualsPage;
|
|
210
|
-
Finch.Page = Pagination.Page;
|
|
211
|
-
Finch.AccessTokens = API.AccessTokens;
|
|
212
|
-
Finch.HRIS = API.HRIS;
|
|
213
|
-
Finch.Providers = API.Providers;
|
|
214
|
-
Finch.ProvidersSinglePage = API.ProvidersSinglePage;
|
|
215
|
-
Finch.Account = API.Account;
|
|
216
|
-
Finch.Webhooks = API.Webhooks;
|
|
217
|
-
Finch.RequestForwarding = API.RequestForwarding;
|
|
218
|
-
Finch.Jobs = API.Jobs;
|
|
219
|
-
Finch.Sandbox = API.Sandbox;
|
|
220
|
-
})(Finch = exports.Finch || (exports.Finch = {}));
|
|
221
|
-
exports = module.exports = Finch;
|
|
222
|
-
exports.default = Finch;
|
|
39
|
+
exports.FinchError = Errors.FinchError, exports.APIError = Errors.APIError, exports.APIConnectionError = Errors.APIConnectionError, exports.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError, exports.APIUserAbortError = Errors.APIUserAbortError, exports.NotFoundError = Errors.NotFoundError, exports.ConflictError = Errors.ConflictError, exports.RateLimitError = Errors.RateLimitError, exports.BadRequestError = Errors.BadRequestError, exports.AuthenticationError = Errors.AuthenticationError, exports.InternalServerError = Errors.InternalServerError, exports.PermissionDeniedError = Errors.PermissionDeniedError, exports.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
40
|
+
__exportStar(require("./client.js"), exports);
|
|
223
41
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,mDAAkC;AAClC,sDAAqC;AACrC,wCAAiC;AAExB,sFAFA,cAAK,OAEA;AACd,kBAAe,cAAK,CAAC;AAEP,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACxB,QAAA,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAGhD,kBAAU,GAaR,MAAM,aAZR,gBAAQ,GAYN,MAAM,WAXR,0BAAkB,GAWhB,MAAM,qBAVR,iCAAyB,GAUvB,MAAM,4BATR,yBAAiB,GASf,MAAM,oBARR,qBAAa,GAQX,MAAM,gBAPR,qBAAa,GAOX,MAAM,gBANR,sBAAc,GAMZ,MAAM,iBALR,uBAAe,GAKb,MAAM,kBAJR,2BAAmB,GAIjB,MAAM,sBAHR,2BAAmB,GAGjB,MAAM,sBAFR,6BAAqB,GAEnB,MAAM,wBADR,gCAAwB,GACtB,MAAM,0BAAC;AAEX,8CAAyB"}
|
package/index.mjs
CHANGED
|
@@ -1,195 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
var _a;
|
|
3
|
-
import * as Core from "./core.mjs";
|
|
4
2
|
import * as Errors from "./error.mjs";
|
|
5
3
|
import * as Uploads from "./uploads.mjs";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export class Finch extends Core.APIClient {
|
|
10
|
-
/**
|
|
11
|
-
* API Client for interfacing with the Finch API.
|
|
12
|
-
*
|
|
13
|
-
* @param {string | null | undefined} [opts.accessToken]
|
|
14
|
-
* @param {string | null | undefined} [opts.clientId=process.env['FINCH_CLIENT_ID'] ?? null]
|
|
15
|
-
* @param {string | null | undefined} [opts.clientSecret=process.env['FINCH_CLIENT_SECRET'] ?? null]
|
|
16
|
-
* @param {string | null | undefined} [opts.sandboxClientId=process.env['FINCH_SANDBOX_CLIENT_ID'] ?? null]
|
|
17
|
-
* @param {string | null | undefined} [opts.sandboxClientSecret=process.env['FINCH_SANDBOX_CLIENT_SECRET'] ?? null]
|
|
18
|
-
* @param {string | null | undefined} [opts.webhookSecret=process.env['FINCH_WEBHOOK_SECRET'] ?? null]
|
|
19
|
-
* @param {string} [opts.baseURL=process.env['FINCH_BASE_URL'] ?? https://api.tryfinch.com] - Override the default base URL for the API.
|
|
20
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
21
|
-
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
22
|
-
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
23
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
24
|
-
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
25
|
-
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
26
|
-
*/
|
|
27
|
-
constructor({ baseURL = Core.readEnv('FINCH_BASE_URL'), accessToken = null, clientId = Core.readEnv('FINCH_CLIENT_ID') ?? null, clientSecret = Core.readEnv('FINCH_CLIENT_SECRET') ?? null, sandboxClientId = Core.readEnv('FINCH_SANDBOX_CLIENT_ID') ?? null, sandboxClientSecret = Core.readEnv('FINCH_SANDBOX_CLIENT_SECRET') ?? null, webhookSecret = Core.readEnv('FINCH_WEBHOOK_SECRET') ?? null, ...opts } = {}) {
|
|
28
|
-
const options = {
|
|
29
|
-
accessToken,
|
|
30
|
-
clientId,
|
|
31
|
-
clientSecret,
|
|
32
|
-
sandboxClientId,
|
|
33
|
-
sandboxClientSecret,
|
|
34
|
-
webhookSecret,
|
|
35
|
-
...opts,
|
|
36
|
-
baseURL: baseURL || `https://api.tryfinch.com`,
|
|
37
|
-
};
|
|
38
|
-
super({
|
|
39
|
-
baseURL: options.baseURL,
|
|
40
|
-
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
41
|
-
httpAgent: options.httpAgent,
|
|
42
|
-
maxRetries: options.maxRetries,
|
|
43
|
-
fetch: options.fetch,
|
|
44
|
-
});
|
|
45
|
-
this.accessTokens = new API.AccessTokens(this);
|
|
46
|
-
this.hris = new API.HRIS(this);
|
|
47
|
-
this.providers = new API.Providers(this);
|
|
48
|
-
this.account = new API.Account(this);
|
|
49
|
-
this.webhooks = new API.Webhooks(this);
|
|
50
|
-
this.requestForwarding = new API.RequestForwarding(this);
|
|
51
|
-
this.jobs = new API.Jobs(this);
|
|
52
|
-
this.sandbox = new API.Sandbox(this);
|
|
53
|
-
this._options = options;
|
|
54
|
-
this.accessToken = accessToken;
|
|
55
|
-
this.clientId = clientId;
|
|
56
|
-
this.clientSecret = clientSecret;
|
|
57
|
-
this.sandboxClientId = sandboxClientId;
|
|
58
|
-
this.sandboxClientSecret = sandboxClientSecret;
|
|
59
|
-
this.webhookSecret = webhookSecret;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* DEPRECATED: use client.accessTokens.create instead.
|
|
63
|
-
*/
|
|
64
|
-
getAccessToken(code, options) {
|
|
65
|
-
if (!this.clientId) {
|
|
66
|
-
throw new Error('Expected the clientId to be set in order to call getAccessToken');
|
|
67
|
-
}
|
|
68
|
-
if (!this.clientSecret) {
|
|
69
|
-
throw new Error('Expected the clientSecret to be set in order to call getAccessToken');
|
|
70
|
-
}
|
|
71
|
-
return this.post('/auth/token', {
|
|
72
|
-
body: {
|
|
73
|
-
client_id: this.clientId,
|
|
74
|
-
client_secret: this.clientSecret,
|
|
75
|
-
code: code,
|
|
76
|
-
redirect_uri: options?.redirectUri,
|
|
77
|
-
},
|
|
78
|
-
headers: {
|
|
79
|
-
authorization: null,
|
|
80
|
-
},
|
|
81
|
-
}).then((response) => response.access_token);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Returns the authorization url which can be visited in order to obtain an
|
|
85
|
-
* authorization code from Finch. The authorization code can then be exchanged for
|
|
86
|
-
* an access token for the Finch api by calling get_access_token().
|
|
87
|
-
*/
|
|
88
|
-
getAuthURL({ products, redirectUri, sandbox, }) {
|
|
89
|
-
if (!this.clientId) {
|
|
90
|
-
throw new Error('Expected the clientId to be set in order to call getAuthUrl');
|
|
91
|
-
}
|
|
92
|
-
const url = new URL('/authorize', 'https://connect.tryfinch.com/authorize');
|
|
93
|
-
url.search = this.stringifyQuery({
|
|
94
|
-
client_id: this.clientId,
|
|
95
|
-
products: products,
|
|
96
|
-
redirect_uri: redirectUri,
|
|
97
|
-
sandbox: sandbox,
|
|
98
|
-
});
|
|
99
|
-
return url.toString();
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Returns a copy of the current Finch client with the given access token for
|
|
103
|
-
* authentication.
|
|
104
|
-
*/
|
|
105
|
-
withAccessToken(accessToken) {
|
|
106
|
-
return new Finch({ ...this._options, accessToken });
|
|
107
|
-
}
|
|
108
|
-
defaultQuery() {
|
|
109
|
-
return this._options.defaultQuery;
|
|
110
|
-
}
|
|
111
|
-
defaultHeaders(opts) {
|
|
112
|
-
return {
|
|
113
|
-
...super.defaultHeaders(opts),
|
|
114
|
-
'Finch-API-Version': '2020-09-17',
|
|
115
|
-
...this._options.defaultHeaders,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
validateHeaders(headers, customHeaders) {
|
|
119
|
-
if (this.accessToken && headers['authorization']) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (customHeaders['authorization'] === null) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (this.sandboxClientId && this.sandboxClientSecret && headers['authorization']) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (customHeaders['authorization'] === null) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
throw new Error('Could not resolve authentication method. Expected either accessToken, sandboxClientId or sandboxClientSecret to be set. Or for one of the "Authorization" or "Authorization" headers to be explicitly omitted');
|
|
132
|
-
}
|
|
133
|
-
authHeaders(opts) {
|
|
134
|
-
const bearerAuth = this.bearerAuth(opts);
|
|
135
|
-
const basicAuth = this.basicAuth(opts);
|
|
136
|
-
if (bearerAuth != null && !Core.isEmptyObj(bearerAuth)) {
|
|
137
|
-
return bearerAuth;
|
|
138
|
-
}
|
|
139
|
-
return {};
|
|
140
|
-
}
|
|
141
|
-
bearerAuth(opts) {
|
|
142
|
-
if (this.accessToken == null) {
|
|
143
|
-
return {};
|
|
144
|
-
}
|
|
145
|
-
return { Authorization: `Bearer ${this.accessToken}` };
|
|
146
|
-
}
|
|
147
|
-
basicAuth(opts) {
|
|
148
|
-
if (!this.sandboxClientId) {
|
|
149
|
-
return {};
|
|
150
|
-
}
|
|
151
|
-
if (!this.sandboxClientSecret) {
|
|
152
|
-
return {};
|
|
153
|
-
}
|
|
154
|
-
const credentials = `${this.sandboxClientId}:${this.sandboxClientSecret}`;
|
|
155
|
-
const Authorization = `Basic ${Core.toBase64(credentials)}`;
|
|
156
|
-
return { Authorization };
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
_a = Finch;
|
|
160
|
-
Finch.Finch = _a;
|
|
161
|
-
Finch.FinchError = Errors.FinchError;
|
|
162
|
-
Finch.APIError = Errors.APIError;
|
|
163
|
-
Finch.APIConnectionError = Errors.APIConnectionError;
|
|
164
|
-
Finch.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
165
|
-
Finch.APIUserAbortError = Errors.APIUserAbortError;
|
|
166
|
-
Finch.NotFoundError = Errors.NotFoundError;
|
|
167
|
-
Finch.ConflictError = Errors.ConflictError;
|
|
168
|
-
Finch.RateLimitError = Errors.RateLimitError;
|
|
169
|
-
Finch.BadRequestError = Errors.BadRequestError;
|
|
170
|
-
Finch.AuthenticationError = Errors.AuthenticationError;
|
|
171
|
-
Finch.InternalServerError = Errors.InternalServerError;
|
|
172
|
-
Finch.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
173
|
-
Finch.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
174
|
-
Finch.toFile = Uploads.toFile;
|
|
175
|
-
Finch.fileFromPath = Uploads.fileFromPath;
|
|
176
|
-
export const { FinchError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } = Errors;
|
|
4
|
+
import { Finch } from "./client.mjs";
|
|
5
|
+
export { Finch };
|
|
6
|
+
export default Finch;
|
|
177
7
|
export var toFile = Uploads.toFile;
|
|
178
8
|
export var fileFromPath = Uploads.fileFromPath;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Finch.ResponsesPage = Pagination.ResponsesPage;
|
|
182
|
-
Finch.IndividualsPage = Pagination.IndividualsPage;
|
|
183
|
-
Finch.Page = Pagination.Page;
|
|
184
|
-
Finch.AccessTokens = API.AccessTokens;
|
|
185
|
-
Finch.HRIS = API.HRIS;
|
|
186
|
-
Finch.Providers = API.Providers;
|
|
187
|
-
Finch.ProvidersSinglePage = API.ProvidersSinglePage;
|
|
188
|
-
Finch.Account = API.Account;
|
|
189
|
-
Finch.Webhooks = API.Webhooks;
|
|
190
|
-
Finch.RequestForwarding = API.RequestForwarding;
|
|
191
|
-
Finch.Jobs = API.Jobs;
|
|
192
|
-
Finch.Sandbox = API.Sandbox;
|
|
193
|
-
})(Finch || (Finch = {}));
|
|
194
|
-
export default Finch;
|
|
9
|
+
export const { FinchError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } = Errors;
|
|
10
|
+
export * from "./client.mjs";
|
|
195
11
|
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,EAAE,KAAK,EAAE;AAEhB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,eAAe,KAAK,CAAC;AAErB,MAAM,KAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACtC,MAAM,KAAQ,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAElD,MAAM,CAAC,MAAM,EACX,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,GAAG,MAAM,CAAC"}
|