increase 0.8.1 → 0.9.1
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 +42 -0
- package/README.md +31 -11
- package/_shims/fetch.d.ts +8 -1
- package/_shims/fetch.node.d.ts +11 -1
- package/core.d.ts +76 -28
- package/core.d.ts.map +1 -1
- package/core.js +123 -55
- package/core.js.map +1 -1
- package/core.mjs +119 -55
- package/core.mjs.map +1 -1
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/index.mjs +3 -2
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/pagination.d.ts +2 -2
- package/pagination.d.ts.map +1 -1
- package/pagination.js +4 -4
- package/pagination.js.map +1 -1
- package/pagination.mjs +4 -4
- package/pagination.mjs.map +1 -1
- package/resources/account-numbers.d.ts +8 -8
- package/resources/account-numbers.d.ts.map +1 -1
- package/resources/account-numbers.js.map +1 -1
- package/resources/account-numbers.mjs.map +1 -1
- package/resources/account-statements.d.ts +3 -6
- package/resources/account-statements.d.ts.map +1 -1
- package/resources/account-statements.js.map +1 -1
- package/resources/account-statements.mjs.map +1 -1
- package/resources/account-transfers.d.ts +6 -18
- package/resources/account-transfers.d.ts.map +1 -1
- package/resources/account-transfers.js.map +1 -1
- package/resources/account-transfers.mjs.map +1 -1
- package/resources/accounts.d.ts +6 -6
- package/resources/accounts.d.ts.map +1 -1
- package/resources/ach-prenotifications.d.ts +51 -7
- package/resources/ach-prenotifications.d.ts.map +1 -1
- package/resources/ach-prenotifications.js.map +1 -1
- package/resources/ach-prenotifications.mjs.map +1 -1
- package/resources/ach-transfers.d.ts +16 -9
- package/resources/ach-transfers.d.ts.map +1 -1
- package/resources/ach-transfers.js.map +1 -1
- package/resources/ach-transfers.mjs.map +1 -1
- package/resources/balance-lookups.d.ts +1 -1
- package/resources/balance-lookups.d.ts.map +1 -1
- package/resources/bookkeeping-accounts.d.ts +3 -3
- package/resources/bookkeeping-accounts.d.ts.map +1 -1
- package/resources/bookkeeping-entries.d.ts +2 -2
- package/resources/bookkeeping-entries.d.ts.map +1 -1
- package/resources/bookkeeping-entry-sets.d.ts +1 -1
- package/resources/bookkeeping-entry-sets.d.ts.map +1 -1
- package/resources/card-disputes.d.ts +7 -7
- package/resources/card-disputes.d.ts.map +1 -1
- package/resources/card-disputes.js.map +1 -1
- package/resources/card-disputes.mjs.map +1 -1
- package/resources/card-profiles.d.ts +15 -7
- package/resources/card-profiles.d.ts.map +1 -1
- package/resources/card-profiles.js +6 -0
- package/resources/card-profiles.js.map +1 -1
- package/resources/card-profiles.mjs +6 -0
- package/resources/card-profiles.mjs.map +1 -1
- package/resources/card-purchase-supplements.d.ts +3 -3
- package/resources/card-purchase-supplements.d.ts.map +1 -1
- package/resources/cards.d.ts +6 -13
- package/resources/cards.d.ts.map +1 -1
- package/resources/cards.js.map +1 -1
- package/resources/cards.mjs.map +1 -1
- package/resources/check-deposits.d.ts +7 -7
- package/resources/check-deposits.d.ts.map +1 -1
- package/resources/check-deposits.js.map +1 -1
- package/resources/check-deposits.mjs.map +1 -1
- package/resources/check-transfers.d.ts +15 -10
- package/resources/check-transfers.d.ts.map +1 -1
- package/resources/check-transfers.js.map +1 -1
- package/resources/check-transfers.mjs.map +1 -1
- package/resources/declined-transactions.d.ts +25 -28
- package/resources/declined-transactions.d.ts.map +1 -1
- package/resources/declined-transactions.js.map +1 -1
- package/resources/declined-transactions.mjs.map +1 -1
- package/resources/digital-wallet-tokens.d.ts +3 -6
- package/resources/digital-wallet-tokens.d.ts.map +1 -1
- package/resources/digital-wallet-tokens.js.map +1 -1
- package/resources/digital-wallet-tokens.mjs.map +1 -1
- package/resources/documents.d.ts +3 -3
- package/resources/documents.d.ts.map +1 -1
- package/resources/entities/beneficial-owners.d.ts +4 -8
- package/resources/entities/beneficial-owners.d.ts.map +1 -1
- package/resources/entities/beneficial-owners.js.map +1 -1
- package/resources/entities/beneficial-owners.mjs.map +1 -1
- package/resources/entities/entities.d.ts +11 -11
- package/resources/entities/entities.d.ts.map +1 -1
- package/resources/entities/entities.js +6 -0
- package/resources/entities/entities.js.map +1 -1
- package/resources/entities/entities.mjs +6 -0
- package/resources/entities/entities.mjs.map +1 -1
- package/resources/entities/supplemental-documents.d.ts +2 -2
- package/resources/entities/supplemental-documents.d.ts.map +1 -1
- package/resources/event-subscriptions.d.ts +5 -8
- package/resources/event-subscriptions.d.ts.map +1 -1
- package/resources/event-subscriptions.js.map +1 -1
- package/resources/event-subscriptions.mjs.map +1 -1
- package/resources/events.d.ts +7 -5
- package/resources/events.d.ts.map +1 -1
- package/resources/events.js.map +1 -1
- package/resources/events.mjs.map +1 -1
- package/resources/exports.d.ts +4 -4
- package/resources/exports.d.ts.map +1 -1
- package/resources/external-accounts.d.ts +5 -11
- package/resources/external-accounts.d.ts.map +1 -1
- package/resources/external-accounts.js.map +1 -1
- package/resources/external-accounts.mjs.map +1 -1
- package/resources/files.d.ts +9 -4
- package/resources/files.d.ts.map +1 -1
- package/resources/files.js +2 -2
- package/resources/files.js.map +1 -1
- package/resources/files.mjs +2 -2
- package/resources/files.mjs.map +1 -1
- package/resources/groups.d.ts +1 -1
- package/resources/groups.d.ts.map +1 -1
- package/resources/inbound-ach-transfer-returns.d.ts +6 -4
- package/resources/inbound-ach-transfer-returns.d.ts.map +1 -1
- package/resources/inbound-ach-transfer-returns.js.map +1 -1
- package/resources/inbound-ach-transfer-returns.mjs.map +1 -1
- package/resources/inbound-wire-drawdown-requests.d.ts +5 -3
- package/resources/inbound-wire-drawdown-requests.d.ts.map +1 -1
- package/resources/inbound-wire-drawdown-requests.js.map +1 -1
- package/resources/inbound-wire-drawdown-requests.mjs.map +1 -1
- package/resources/limits.d.ts +5 -9
- package/resources/limits.d.ts.map +1 -1
- package/resources/limits.js.map +1 -1
- package/resources/limits.mjs.map +1 -1
- package/resources/oauth-connections.d.ts +3 -6
- package/resources/oauth-connections.d.ts.map +1 -1
- package/resources/oauth-connections.js.map +1 -1
- package/resources/oauth-connections.mjs.map +1 -1
- package/resources/pending-transactions.d.ts +28 -37
- package/resources/pending-transactions.d.ts.map +1 -1
- package/resources/pending-transactions.js.map +1 -1
- package/resources/pending-transactions.mjs.map +1 -1
- package/resources/programs.d.ts +3 -3
- package/resources/programs.d.ts.map +1 -1
- package/resources/real-time-decisions.d.ts +2 -5
- package/resources/real-time-decisions.d.ts.map +1 -1
- package/resources/real-time-decisions.js.map +1 -1
- package/resources/real-time-decisions.mjs.map +1 -1
- package/resources/real-time-payments-transfers.d.ts +6 -4
- package/resources/real-time-payments-transfers.d.ts.map +1 -1
- package/resources/real-time-payments-transfers.js.map +1 -1
- package/resources/real-time-payments-transfers.mjs.map +1 -1
- package/resources/routing-numbers.d.ts +4 -1
- package/resources/routing-numbers.d.ts.map +1 -1
- package/resources/routing-numbers.js.map +1 -1
- package/resources/routing-numbers.mjs.map +1 -1
- package/resources/simulations/account-statements.d.ts +1 -1
- package/resources/simulations/account-statements.d.ts.map +1 -1
- package/resources/simulations/account-transfers.d.ts +1 -1
- package/resources/simulations/account-transfers.d.ts.map +1 -1
- package/resources/simulations/ach-transfers.d.ts +124 -138
- package/resources/simulations/ach-transfers.d.ts.map +1 -1
- package/resources/simulations/ach-transfers.js.map +1 -1
- package/resources/simulations/ach-transfers.mjs.map +1 -1
- package/resources/simulations/card-disputes.d.ts +1 -1
- package/resources/simulations/card-disputes.d.ts.map +1 -1
- package/resources/simulations/card-profiles.d.ts +1 -4
- package/resources/simulations/card-profiles.d.ts.map +1 -1
- package/resources/simulations/card-profiles.js.map +1 -1
- package/resources/simulations/card-profiles.mjs.map +1 -1
- package/resources/simulations/card-refunds.d.ts +1 -1
- package/resources/simulations/card-refunds.d.ts.map +1 -1
- package/resources/simulations/cards.d.ts +49 -58
- package/resources/simulations/cards.d.ts.map +1 -1
- package/resources/simulations/cards.js.map +1 -1
- package/resources/simulations/cards.mjs.map +1 -1
- package/resources/simulations/check-deposits.d.ts +3 -12
- package/resources/simulations/check-deposits.d.ts.map +1 -1
- package/resources/simulations/check-transfers.d.ts +2 -2
- package/resources/simulations/check-transfers.d.ts.map +1 -1
- package/resources/simulations/digital-wallet-token-requests.d.ts +1 -1
- package/resources/simulations/digital-wallet-token-requests.d.ts.map +1 -1
- package/resources/simulations/documents.d.ts +1 -4
- package/resources/simulations/documents.d.ts.map +1 -1
- package/resources/simulations/documents.js.map +1 -1
- package/resources/simulations/documents.mjs.map +1 -1
- package/resources/simulations/inbound-funds-holds.d.ts +1 -1
- package/resources/simulations/inbound-funds-holds.d.ts.map +1 -1
- package/resources/simulations/inbound-wire-drawdown-requests.d.ts +1 -1
- package/resources/simulations/inbound-wire-drawdown-requests.d.ts.map +1 -1
- package/resources/simulations/interest-payments.d.ts +100 -108
- package/resources/simulations/interest-payments.d.ts.map +1 -1
- package/resources/simulations/interest-payments.js.map +1 -1
- package/resources/simulations/interest-payments.mjs.map +1 -1
- package/resources/simulations/programs.d.ts +1 -4
- package/resources/simulations/programs.d.ts.map +1 -1
- package/resources/simulations/programs.js.map +1 -1
- package/resources/simulations/programs.mjs.map +1 -1
- package/resources/simulations/real-time-payments-transfers.d.ts +123 -134
- package/resources/simulations/real-time-payments-transfers.d.ts.map +1 -1
- package/resources/simulations/real-time-payments-transfers.js.map +1 -1
- package/resources/simulations/real-time-payments-transfers.mjs.map +1 -1
- package/resources/simulations/wire-transfers.d.ts +100 -108
- package/resources/simulations/wire-transfers.d.ts.map +1 -1
- package/resources/simulations/wire-transfers.js.map +1 -1
- package/resources/simulations/wire-transfers.mjs.map +1 -1
- package/resources/transactions.d.ts +105 -110
- package/resources/transactions.d.ts.map +1 -1
- package/resources/transactions.js.map +1 -1
- package/resources/transactions.mjs.map +1 -1
- package/resources/wire-drawdown-requests.d.ts +4 -4
- package/resources/wire-drawdown-requests.d.ts.map +1 -1
- package/resources/wire-transfers.d.ts +11 -11
- package/resources/wire-transfers.d.ts.map +1 -1
- package/resources/wire-transfers.js.map +1 -1
- package/resources/wire-transfers.mjs.map +1 -1
- package/src/_shims/fetch.d.ts +8 -1
- package/src/_shims/fetch.node.d.ts +11 -1
- package/src/core.ts +176 -76
- package/src/index.ts +2 -2
- package/src/pagination.ts +5 -5
- package/src/resources/account-numbers.ts +9 -9
- package/src/resources/account-statements.ts +4 -7
- package/src/resources/account-transfers.ts +7 -19
- package/src/resources/accounts.ts +7 -7
- package/src/resources/ach-prenotifications.ts +56 -8
- package/src/resources/ach-transfers.ts +18 -10
- package/src/resources/balance-lookups.ts +1 -1
- package/src/resources/bookkeeping-accounts.ts +4 -4
- package/src/resources/bookkeeping-entries.ts +3 -3
- package/src/resources/bookkeeping-entry-sets.ts +1 -1
- package/src/resources/card-disputes.ts +8 -8
- package/src/resources/card-profiles.ts +20 -8
- package/src/resources/card-purchase-supplements.ts +4 -4
- package/src/resources/cards.ts +7 -14
- package/src/resources/check-deposits.ts +8 -8
- package/src/resources/check-transfers.ts +17 -11
- package/src/resources/declined-transactions.ts +26 -29
- package/src/resources/digital-wallet-tokens.ts +4 -7
- package/src/resources/documents.ts +4 -4
- package/src/resources/entities/beneficial-owners.ts +4 -8
- package/src/resources/entities/entities.ts +15 -12
- package/src/resources/entities/supplemental-documents.ts +2 -2
- package/src/resources/event-subscriptions.ts +6 -9
- package/src/resources/events.ts +8 -6
- package/src/resources/exports.ts +5 -5
- package/src/resources/external-accounts.ts +6 -12
- package/src/resources/files.ts +11 -6
- package/src/resources/groups.ts +1 -1
- package/src/resources/inbound-ach-transfer-returns.ts +7 -5
- package/src/resources/inbound-wire-drawdown-requests.ts +6 -4
- package/src/resources/limits.ts +6 -10
- package/src/resources/oauth-connections.ts +4 -7
- package/src/resources/pending-transactions.ts +29 -38
- package/src/resources/programs.ts +4 -4
- package/src/resources/real-time-decisions.ts +2 -5
- package/src/resources/real-time-payments-transfers.ts +7 -5
- package/src/resources/routing-numbers.ts +4 -1
- package/src/resources/simulations/account-statements.ts +1 -1
- package/src/resources/simulations/account-transfers.ts +1 -1
- package/src/resources/simulations/ach-transfers.ts +124 -138
- package/src/resources/simulations/card-disputes.ts +1 -1
- package/src/resources/simulations/card-profiles.ts +1 -4
- package/src/resources/simulations/card-refunds.ts +1 -1
- package/src/resources/simulations/cards.ts +49 -58
- package/src/resources/simulations/check-deposits.ts +3 -3
- package/src/resources/simulations/check-transfers.ts +2 -2
- package/src/resources/simulations/digital-wallet-token-requests.ts +1 -1
- package/src/resources/simulations/documents.ts +1 -4
- package/src/resources/simulations/inbound-funds-holds.ts +1 -1
- package/src/resources/simulations/inbound-wire-drawdown-requests.ts +1 -1
- package/src/resources/simulations/interest-payments.ts +100 -108
- package/src/resources/simulations/programs.ts +1 -4
- package/src/resources/simulations/real-time-payments-transfers.ts +123 -134
- package/src/resources/simulations/wire-transfers.ts +100 -108
- package/src/resources/transactions.ts +106 -111
- package/src/resources/wire-drawdown-requests.ts +5 -5
- package/src/resources/wire-transfers.ts +12 -12
- 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":"wire-transfers.d.ts","sourceRoot":"","sources":["../src/resources/wire-transfers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,GAAG,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvD,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;OAEG;IACH,MAAM,
|
|
1
|
+
{"version":3,"file":"wire-transfers.d.ts","sourceRoot":"","sources":["../src/resources/wire-transfers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,GAAG,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE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AiB,aAAa,CAAC;IAC7B,MAAM,QAAQ,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IAC9C,KAAY,iBAAiB,GAAG,kBAAkB,CAAC;IACnD,MAAM,QAAQ,wBAAwB,GAAG,GAAG,CAAC,wBAAwB,CAAC;IACtE,MAAM,QAAQ,sBAAsB,GAAG,GAAG,CAAC,sBAAsB,CAAC;CACnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-transfers.js","sourceRoot":"","sources":["../src/resources/wire-transfers.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,gDAAgD;AAChD,wCAAiD;AAEjD,oDAAuD;AAEvD,MAAa,aAAc,SAAQ,sBAAW;IAC5C;;OAEG;IACH,MAAM,
|
|
1
|
+
{"version":3,"file":"wire-transfers.js","sourceRoot":"","sources":["../src/resources/wire-transfers.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,gDAAgD;AAChD,wCAAiD;AAEjD,oDAAuD;AAEvD,MAAa,aAAc,SAAQ,sBAAW;IAC5C;;OAEG;IACH,MAAM,CAAC,IAA8B,EAAE,OAA6B;QAClE,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,cAAsB,EAAE,OAA6B;QAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAUD,IAAI,CACF,QAAsD,EAAE,EACxD,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,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,cAAsB,EAAE,OAA6B;QAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,cAAc,UAAU,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAsB,EAAE,OAA6B;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,cAAc,SAAS,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,cAAsB,EAAE,OAA6B;QAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,+BAA+B,cAAc,UAAU,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,cAAsB,EAAE,OAA6B;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,+BAA+B,cAAc,SAAS,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACF;AAjED,sCAiEC;AAED,MAAa,iBAAkB,SAAQ,iBAAkB;CAAG;AAA5D,8CAA4D;AA8Y5D,WAAiB,aAAa;AAK9B,CAAC,EALgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAK7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-transfers.mjs","sourceRoot":"","sources":["../src/resources/wire-transfers.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,mBAAmB;OACxC,EAAE,gBAAgB,EAAE,MAAM,eAAe;OAEzC,EAAE,IAAI,EAAc,MAAM,qBAAqB;AAEtD,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C;;OAEG;IACH,MAAM,
|
|
1
|
+
{"version":3,"file":"wire-transfers.mjs","sourceRoot":"","sources":["../src/resources/wire-transfers.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,mBAAmB;OACxC,EAAE,gBAAgB,EAA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AAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,IAAkB;CAAG;AA8Y5D,WAAiB,aAAa;AAK9B,CAAC,EALgB,aAAa,KAAb,aAAa,QAK7B"}
|
package/src/_shims/fetch.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ type _Response = unknown extends Response ? never : Response;
|
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
type _ResponseInit = unknown extends ResponseInit ? never : ResponseInit;
|
|
28
28
|
// @ts-ignore
|
|
29
|
+
type _ResponseType = unknown extends ResponseType ? never : ResponseType;
|
|
30
|
+
// @ts-ignore
|
|
29
31
|
type _BodyInit = unknown extends BodyInit ? never : BodyInit;
|
|
30
32
|
// @ts-ignore
|
|
31
33
|
type _Headers = unknown extends Headers ? never : Headers;
|
|
@@ -49,4 +51,9 @@ declare const _Headers: {
|
|
|
49
51
|
export const isPolyfilled = false;
|
|
50
52
|
|
|
51
53
|
export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers };
|
|
52
|
-
export type {
|
|
54
|
+
export type {
|
|
55
|
+
_RequestInit as RequestInit,
|
|
56
|
+
_RequestInfo as RequestInfo,
|
|
57
|
+
_ResponseType as ResponseType,
|
|
58
|
+
_BodyInit as BodyInit,
|
|
59
|
+
};
|
|
@@ -26,6 +26,11 @@ type _RequestInit = unknown extends RequestInit ? nf.RequestInit : RequestInit;
|
|
|
26
26
|
type _Response = unknown extends Response ? nf.Response : Response;
|
|
27
27
|
// @ts-ignore
|
|
28
28
|
type _ResponseInit = unknown extends ResponseInit ? nf.ResponseInit : ResponseInit;
|
|
29
|
+
type _ResponseType =
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
unknown extends ResponseType ? 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect'
|
|
32
|
+
: // @ts-ignore
|
|
33
|
+
ResponseType;
|
|
29
34
|
// @ts-ignore
|
|
30
35
|
type _BodyInit = unknown extends BodyInit ? nf.BodyInit : BodyInit;
|
|
31
36
|
// @ts-ignore
|
|
@@ -50,4 +55,9 @@ declare const _Headers: {
|
|
|
50
55
|
export const isPolyfilled = false;
|
|
51
56
|
|
|
52
57
|
export { _fetch as fetch, _Request as Request, _Response as Response, _Headers as Headers };
|
|
53
|
-
export type {
|
|
58
|
+
export type {
|
|
59
|
+
_RequestInit as RequestInit,
|
|
60
|
+
_RequestInfo as RequestInfo,
|
|
61
|
+
_ResponseType as ResponseType,
|
|
62
|
+
_BodyInit as BodyInit,
|
|
63
|
+
};
|
package/src/core.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type RequestInit,
|
|
10
10
|
type Response,
|
|
11
11
|
} from './_shims/fetch.js';
|
|
12
|
+
export { type Response };
|
|
12
13
|
import { isMultipartBody } from './uploads';
|
|
13
14
|
export {
|
|
14
15
|
maybeMultipartFormRequestOptions,
|
|
@@ -21,6 +22,100 @@ const MAX_RETRIES = 2;
|
|
|
21
22
|
|
|
22
23
|
export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
23
24
|
|
|
25
|
+
type PromiseOrValue<T> = T | Promise<T>;
|
|
26
|
+
|
|
27
|
+
type APIResponseProps = {
|
|
28
|
+
response: Response;
|
|
29
|
+
options: FinalRequestOptions;
|
|
30
|
+
controller: AbortController;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
|
|
34
|
+
const { response } = props;
|
|
35
|
+
const contentType = response.headers.get('content-type');
|
|
36
|
+
if (contentType?.includes('application/json')) {
|
|
37
|
+
const json = await response.json();
|
|
38
|
+
|
|
39
|
+
debug('response', response.status, response.url, response.headers, json);
|
|
40
|
+
|
|
41
|
+
return json as T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// TODO handle blob, arraybuffer, other content types, etc.
|
|
45
|
+
const text = await response.text();
|
|
46
|
+
debug('response', response.status, response.url, response.headers, text);
|
|
47
|
+
return text as T;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A subclass of `Promise` providing additional helper methods
|
|
52
|
+
* for interacting with the SDK.
|
|
53
|
+
*/
|
|
54
|
+
export class APIPromise<T> extends Promise<T> {
|
|
55
|
+
private parsedPromise: Promise<T> | undefined;
|
|
56
|
+
|
|
57
|
+
constructor(
|
|
58
|
+
private responsePromise: Promise<APIResponseProps>,
|
|
59
|
+
private parseResponse: (props: APIResponseProps) => PromiseOrValue<T> = defaultParseResponse,
|
|
60
|
+
) {
|
|
61
|
+
super((resolve) => {
|
|
62
|
+
// this is maybe a bit weird but this has to be a no-op to not implicitly
|
|
63
|
+
// parse the response body; instead .then, .catch, .finally are overridden
|
|
64
|
+
// to parse the response
|
|
65
|
+
resolve(null as any);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_thenUnwrap<U>(transform: (data: T) => U): APIPromise<U> {
|
|
70
|
+
return new APIPromise(this.responsePromise, async (props) => transform(await this.parseResponse(props)));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets the raw `Response` instance instead of parsing the response
|
|
75
|
+
* data.
|
|
76
|
+
*
|
|
77
|
+
* If you want to parse the response body but still get the `Response`
|
|
78
|
+
* instance, you can use {@link withResponse()}.
|
|
79
|
+
*/
|
|
80
|
+
asResponse(): Promise<Response> {
|
|
81
|
+
return this.responsePromise.then((p) => p.response);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the parsed response data and the raw `Response` instance.
|
|
85
|
+
*
|
|
86
|
+
* If you just want to get the raw `Response` instance without parsing it,
|
|
87
|
+
* you can use {@link asResponse()}.
|
|
88
|
+
*/
|
|
89
|
+
async withResponse(): Promise<{ data: T; response: Response }> {
|
|
90
|
+
const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
|
|
91
|
+
return { data, response };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private parse(): Promise<T> {
|
|
95
|
+
if (!this.parsedPromise) {
|
|
96
|
+
this.parsedPromise = this.responsePromise.then(this.parseResponse);
|
|
97
|
+
}
|
|
98
|
+
return this.parsedPromise;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
override then<TResult1 = T, TResult2 = never>(
|
|
102
|
+
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
|
|
103
|
+
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null,
|
|
104
|
+
): Promise<TResult1 | TResult2> {
|
|
105
|
+
return this.parse().then(onfulfilled, onrejected);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
override catch<TResult = never>(
|
|
109
|
+
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null,
|
|
110
|
+
): Promise<T | TResult> {
|
|
111
|
+
return this.parse().catch(onrejected);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
override finally(onfinally?: (() => void) | undefined | null): Promise<T> {
|
|
115
|
+
return this.parse().finally(onfinally);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
24
119
|
export abstract class APIClient {
|
|
25
120
|
baseURL: string;
|
|
26
121
|
maxRetries: number;
|
|
@@ -33,7 +128,7 @@ export abstract class APIClient {
|
|
|
33
128
|
constructor({
|
|
34
129
|
baseURL,
|
|
35
130
|
maxRetries,
|
|
36
|
-
timeout =
|
|
131
|
+
timeout = 60000, // 1 minute
|
|
37
132
|
httpAgent,
|
|
38
133
|
fetch: overridenFetch,
|
|
39
134
|
}: {
|
|
@@ -84,27 +179,39 @@ export abstract class APIClient {
|
|
|
84
179
|
return `stainless-node-retry-${uuid4()}`;
|
|
85
180
|
}
|
|
86
181
|
|
|
87
|
-
get<Req extends {}, Rsp>(path: string, opts?: RequestOptions<Req
|
|
88
|
-
return this.
|
|
182
|
+
get<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
183
|
+
return this.methodRequest('get', path, opts);
|
|
89
184
|
}
|
|
90
|
-
|
|
91
|
-
|
|
185
|
+
|
|
186
|
+
post<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
187
|
+
return this.methodRequest('post', path, opts);
|
|
92
188
|
}
|
|
93
|
-
|
|
94
|
-
|
|
189
|
+
|
|
190
|
+
patch<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
191
|
+
return this.methodRequest('patch', path, opts);
|
|
95
192
|
}
|
|
96
|
-
|
|
97
|
-
|
|
193
|
+
|
|
194
|
+
put<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
195
|
+
return this.methodRequest('put', path, opts);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
delete<Req extends {}, Rsp>(path: string, opts?: PromiseOrValue<RequestOptions<Req>>): APIPromise<Rsp> {
|
|
199
|
+
return this.methodRequest('delete', path, opts);
|
|
98
200
|
}
|
|
99
|
-
|
|
100
|
-
|
|
201
|
+
|
|
202
|
+
private methodRequest<Req extends {}, Rsp>(
|
|
203
|
+
method: HTTPMethod,
|
|
204
|
+
path: string,
|
|
205
|
+
opts?: PromiseOrValue<RequestOptions<Req>>,
|
|
206
|
+
): APIPromise<Rsp> {
|
|
207
|
+
return this.request(Promise.resolve(opts).then((opts) => ({ method, path, ...opts })));
|
|
101
208
|
}
|
|
102
209
|
|
|
103
210
|
getAPIList<Item, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(
|
|
104
211
|
path: string,
|
|
105
212
|
Page: new (...args: any[]) => PageClass,
|
|
106
213
|
opts?: RequestOptions<any>,
|
|
107
|
-
): PagePromise<PageClass> {
|
|
214
|
+
): PagePromise<PageClass, Item> {
|
|
108
215
|
return this.requestAPIList(Page, { method: 'get', path, ...opts });
|
|
109
216
|
}
|
|
110
217
|
|
|
@@ -140,7 +247,10 @@ export abstract class APIClient {
|
|
|
140
247
|
const timeout = options.timeout ?? this.timeout;
|
|
141
248
|
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
|
|
142
249
|
const minAgentTimeout = timeout + 1000;
|
|
143
|
-
if (
|
|
250
|
+
if (
|
|
251
|
+
typeof (httpAgent as any)?.options?.timeout === 'number' &&
|
|
252
|
+
minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
|
|
253
|
+
) {
|
|
144
254
|
// Allow any given request to bump our agent active socket timeout.
|
|
145
255
|
// This may seem strange, but leaking active sockets should be rare and not particularly problematic,
|
|
146
256
|
// and without mutating agent we would need to create more of them.
|
|
@@ -198,14 +308,27 @@ export abstract class APIClient {
|
|
|
198
308
|
return APIError.generate(status, error, message, headers);
|
|
199
309
|
}
|
|
200
310
|
|
|
201
|
-
|
|
202
|
-
options: FinalRequestOptions<Req
|
|
203
|
-
|
|
204
|
-
):
|
|
311
|
+
request<Req extends {}, Rsp>(
|
|
312
|
+
options: PromiseOrValue<FinalRequestOptions<Req>>,
|
|
313
|
+
remainingRetries: number | null = null,
|
|
314
|
+
): APIPromise<Rsp> {
|
|
315
|
+
return new APIPromise(this.makeRequest(options, remainingRetries));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private async makeRequest(
|
|
319
|
+
optionsInput: PromiseOrValue<FinalRequestOptions>,
|
|
320
|
+
retriesRemaining: number | null,
|
|
321
|
+
): Promise<APIResponseProps> {
|
|
322
|
+
const options = await optionsInput;
|
|
323
|
+
if (retriesRemaining == null) {
|
|
324
|
+
retriesRemaining = options.maxRetries ?? this.maxRetries;
|
|
325
|
+
}
|
|
326
|
+
|
|
205
327
|
const { req, url, timeout } = this.buildRequest(options);
|
|
328
|
+
|
|
206
329
|
await this.prepareRequest(req, { url });
|
|
207
330
|
|
|
208
|
-
|
|
331
|
+
debug('request', url, options, req.headers);
|
|
209
332
|
|
|
210
333
|
if (options.signal?.aborted) {
|
|
211
334
|
throw new APIUserAbortError();
|
|
@@ -238,42 +361,21 @@ export abstract class APIClient {
|
|
|
238
361
|
const errJSON = safeJSON(errText);
|
|
239
362
|
const errMessage = errJSON ? undefined : errText;
|
|
240
363
|
|
|
241
|
-
|
|
364
|
+
debug('response', response.status, url, responseHeaders, errMessage);
|
|
242
365
|
|
|
243
366
|
const err = this.makeStatusError(response.status, errJSON, errMessage, responseHeaders);
|
|
244
367
|
throw err;
|
|
245
368
|
}
|
|
246
369
|
|
|
247
|
-
|
|
248
|
-
if (contentType?.includes('application/json')) {
|
|
249
|
-
const json = await response.json();
|
|
250
|
-
|
|
251
|
-
if (typeof json === 'object' && json != null) {
|
|
252
|
-
/** @deprecated – we expect to change this interface in the near future. */
|
|
253
|
-
Object.defineProperty(json, 'responseHeaders', {
|
|
254
|
-
enumerable: false,
|
|
255
|
-
writable: false,
|
|
256
|
-
value: responseHeaders,
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
this.debug('response', response.status, url, responseHeaders, json);
|
|
261
|
-
|
|
262
|
-
return json as APIResponse<Rsp>;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// TODO handle blob, arraybuffer, other content types, etc.
|
|
266
|
-
const text = response.text();
|
|
267
|
-
this.debug('response', response.status, url, responseHeaders, text);
|
|
268
|
-
return text as Promise<any>;
|
|
370
|
+
return { response, options, controller };
|
|
269
371
|
}
|
|
270
372
|
|
|
271
373
|
requestAPIList<Item = unknown, PageClass extends AbstractPage<Item> = AbstractPage<Item>>(
|
|
272
374
|
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
273
375
|
options: FinalRequestOptions,
|
|
274
|
-
): PagePromise<PageClass> {
|
|
275
|
-
const
|
|
276
|
-
return new PagePromise(this,
|
|
376
|
+
): PagePromise<PageClass, Item> {
|
|
377
|
+
const request = this.makeRequest(options, null);
|
|
378
|
+
return new PagePromise<PageClass, Item>(this, request, Page);
|
|
277
379
|
}
|
|
278
380
|
|
|
279
381
|
buildURL<Req>(path: string, query: Req | undefined): string {
|
|
@@ -353,11 +455,11 @@ export abstract class APIClient {
|
|
|
353
455
|
return false;
|
|
354
456
|
}
|
|
355
457
|
|
|
356
|
-
private async retryRequest
|
|
357
|
-
options: FinalRequestOptions
|
|
458
|
+
private async retryRequest(
|
|
459
|
+
options: FinalRequestOptions,
|
|
358
460
|
retriesRemaining: number,
|
|
359
461
|
responseHeaders?: Headers | undefined,
|
|
360
|
-
): Promise<
|
|
462
|
+
): Promise<APIResponseProps> {
|
|
361
463
|
retriesRemaining -= 1;
|
|
362
464
|
|
|
363
465
|
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
@@ -370,7 +472,7 @@ export abstract class APIClient {
|
|
|
370
472
|
const timeout = this.calculateRetryTimeoutSeconds(retriesRemaining, retryAfter, maxRetries) * 1000;
|
|
371
473
|
await sleep(timeout);
|
|
372
474
|
|
|
373
|
-
return this.
|
|
475
|
+
return this.makeRequest(options, retriesRemaining);
|
|
374
476
|
}
|
|
375
477
|
|
|
376
478
|
private calculateRetryTimeoutSeconds(
|
|
@@ -401,12 +503,6 @@ export abstract class APIClient {
|
|
|
401
503
|
private getUserAgent(): string {
|
|
402
504
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
403
505
|
}
|
|
404
|
-
|
|
405
|
-
private debug(action: string, ...args: any[]) {
|
|
406
|
-
if (typeof process !== 'undefined' && process.env['DEBUG'] === 'true') {
|
|
407
|
-
console.log(`${this.constructor.name}:DEBUG:${action}`, ...args);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
506
|
}
|
|
411
507
|
|
|
412
508
|
export class APIResource {
|
|
@@ -436,9 +532,14 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
|
436
532
|
#client: APIClient;
|
|
437
533
|
protected options: FinalRequestOptions;
|
|
438
534
|
|
|
439
|
-
|
|
535
|
+
protected response: Response;
|
|
536
|
+
protected body: unknown;
|
|
537
|
+
|
|
538
|
+
constructor(client: APIClient, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
440
539
|
this.#client = client;
|
|
441
540
|
this.options = options;
|
|
541
|
+
this.response = response;
|
|
542
|
+
this.body = body;
|
|
442
543
|
}
|
|
443
544
|
|
|
444
545
|
/**
|
|
@@ -495,35 +596,33 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
|
495
596
|
}
|
|
496
597
|
}
|
|
497
598
|
|
|
599
|
+
/**
|
|
600
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
601
|
+
*
|
|
602
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
603
|
+
*
|
|
604
|
+
* for await (const item of client.items.list()) {
|
|
605
|
+
* console.log(item)
|
|
606
|
+
* }
|
|
607
|
+
*/
|
|
498
608
|
export class PagePromise<
|
|
499
609
|
PageClass extends AbstractPage<Item>,
|
|
500
610
|
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
501
611
|
>
|
|
502
|
-
extends
|
|
612
|
+
extends APIPromise<PageClass>
|
|
503
613
|
implements AsyncIterable<Item>
|
|
504
614
|
{
|
|
505
|
-
/**
|
|
506
|
-
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
507
|
-
*/
|
|
508
615
|
constructor(
|
|
509
616
|
client: APIClient,
|
|
510
|
-
|
|
511
|
-
options: FinalRequestOptions,
|
|
617
|
+
request: Promise<APIResponseProps>,
|
|
512
618
|
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
513
619
|
) {
|
|
514
|
-
super(
|
|
515
|
-
|
|
620
|
+
super(
|
|
621
|
+
request,
|
|
622
|
+
async (props) => new Page(client, props.response, await defaultParseResponse(props), props.options),
|
|
516
623
|
);
|
|
517
624
|
}
|
|
518
625
|
|
|
519
|
-
/**
|
|
520
|
-
* Enable subclassing Promise.
|
|
521
|
-
* Ref: https://stackoverflow.com/a/60328122
|
|
522
|
-
*/
|
|
523
|
-
static get [Symbol.species]() {
|
|
524
|
-
return Promise;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
626
|
/**
|
|
528
627
|
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
529
628
|
*
|
|
@@ -610,11 +709,6 @@ export type FinalRequestOptions<Req extends {} = Record<string, unknown> | Reada
|
|
|
610
709
|
path: string;
|
|
611
710
|
};
|
|
612
711
|
|
|
613
|
-
export type APIResponse<T> = T & {
|
|
614
|
-
/** @deprecated - we plan to add a different way to access raw response information shortly. */
|
|
615
|
-
responseHeaders: Headers;
|
|
616
|
-
};
|
|
617
|
-
|
|
618
712
|
declare const Deno: any;
|
|
619
713
|
declare const EdgeRuntime: any;
|
|
620
714
|
type Arch = 'x32' | 'x64' | 'arm' | 'arm64' | `other:${string}` | 'unknown';
|
|
@@ -877,6 +971,12 @@ export function hasOwn(obj: Object, key: string): boolean {
|
|
|
877
971
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
878
972
|
}
|
|
879
973
|
|
|
974
|
+
export function debug(action: string, ...args: any[]) {
|
|
975
|
+
if (typeof process !== 'undefined' && process.env['DEBUG'] === 'true') {
|
|
976
|
+
console.log(`Increase:DEBUG:${action}`, ...args);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
880
980
|
/**
|
|
881
981
|
* https://stackoverflow.com/a/2117523
|
|
882
982
|
*/
|
package/src/index.ts
CHANGED
|
@@ -92,7 +92,7 @@ export class Increase extends Core.APIClient {
|
|
|
92
92
|
constructor({ apiKey = Core.readEnv('INCREASE_API_KEY'), ...opts }: ClientOptions = {}) {
|
|
93
93
|
if (apiKey === undefined) {
|
|
94
94
|
throw new Error(
|
|
95
|
-
|
|
95
|
+
"The INCREASE_API_KEY environment variable is missing or empty; either provide it, or instantiate the Increase client with an apiKey option, like new Increase({ apiKey: 'my apiKey' }).",
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -104,7 +104,7 @@ export class Increase extends Core.APIClient {
|
|
|
104
104
|
|
|
105
105
|
super({
|
|
106
106
|
baseURL: options.baseURL || environments[options.environment || 'production'],
|
|
107
|
-
timeout: options.timeout
|
|
107
|
+
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
108
108
|
httpAgent: options.httpAgent,
|
|
109
109
|
maxRetries: options.maxRetries,
|
|
110
110
|
fetch: options.fetch,
|
package/src/pagination.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { AbstractPage,
|
|
3
|
+
import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A list of Account objects
|
|
@@ -35,11 +35,11 @@ export class Page<Item> extends AbstractPage<Item> implements PageResponse<Item>
|
|
|
35
35
|
*/
|
|
36
36
|
next_cursor: string | null;
|
|
37
37
|
|
|
38
|
-
constructor(client: APIClient, response:
|
|
39
|
-
super(client, response, options);
|
|
38
|
+
constructor(client: APIClient, response: Response, body: PageResponse<Item>, options: FinalRequestOptions) {
|
|
39
|
+
super(client, response, body, options);
|
|
40
40
|
|
|
41
|
-
this.data =
|
|
42
|
-
this.next_cursor =
|
|
41
|
+
this.data = body.data;
|
|
42
|
+
this.next_cursor = body.next_cursor;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
getPaginatedItems(): Item[] {
|
|
@@ -10,17 +10,14 @@ export class AccountNumbers extends APIResource {
|
|
|
10
10
|
/**
|
|
11
11
|
* Create an Account Number
|
|
12
12
|
*/
|
|
13
|
-
create(
|
|
14
|
-
body: AccountNumberCreateParams,
|
|
15
|
-
options?: Core.RequestOptions,
|
|
16
|
-
): Promise<Core.APIResponse<AccountNumber>> {
|
|
13
|
+
create(body: AccountNumberCreateParams, options?: Core.RequestOptions): Core.APIPromise<AccountNumber> {
|
|
17
14
|
return this.post('/account_numbers', { body, ...options });
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Retrieve an Account Number
|
|
22
19
|
*/
|
|
23
|
-
retrieve(accountNumberId: string, options?: Core.RequestOptions):
|
|
20
|
+
retrieve(accountNumberId: string, options?: Core.RequestOptions): Core.APIPromise<AccountNumber> {
|
|
24
21
|
return this.get(`/account_numbers/${accountNumberId}`, options);
|
|
25
22
|
}
|
|
26
23
|
|
|
@@ -31,19 +28,22 @@ export class AccountNumbers extends APIResource {
|
|
|
31
28
|
accountNumberId: string,
|
|
32
29
|
body: AccountNumberUpdateParams,
|
|
33
30
|
options?: Core.RequestOptions,
|
|
34
|
-
):
|
|
31
|
+
): Core.APIPromise<AccountNumber> {
|
|
35
32
|
return this.patch(`/account_numbers/${accountNumberId}`, { body, ...options });
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
/**
|
|
39
36
|
* List Account Numbers
|
|
40
37
|
*/
|
|
41
|
-
list(
|
|
42
|
-
|
|
38
|
+
list(
|
|
39
|
+
query?: AccountNumberListParams,
|
|
40
|
+
options?: Core.RequestOptions,
|
|
41
|
+
): Core.PagePromise<AccountNumbersPage, AccountNumber>;
|
|
42
|
+
list(options?: Core.RequestOptions): Core.PagePromise<AccountNumbersPage, AccountNumber>;
|
|
43
43
|
list(
|
|
44
44
|
query: AccountNumberListParams | Core.RequestOptions = {},
|
|
45
45
|
options?: Core.RequestOptions,
|
|
46
|
-
): Core.PagePromise<AccountNumbersPage> {
|
|
46
|
+
): Core.PagePromise<AccountNumbersPage, AccountNumber> {
|
|
47
47
|
if (isRequestOptions(query)) {
|
|
48
48
|
return this.list({}, query);
|
|
49
49
|
}
|
|
@@ -10,10 +10,7 @@ export class AccountStatements extends APIResource {
|
|
|
10
10
|
/**
|
|
11
11
|
* Retrieve an Account Statement
|
|
12
12
|
*/
|
|
13
|
-
retrieve(
|
|
14
|
-
accountStatementId: string,
|
|
15
|
-
options?: Core.RequestOptions,
|
|
16
|
-
): Promise<Core.APIResponse<AccountStatement>> {
|
|
13
|
+
retrieve(accountStatementId: string, options?: Core.RequestOptions): Core.APIPromise<AccountStatement> {
|
|
17
14
|
return this.get(`/account_statements/${accountStatementId}`, options);
|
|
18
15
|
}
|
|
19
16
|
|
|
@@ -23,12 +20,12 @@ export class AccountStatements extends APIResource {
|
|
|
23
20
|
list(
|
|
24
21
|
query?: AccountStatementListParams,
|
|
25
22
|
options?: Core.RequestOptions,
|
|
26
|
-
): Core.PagePromise<AccountStatementsPage>;
|
|
27
|
-
list(options?: Core.RequestOptions): Core.PagePromise<AccountStatementsPage>;
|
|
23
|
+
): Core.PagePromise<AccountStatementsPage, AccountStatement>;
|
|
24
|
+
list(options?: Core.RequestOptions): Core.PagePromise<AccountStatementsPage, AccountStatement>;
|
|
28
25
|
list(
|
|
29
26
|
query: AccountStatementListParams | Core.RequestOptions = {},
|
|
30
27
|
options?: Core.RequestOptions,
|
|
31
|
-
): Core.PagePromise<AccountStatementsPage> {
|
|
28
|
+
): Core.PagePromise<AccountStatementsPage, AccountStatement> {
|
|
32
29
|
if (isRequestOptions(query)) {
|
|
33
30
|
return this.list({}, query);
|
|
34
31
|
}
|
|
@@ -10,20 +10,14 @@ export class AccountTransfers extends APIResource {
|
|
|
10
10
|
/**
|
|
11
11
|
* Create an Account Transfer
|
|
12
12
|
*/
|
|
13
|
-
create(
|
|
14
|
-
body: AccountTransferCreateParams,
|
|
15
|
-
options?: Core.RequestOptions,
|
|
16
|
-
): Promise<Core.APIResponse<AccountTransfer>> {
|
|
13
|
+
create(body: AccountTransferCreateParams, options?: Core.RequestOptions): Core.APIPromise<AccountTransfer> {
|
|
17
14
|
return this.post('/account_transfers', { body, ...options });
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Retrieve an Account Transfer
|
|
22
19
|
*/
|
|
23
|
-
retrieve(
|
|
24
|
-
accountTransferId: string,
|
|
25
|
-
options?: Core.RequestOptions,
|
|
26
|
-
): Promise<Core.APIResponse<AccountTransfer>> {
|
|
20
|
+
retrieve(accountTransferId: string, options?: Core.RequestOptions): Core.APIPromise<AccountTransfer> {
|
|
27
21
|
return this.get(`/account_transfers/${accountTransferId}`, options);
|
|
28
22
|
}
|
|
29
23
|
|
|
@@ -33,12 +27,12 @@ export class AccountTransfers extends APIResource {
|
|
|
33
27
|
list(
|
|
34
28
|
query?: AccountTransferListParams,
|
|
35
29
|
options?: Core.RequestOptions,
|
|
36
|
-
): Core.PagePromise<AccountTransfersPage>;
|
|
37
|
-
list(options?: Core.RequestOptions): Core.PagePromise<AccountTransfersPage>;
|
|
30
|
+
): Core.PagePromise<AccountTransfersPage, AccountTransfer>;
|
|
31
|
+
list(options?: Core.RequestOptions): Core.PagePromise<AccountTransfersPage, AccountTransfer>;
|
|
38
32
|
list(
|
|
39
33
|
query: AccountTransferListParams | Core.RequestOptions = {},
|
|
40
34
|
options?: Core.RequestOptions,
|
|
41
|
-
): Core.PagePromise<AccountTransfersPage> {
|
|
35
|
+
): Core.PagePromise<AccountTransfersPage, AccountTransfer> {
|
|
42
36
|
if (isRequestOptions(query)) {
|
|
43
37
|
return this.list({}, query);
|
|
44
38
|
}
|
|
@@ -48,20 +42,14 @@ export class AccountTransfers extends APIResource {
|
|
|
48
42
|
/**
|
|
49
43
|
* Approve an Account Transfer
|
|
50
44
|
*/
|
|
51
|
-
approve(
|
|
52
|
-
accountTransferId: string,
|
|
53
|
-
options?: Core.RequestOptions,
|
|
54
|
-
): Promise<Core.APIResponse<AccountTransfer>> {
|
|
45
|
+
approve(accountTransferId: string, options?: Core.RequestOptions): Core.APIPromise<AccountTransfer> {
|
|
55
46
|
return this.post(`/account_transfers/${accountTransferId}/approve`, options);
|
|
56
47
|
}
|
|
57
48
|
|
|
58
49
|
/**
|
|
59
50
|
* Cancel an Account Transfer
|
|
60
51
|
*/
|
|
61
|
-
cancel(
|
|
62
|
-
accountTransferId: string,
|
|
63
|
-
options?: Core.RequestOptions,
|
|
64
|
-
): Promise<Core.APIResponse<AccountTransfer>> {
|
|
52
|
+
cancel(accountTransferId: string, options?: Core.RequestOptions): Core.APIPromise<AccountTransfer> {
|
|
65
53
|
return this.post(`/account_transfers/${accountTransferId}/cancel`, options);
|
|
66
54
|
}
|
|
67
55
|
}
|