postgrid-node 0.1.0-alpha.3 → 0.1.0-alpha.4
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 +47 -0
- package/README.md +25 -39
- package/core.d.ts +7 -4
- package/core.d.ts.map +1 -1
- package/core.js +16 -9
- package/core.js.map +1 -1
- package/core.mjs +16 -9
- package/core.mjs.map +1 -1
- package/index.d.mts +21 -8
- package/index.d.ts +21 -8
- package/index.d.ts.map +1 -1
- package/index.js +28 -5
- package/index.js.map +1 -1
- package/index.mjs +28 -5
- package/index.mjs.map +1 -1
- package/internal/qs/formats.d.ts +6 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +11 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +8 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +280 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +276 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.ts +14 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +229 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/package.json +1 -1
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -1
- package/pagination.js +2 -1
- package/pagination.js.map +1 -1
- package/pagination.mjs +2 -1
- package/pagination.mjs.map +1 -1
- package/resource.d.ts +1 -1
- package/resource.d.ts.map +1 -1
- package/resource.js.map +1 -1
- package/resource.mjs.map +1 -1
- package/resources/bank-accounts.d.ts +61 -4
- package/resources/bank-accounts.d.ts.map +1 -1
- package/resources/bank-accounts.js +25 -0
- package/resources/bank-accounts.js.map +1 -1
- package/resources/bank-accounts.mjs +25 -0
- package/resources/bank-accounts.mjs.map +1 -1
- package/resources/boxes.d.ts +80 -15
- package/resources/boxes.d.ts.map +1 -1
- package/resources/boxes.js +27 -0
- package/resources/boxes.js.map +1 -1
- package/resources/boxes.mjs +27 -0
- package/resources/boxes.mjs.map +1 -1
- package/resources/campaigns.d.ts +21 -7
- package/resources/campaigns.d.ts.map +1 -1
- package/resources/cheques/cheques.d.ts +43 -4
- package/resources/cheques/cheques.d.ts.map +1 -1
- package/resources/cheques/cheques.js +23 -0
- package/resources/cheques/cheques.js.map +1 -1
- package/resources/cheques/cheques.mjs +23 -0
- package/resources/cheques/cheques.mjs.map +1 -1
- package/resources/cheques/url.d.ts +5 -0
- package/resources/cheques/url.d.ts.map +1 -1
- package/resources/cheques/url.js +5 -0
- package/resources/cheques/url.js.map +1 -1
- package/resources/cheques/url.mjs +5 -0
- package/resources/cheques/url.mjs.map +1 -1
- package/resources/cheques/with-deposit-ready-pdf.d.ts +6 -0
- package/resources/cheques/with-deposit-ready-pdf.d.ts.map +1 -1
- package/resources/cheques/with-deposit-ready-pdf.js +6 -0
- package/resources/cheques/with-deposit-ready-pdf.js.map +1 -1
- package/resources/cheques/with-deposit-ready-pdf.mjs +6 -0
- package/resources/cheques/with-deposit-ready-pdf.mjs.map +1 -1
- package/resources/contacts.d.ts +37 -3
- package/resources/contacts.d.ts.map +1 -1
- package/resources/contacts.js +20 -0
- package/resources/contacts.js.map +1 -1
- package/resources/contacts.mjs +20 -0
- package/resources/contacts.mjs.map +1 -1
- package/resources/index.d.ts +5 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +12 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -1
- package/resources/letters.d.ts +50 -6
- package/resources/letters.d.ts.map +1 -1
- package/resources/letters.js +24 -0
- package/resources/letters.js.map +1 -1
- package/resources/letters.mjs +24 -0
- package/resources/letters.mjs.map +1 -1
- package/resources/mailing-list-imports.d.ts +919 -0
- package/resources/mailing-list-imports.d.ts.map +1 -0
- package/resources/mailing-list-imports.js +95 -0
- package/resources/mailing-list-imports.js.map +1 -0
- package/resources/mailing-list-imports.mjs +90 -0
- package/resources/mailing-list-imports.mjs.map +1 -0
- package/resources/mailing-lists.d.ts +398 -0
- package/resources/mailing-lists.d.ts.map +1 -0
- package/resources/mailing-lists.js +101 -0
- package/resources/mailing-lists.js.map +1 -0
- package/resources/mailing-lists.mjs +96 -0
- package/resources/mailing-lists.mjs.map +1 -0
- package/resources/order-profiles/cheques.d.ts +588 -0
- package/resources/order-profiles/cheques.d.ts.map +1 -0
- package/resources/order-profiles/cheques.js +74 -0
- package/resources/order-profiles/cheques.js.map +1 -0
- package/resources/order-profiles/cheques.mjs +69 -0
- package/resources/order-profiles/cheques.mjs.map +1 -0
- package/resources/order-profiles/index.d.ts +6 -0
- package/resources/order-profiles/index.d.ts.map +1 -0
- package/resources/order-profiles/index.js +19 -0
- package/resources/order-profiles/index.js.map +1 -0
- package/resources/order-profiles/index.mjs +7 -0
- package/resources/order-profiles/index.mjs.map +1 -0
- package/resources/order-profiles/letters.d.ts +647 -0
- package/resources/order-profiles/letters.d.ts.map +1 -0
- package/resources/order-profiles/letters.js +80 -0
- package/resources/order-profiles/letters.js.map +1 -0
- package/resources/order-profiles/letters.mjs +75 -0
- package/resources/order-profiles/letters.mjs.map +1 -0
- package/resources/order-profiles/order-profiles.d.ts +22 -0
- package/resources/order-profiles/order-profiles.d.ts.map +1 -0
- package/resources/order-profiles/order-profiles.js +55 -0
- package/resources/order-profiles/order-profiles.js.map +1 -0
- package/resources/order-profiles/order-profiles.mjs +28 -0
- package/resources/order-profiles/order-profiles.mjs.map +1 -0
- package/resources/order-profiles/postcards.d.ts +423 -0
- package/resources/order-profiles/postcards.d.ts.map +1 -0
- package/resources/order-profiles/postcards.js +73 -0
- package/resources/order-profiles/postcards.js.map +1 -0
- package/resources/order-profiles/postcards.mjs +68 -0
- package/resources/order-profiles/postcards.mjs.map +1 -0
- package/resources/order-profiles/self-mailers.d.ts +435 -0
- package/resources/order-profiles/self-mailers.d.ts.map +1 -0
- package/resources/order-profiles/self-mailers.js +75 -0
- package/resources/order-profiles/self-mailers.js.map +1 -0
- package/resources/order-profiles/self-mailers.mjs +70 -0
- package/resources/order-profiles/self-mailers.mjs.map +1 -0
- package/resources/order-profiles.d.ts +2 -0
- package/resources/order-profiles.d.ts.map +1 -0
- package/resources/order-profiles.js +19 -0
- package/resources/order-profiles.js.map +1 -0
- package/resources/order-profiles.mjs +3 -0
- package/resources/order-profiles.mjs.map +1 -0
- package/resources/postcards.d.ts +58 -8
- package/resources/postcards.d.ts.map +1 -1
- package/resources/postcards.js +26 -0
- package/resources/postcards.js.map +1 -1
- package/resources/postcards.mjs +26 -0
- package/resources/postcards.mjs.map +1 -1
- package/resources/reports/exports.d.ts +36 -3
- package/resources/reports/exports.d.ts.map +1 -1
- package/resources/reports/exports.js +27 -0
- package/resources/reports/exports.js.map +1 -1
- package/resources/reports/exports.mjs +27 -0
- package/resources/reports/exports.mjs.map +1 -1
- package/resources/reports/reports.d.ts +76 -8
- package/resources/reports/reports.d.ts.map +1 -1
- package/resources/reports/reports.js +44 -0
- package/resources/reports/reports.js.map +1 -1
- package/resources/reports/reports.mjs +44 -0
- package/resources/reports/reports.mjs.map +1 -1
- package/resources/self-mailers.d.ts +99 -15
- package/resources/self-mailers.d.ts.map +1 -1
- package/resources/self-mailers.js +38 -0
- package/resources/self-mailers.js.map +1 -1
- package/resources/self-mailers.mjs +38 -0
- package/resources/self-mailers.mjs.map +1 -1
- package/resources/shared.d.ts +6 -2
- package/resources/shared.d.ts.map +1 -1
- package/resources/sub-organizations.d.ts +394 -0
- package/resources/sub-organizations.d.ts.map +1 -0
- package/resources/sub-organizations.js +63 -0
- package/resources/sub-organizations.js.map +1 -0
- package/resources/sub-organizations.mjs +58 -0
- package/resources/sub-organizations.mjs.map +1 -0
- package/resources/templates.d.ts +43 -3
- package/resources/templates.d.ts.map +1 -1
- package/resources/templates.js +26 -0
- package/resources/templates.js.map +1 -1
- package/resources/templates.mjs +26 -0
- package/resources/templates.mjs.map +1 -1
- package/src/core.ts +17 -8
- package/src/index.ts +112 -11
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +9 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +388 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/pagination.ts +6 -1
- package/src/resource.ts +1 -1
- package/src/resources/bank-accounts.ts +57 -4
- package/src/resources/boxes.ts +50 -15
- package/src/resources/campaigns.ts +7 -7
- package/src/resources/cheques/cheques.ts +35 -4
- package/src/resources/cheques/url.ts +5 -0
- package/src/resources/cheques/with-deposit-ready-pdf.ts +6 -0
- package/src/resources/contacts.ts +31 -3
- package/src/resources/index.ts +39 -0
- package/src/resources/letters.ts +38 -6
- package/src/resources/mailing-list-imports.ts +1076 -0
- package/src/resources/mailing-lists.ts +511 -0
- package/src/resources/order-profiles/cheques.ts +888 -0
- package/src/resources/order-profiles/index.ts +55 -0
- package/src/resources/order-profiles/letters.ts +956 -0
- package/src/resources/order-profiles/order-profiles.ts +133 -0
- package/src/resources/order-profiles/postcards.ts +694 -0
- package/src/resources/order-profiles/self-mailers.ts +707 -0
- package/src/resources/order-profiles.ts +3 -0
- package/src/resources/postcards.ts +42 -8
- package/src/resources/reports/exports.ts +30 -3
- package/src/resources/reports/reports.ts +60 -8
- package/src/resources/self-mailers.ts +80 -14
- package/src/resources/shared.ts +2 -2
- package/src/resources/sub-organizations.ts +518 -0
- package/src/resources/templates.ts +37 -3
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAC1C,qCAA2C;AAE3C,iDAAsD;AAEtD,MAAa,SAAU,SAAQ,sBAAW;IACxC
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAC1C,qCAA2C;AAE3C,iDAAsD;AAEtD,MAAa,SAAU,SAAQ,sBAAW;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAA0B,EAAE,OAA6B;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAU,EAAE,IAA0B,EAAE,OAA6B;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAeD,IAAI,CACF,QAAkD,EAAE,EACpD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAA6B;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AA9ED,8BA8EC;AAED,MAAa,aAAc,SAAQ,iBAAc;CAAG;AAApD,sCAAoD;AAsHpD,SAAS,CAAC,aAAa,GAAG,aAAa,CAAC"}
|
package/resources/templates.mjs
CHANGED
|
@@ -6,18 +6,39 @@ export class Templates extends APIResource {
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a template. Note that if you want to create a template that works with
|
|
8
8
|
* our template editor, you must use our dashboard.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const template = await client.templates.create({
|
|
13
|
+
* description: 'Test',
|
|
14
|
+
* html: '<b>Hello</b> {{to.firstName}}',
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
9
17
|
*/
|
|
10
18
|
create(body, options) {
|
|
11
19
|
return this._client.post('/templates', { body, ...options });
|
|
12
20
|
}
|
|
13
21
|
/**
|
|
14
22
|
* Retrieve a template by ID.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const template = await client.templates.retrieve('id');
|
|
27
|
+
* ```
|
|
15
28
|
*/
|
|
16
29
|
retrieve(id, options) {
|
|
17
30
|
return this._client.get(`/templates/${id}`, options);
|
|
18
31
|
}
|
|
19
32
|
/**
|
|
20
33
|
* Update a template by ID.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const template = await client.templates.update('id', {
|
|
38
|
+
* description: 'Test',
|
|
39
|
+
* html: '<b>Hello</b> {{to.firstName}}!',
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
21
42
|
*/
|
|
22
43
|
update(id, body, options) {
|
|
23
44
|
return this._client.post(`/templates/${id}`, { body, ...options });
|
|
@@ -30,6 +51,11 @@ export class Templates extends APIResource {
|
|
|
30
51
|
}
|
|
31
52
|
/**
|
|
32
53
|
* Delete a template by ID. Note that this operation cannot be undone.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const template = await client.templates.delete('id');
|
|
58
|
+
* ```
|
|
33
59
|
*/
|
|
34
60
|
delete(id, options) {
|
|
35
61
|
return this._client.delete(`/templates/${id}`, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.mjs","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;OAEpB,EAAE,IAAI,EAAmB;AAEhC,MAAM,OAAO,SAAU,SAAQ,WAAW;IACxC
|
|
1
|
+
{"version":3,"file":"templates.mjs","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;OAEpB,EAAE,IAAI,EAAmB;AAEhC,MAAM,OAAO,SAAU,SAAQ,WAAW;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,IAA0B,EAAE,OAA6B;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAU,EAAE,IAA0B,EAAE,OAA6B;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IAeD,IAAI,CACF,QAAkD,EAAE,EACpD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAA6B;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,IAAc;CAAG;AAsHpD,SAAS,CAAC,aAAa,GAAG,aAAa,CAAC"}
|
package/src/core.ts
CHANGED
|
@@ -170,6 +170,7 @@ export class APIPromise<T> extends Promise<T> {
|
|
|
170
170
|
|
|
171
171
|
export abstract class APIClient {
|
|
172
172
|
baseURL: string;
|
|
173
|
+
#baseURLOverridden: boolean;
|
|
173
174
|
maxRetries: number;
|
|
174
175
|
timeout: number;
|
|
175
176
|
httpAgent: Agent | undefined;
|
|
@@ -179,18 +180,21 @@ export abstract class APIClient {
|
|
|
179
180
|
|
|
180
181
|
constructor({
|
|
181
182
|
baseURL,
|
|
183
|
+
baseURLOverridden,
|
|
182
184
|
maxRetries = 2,
|
|
183
185
|
timeout = 60000, // 1 minute
|
|
184
186
|
httpAgent,
|
|
185
187
|
fetch: overriddenFetch,
|
|
186
188
|
}: {
|
|
187
189
|
baseURL: string;
|
|
190
|
+
baseURLOverridden: boolean;
|
|
188
191
|
maxRetries?: number | undefined;
|
|
189
192
|
timeout: number | undefined;
|
|
190
193
|
httpAgent: Agent | undefined;
|
|
191
194
|
fetch: Fetch | undefined;
|
|
192
195
|
}) {
|
|
193
196
|
this.baseURL = baseURL;
|
|
197
|
+
this.#baseURLOverridden = baseURLOverridden;
|
|
194
198
|
this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
|
|
195
199
|
this.timeout = validatePositiveInteger('timeout', timeout);
|
|
196
200
|
this.httpAgent = httpAgent;
|
|
@@ -213,7 +217,7 @@ export abstract class APIClient {
|
|
|
213
217
|
protected defaultHeaders(opts: FinalRequestOptions): Headers {
|
|
214
218
|
return {
|
|
215
219
|
Accept: 'application/json',
|
|
216
|
-
'Content-Type': 'application/json',
|
|
220
|
+
...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }),
|
|
217
221
|
'User-Agent': this.getUserAgent(),
|
|
218
222
|
...getPlatformHeaders(),
|
|
219
223
|
...this.authHeaders(opts),
|
|
@@ -295,12 +299,12 @@ export abstract class APIClient {
|
|
|
295
299
|
return null;
|
|
296
300
|
}
|
|
297
301
|
|
|
298
|
-
buildRequest<Req>(
|
|
302
|
+
async buildRequest<Req>(
|
|
299
303
|
inputOptions: FinalRequestOptions<Req>,
|
|
300
304
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
301
|
-
): { req: RequestInit; url: string; timeout: number } {
|
|
305
|
+
): Promise<{ req: RequestInit; url: string; timeout: number }> {
|
|
302
306
|
const options = { ...inputOptions };
|
|
303
|
-
const { method, path, query, headers: headers = {} } = options;
|
|
307
|
+
const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
|
|
304
308
|
|
|
305
309
|
const body =
|
|
306
310
|
ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
|
|
@@ -310,7 +314,7 @@ export abstract class APIClient {
|
|
|
310
314
|
: null;
|
|
311
315
|
const contentLength = this.calculateContentLength(body);
|
|
312
316
|
|
|
313
|
-
const url = this.buildURL(path!, query);
|
|
317
|
+
const url = this.buildURL(path!, query, defaultBaseURL);
|
|
314
318
|
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
315
319
|
options.timeout = options.timeout ?? this.timeout;
|
|
316
320
|
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
|
|
@@ -446,7 +450,9 @@ export abstract class APIClient {
|
|
|
446
450
|
|
|
447
451
|
await this.prepareOptions(options);
|
|
448
452
|
|
|
449
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
453
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
454
|
+
retryCount: maxRetries - retriesRemaining,
|
|
455
|
+
});
|
|
450
456
|
|
|
451
457
|
await this.prepareRequest(req, { url, options });
|
|
452
458
|
|
|
@@ -503,11 +509,12 @@ export abstract class APIClient {
|
|
|
503
509
|
return new PagePromise<PageClass, Item>(this, request, Page);
|
|
504
510
|
}
|
|
505
511
|
|
|
506
|
-
buildURL<Req>(path: string, query: Req | null | undefined): string {
|
|
512
|
+
buildURL<Req>(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string {
|
|
513
|
+
const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL;
|
|
507
514
|
const url =
|
|
508
515
|
isAbsoluteURL(path) ?
|
|
509
516
|
new URL(path)
|
|
510
|
-
: new URL(
|
|
517
|
+
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
511
518
|
|
|
512
519
|
const defaultQuery = this.defaultQuery();
|
|
513
520
|
if (!isEmptyObj(defaultQuery)) {
|
|
@@ -792,6 +799,7 @@ export type RequestOptions<
|
|
|
792
799
|
query?: Req | undefined;
|
|
793
800
|
body?: Req | null | undefined;
|
|
794
801
|
headers?: Headers | undefined;
|
|
802
|
+
defaultBaseURL?: string | undefined;
|
|
795
803
|
|
|
796
804
|
maxRetries?: number;
|
|
797
805
|
stream?: boolean | undefined;
|
|
@@ -813,6 +821,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
|
|
|
813
821
|
query: true,
|
|
814
822
|
body: true,
|
|
815
823
|
headers: true,
|
|
824
|
+
defaultBaseURL: true,
|
|
816
825
|
|
|
817
826
|
maxRetries: true,
|
|
818
827
|
stream: true,
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { type Agent } from './_shims/index';
|
|
4
|
+
import * as qs from './internal/qs';
|
|
4
5
|
import * as Core from './core';
|
|
5
6
|
import * as Errors from './error';
|
|
6
7
|
import * as Pagination from './pagination';
|
|
@@ -57,6 +58,32 @@ import {
|
|
|
57
58
|
Letters,
|
|
58
59
|
LettersList,
|
|
59
60
|
} from './resources/letters';
|
|
61
|
+
import {
|
|
62
|
+
MailingListImportCreateParams,
|
|
63
|
+
MailingListImportCreateResponse,
|
|
64
|
+
MailingListImportDeleteResponse,
|
|
65
|
+
MailingListImportListParams,
|
|
66
|
+
MailingListImportListResponse,
|
|
67
|
+
MailingListImportListResponsesList,
|
|
68
|
+
MailingListImportRetrieveResponse,
|
|
69
|
+
MailingListImportUpdateParams,
|
|
70
|
+
MailingListImportUpdateResponse,
|
|
71
|
+
MailingListImports,
|
|
72
|
+
} from './resources/mailing-list-imports';
|
|
73
|
+
import {
|
|
74
|
+
MailingListCreateParams,
|
|
75
|
+
MailingListCreateResponse,
|
|
76
|
+
MailingListDeleteResponse,
|
|
77
|
+
MailingListListParams,
|
|
78
|
+
MailingListListResponse,
|
|
79
|
+
MailingListListResponsesList,
|
|
80
|
+
MailingListRetrieveResponse,
|
|
81
|
+
MailingListSubmitJobParams,
|
|
82
|
+
MailingListSubmitJobResponse,
|
|
83
|
+
MailingListUpdateParams,
|
|
84
|
+
MailingListUpdateResponse,
|
|
85
|
+
MailingLists,
|
|
86
|
+
} from './resources/mailing-lists';
|
|
60
87
|
import {
|
|
61
88
|
Postcard,
|
|
62
89
|
PostcardCreateParams,
|
|
@@ -73,9 +100,21 @@ import {
|
|
|
73
100
|
SelfMailerListParams,
|
|
74
101
|
SelfMailerListResponse,
|
|
75
102
|
SelfMailerListResponsesList,
|
|
103
|
+
SelfMailerRetrievePreviewURLResponse,
|
|
76
104
|
SelfMailerRetrieveResponse,
|
|
77
105
|
SelfMailers,
|
|
78
106
|
} from './resources/self-mailers';
|
|
107
|
+
import {
|
|
108
|
+
SubOrganizationCreateParams,
|
|
109
|
+
SubOrganizationCreateResponse,
|
|
110
|
+
SubOrganizationListParams,
|
|
111
|
+
SubOrganizationListResponse,
|
|
112
|
+
SubOrganizationListResponsesList,
|
|
113
|
+
SubOrganizationListUsersParams,
|
|
114
|
+
SubOrganizationListUsersResponse,
|
|
115
|
+
SubOrganizationRetrieveResponse,
|
|
116
|
+
SubOrganizations,
|
|
117
|
+
} from './resources/sub-organizations';
|
|
79
118
|
import {
|
|
80
119
|
Template,
|
|
81
120
|
TemplateCreateParams,
|
|
@@ -94,6 +133,7 @@ import {
|
|
|
94
133
|
Cheques,
|
|
95
134
|
ChequesList,
|
|
96
135
|
} from './resources/cheques/cheques';
|
|
136
|
+
import { OrderProfiles } from './resources/order-profiles/order-profiles';
|
|
97
137
|
import {
|
|
98
138
|
ReportCreateParams,
|
|
99
139
|
ReportCreateResponse,
|
|
@@ -112,10 +152,7 @@ import {
|
|
|
112
152
|
} from './resources/reports/reports';
|
|
113
153
|
|
|
114
154
|
export interface ClientOptions {
|
|
115
|
-
|
|
116
|
-
* Defaults to process.env['POSTGRID_API_KEY'].
|
|
117
|
-
*/
|
|
118
|
-
apiKey?: string | undefined;
|
|
155
|
+
apiKey: string;
|
|
119
156
|
|
|
120
157
|
/**
|
|
121
158
|
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
@@ -130,6 +167,8 @@ export interface ClientOptions {
|
|
|
130
167
|
*
|
|
131
168
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
132
169
|
* much longer than this timeout before the promise succeeds or fails.
|
|
170
|
+
*
|
|
171
|
+
* @unit milliseconds
|
|
133
172
|
*/
|
|
134
173
|
timeout?: number | undefined;
|
|
135
174
|
|
|
@@ -185,7 +224,7 @@ export class PostGrid extends Core.APIClient {
|
|
|
185
224
|
/**
|
|
186
225
|
* API Client for interfacing with the PostGrid API.
|
|
187
226
|
*
|
|
188
|
-
* @param {string
|
|
227
|
+
* @param {string} opts.apiKey
|
|
189
228
|
* @param {string} [opts.baseURL=process.env['POSTGRID_BASE_URL'] ?? https://api.postgrid.com/print-mail/v1] - Override the default base URL for the API.
|
|
190
229
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
191
230
|
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
@@ -194,14 +233,10 @@ export class PostGrid extends Core.APIClient {
|
|
|
194
233
|
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
195
234
|
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
196
235
|
*/
|
|
197
|
-
constructor({
|
|
198
|
-
baseURL = Core.readEnv('POSTGRID_BASE_URL'),
|
|
199
|
-
apiKey = Core.readEnv('POSTGRID_API_KEY'),
|
|
200
|
-
...opts
|
|
201
|
-
}: ClientOptions = {}) {
|
|
236
|
+
constructor({ baseURL = Core.readEnv('POSTGRID_BASE_URL'), apiKey, ...opts }: ClientOptions) {
|
|
202
237
|
if (apiKey === undefined) {
|
|
203
238
|
throw new Errors.PostGridError(
|
|
204
|
-
"
|
|
239
|
+
"Missing required client option apiKey; you need to instantiate the PostGrid client with an apiKey option, like new PostGrid({ apiKey: 'My API Key' }).",
|
|
205
240
|
);
|
|
206
241
|
}
|
|
207
242
|
|
|
@@ -213,6 +248,7 @@ export class PostGrid extends Core.APIClient {
|
|
|
213
248
|
|
|
214
249
|
super({
|
|
215
250
|
baseURL: options.baseURL!,
|
|
251
|
+
baseURLOverridden: baseURL ? baseURL !== 'https://api.postgrid.com/print-mail/v1' : false,
|
|
216
252
|
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
217
253
|
httpAgent: options.httpAgent,
|
|
218
254
|
maxRetries: options.maxRetries,
|
|
@@ -235,6 +271,17 @@ export class PostGrid extends Core.APIClient {
|
|
|
235
271
|
campaigns: API.Campaigns = new API.Campaigns(this);
|
|
236
272
|
reports: API.Reports = new API.Reports(this);
|
|
237
273
|
selfMailers: API.SelfMailers = new API.SelfMailers(this);
|
|
274
|
+
mailingListImports: API.MailingListImports = new API.MailingListImports(this);
|
|
275
|
+
mailingLists: API.MailingLists = new API.MailingLists(this);
|
|
276
|
+
orderProfiles: API.OrderProfiles = new API.OrderProfiles(this);
|
|
277
|
+
subOrganizations: API.SubOrganizations = new API.SubOrganizations(this);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Check whether the base URL is set to its default.
|
|
281
|
+
*/
|
|
282
|
+
#baseURLOverridden(): boolean {
|
|
283
|
+
return this.baseURL !== 'https://api.postgrid.com/print-mail/v1';
|
|
284
|
+
}
|
|
238
285
|
|
|
239
286
|
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
240
287
|
return this._options.defaultQuery;
|
|
@@ -251,6 +298,10 @@ export class PostGrid extends Core.APIClient {
|
|
|
251
298
|
return { 'X-API-Key': this.apiKey };
|
|
252
299
|
}
|
|
253
300
|
|
|
301
|
+
protected override stringifyQuery(query: Record<string, unknown>): string {
|
|
302
|
+
return qs.stringify(query, { arrayFormat: 'comma' });
|
|
303
|
+
}
|
|
304
|
+
|
|
254
305
|
static PostGrid = this;
|
|
255
306
|
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
256
307
|
|
|
@@ -292,6 +343,13 @@ PostGrid.Reports = Reports;
|
|
|
292
343
|
PostGrid.ReportListResponsesList = ReportListResponsesList;
|
|
293
344
|
PostGrid.SelfMailers = SelfMailers;
|
|
294
345
|
PostGrid.SelfMailerListResponsesList = SelfMailerListResponsesList;
|
|
346
|
+
PostGrid.MailingListImports = MailingListImports;
|
|
347
|
+
PostGrid.MailingListImportListResponsesList = MailingListImportListResponsesList;
|
|
348
|
+
PostGrid.MailingLists = MailingLists;
|
|
349
|
+
PostGrid.MailingListListResponsesList = MailingListListResponsesList;
|
|
350
|
+
PostGrid.OrderProfiles = OrderProfiles;
|
|
351
|
+
PostGrid.SubOrganizations = SubOrganizations;
|
|
352
|
+
PostGrid.SubOrganizationListResponsesList = SubOrganizationListResponsesList;
|
|
295
353
|
export declare namespace PostGrid {
|
|
296
354
|
export type RequestOptions = Core.RequestOptions;
|
|
297
355
|
|
|
@@ -406,11 +464,54 @@ export declare namespace PostGrid {
|
|
|
406
464
|
type SelfMailerRetrieveResponse as SelfMailerRetrieveResponse,
|
|
407
465
|
type SelfMailerListResponse as SelfMailerListResponse,
|
|
408
466
|
type SelfMailerCancelResponse as SelfMailerCancelResponse,
|
|
467
|
+
type SelfMailerRetrievePreviewURLResponse as SelfMailerRetrievePreviewURLResponse,
|
|
409
468
|
SelfMailerListResponsesList as SelfMailerListResponsesList,
|
|
410
469
|
type SelfMailerCreateParams as SelfMailerCreateParams,
|
|
411
470
|
type SelfMailerListParams as SelfMailerListParams,
|
|
412
471
|
};
|
|
413
472
|
|
|
473
|
+
export {
|
|
474
|
+
MailingListImports as MailingListImports,
|
|
475
|
+
type MailingListImportCreateResponse as MailingListImportCreateResponse,
|
|
476
|
+
type MailingListImportRetrieveResponse as MailingListImportRetrieveResponse,
|
|
477
|
+
type MailingListImportUpdateResponse as MailingListImportUpdateResponse,
|
|
478
|
+
type MailingListImportListResponse as MailingListImportListResponse,
|
|
479
|
+
type MailingListImportDeleteResponse as MailingListImportDeleteResponse,
|
|
480
|
+
MailingListImportListResponsesList as MailingListImportListResponsesList,
|
|
481
|
+
type MailingListImportCreateParams as MailingListImportCreateParams,
|
|
482
|
+
type MailingListImportUpdateParams as MailingListImportUpdateParams,
|
|
483
|
+
type MailingListImportListParams as MailingListImportListParams,
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
export {
|
|
487
|
+
MailingLists as MailingLists,
|
|
488
|
+
type MailingListCreateResponse as MailingListCreateResponse,
|
|
489
|
+
type MailingListRetrieveResponse as MailingListRetrieveResponse,
|
|
490
|
+
type MailingListUpdateResponse as MailingListUpdateResponse,
|
|
491
|
+
type MailingListListResponse as MailingListListResponse,
|
|
492
|
+
type MailingListDeleteResponse as MailingListDeleteResponse,
|
|
493
|
+
type MailingListSubmitJobResponse as MailingListSubmitJobResponse,
|
|
494
|
+
MailingListListResponsesList as MailingListListResponsesList,
|
|
495
|
+
type MailingListCreateParams as MailingListCreateParams,
|
|
496
|
+
type MailingListUpdateParams as MailingListUpdateParams,
|
|
497
|
+
type MailingListListParams as MailingListListParams,
|
|
498
|
+
type MailingListSubmitJobParams as MailingListSubmitJobParams,
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
export { OrderProfiles as OrderProfiles };
|
|
502
|
+
|
|
503
|
+
export {
|
|
504
|
+
SubOrganizations as SubOrganizations,
|
|
505
|
+
type SubOrganizationCreateResponse as SubOrganizationCreateResponse,
|
|
506
|
+
type SubOrganizationRetrieveResponse as SubOrganizationRetrieveResponse,
|
|
507
|
+
type SubOrganizationListResponse as SubOrganizationListResponse,
|
|
508
|
+
type SubOrganizationListUsersResponse as SubOrganizationListUsersResponse,
|
|
509
|
+
SubOrganizationListResponsesList as SubOrganizationListResponsesList,
|
|
510
|
+
type SubOrganizationCreateParams as SubOrganizationCreateParams,
|
|
511
|
+
type SubOrganizationListParams as SubOrganizationListParams,
|
|
512
|
+
type SubOrganizationListUsersParams as SubOrganizationListUsersParams,
|
|
513
|
+
};
|
|
514
|
+
|
|
414
515
|
export type Cancellation = API.Cancellation;
|
|
415
516
|
export type ContactCreateWithCompanyName = API.ContactCreateWithCompanyName;
|
|
416
517
|
export type ContactCreateWithFirstName = API.ContactCreateWithFirstName;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/puruvj/neoqs/graphs/contributors) All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
10
|
+
|
|
11
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Format } from './types';
|
|
2
|
+
|
|
3
|
+
export const default_format: Format = 'RFC3986';
|
|
4
|
+
export const formatters: Record<Format, (str: PropertyKey) => string> = {
|
|
5
|
+
RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
|
|
6
|
+
RFC3986: (v: PropertyKey) => String(v),
|
|
7
|
+
};
|
|
8
|
+
export const RFC1738 = 'RFC1738';
|
|
9
|
+
export const RFC3986 = 'RFC3986';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default_format, formatters, RFC1738, RFC3986 } from './formats';
|
|
2
|
+
|
|
3
|
+
const formats = {
|
|
4
|
+
formatters,
|
|
5
|
+
RFC1738,
|
|
6
|
+
RFC3986,
|
|
7
|
+
default: default_format,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { stringify } from './stringify';
|
|
11
|
+
export { formats };
|
|
12
|
+
|
|
13
|
+
export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types';
|