partnermax 0.2.1 → 0.2.2
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 +15 -0
- package/README.md +41 -17
- package/client.d.mts +9 -3
- package/client.d.mts.map +1 -1
- package/client.d.ts +9 -3
- package/client.d.ts.map +1 -1
- package/client.js +11 -1
- package/client.js.map +1 -1
- package/client.mjs +11 -1
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +57 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +57 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +108 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +102 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/package.json +11 -1
- package/pagination.d.mts +3 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +3 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +3 -0
- package/pagination.mjs.map +1 -0
- package/resources/dealers/dealers.d.mts +7 -71
- package/resources/dealers/dealers.d.mts.map +1 -1
- package/resources/dealers/dealers.d.ts +7 -71
- package/resources/dealers/dealers.d.ts.map +1 -1
- package/resources/dealers/dealers.js +2 -15
- package/resources/dealers/dealers.js.map +1 -1
- package/resources/dealers/dealers.mjs +2 -15
- package/resources/dealers/dealers.mjs.map +1 -1
- package/resources/dealers/index.d.mts +2 -2
- package/resources/dealers/index.d.mts.map +1 -1
- package/resources/dealers/index.d.ts +2 -2
- package/resources/dealers/index.d.ts.map +1 -1
- package/resources/dealers/index.js.map +1 -1
- package/resources/dealers/index.mjs.map +1 -1
- package/resources/dealers/nlt/index.d.mts +1 -1
- package/resources/dealers/nlt/index.d.mts.map +1 -1
- package/resources/dealers/nlt/index.d.ts +1 -1
- package/resources/dealers/nlt/index.d.ts.map +1 -1
- package/resources/dealers/nlt/nlt.d.mts +2 -2
- package/resources/dealers/nlt/nlt.d.mts.map +1 -1
- package/resources/dealers/nlt/nlt.d.ts +2 -2
- package/resources/dealers/nlt/nlt.d.ts.map +1 -1
- package/resources/dealers/nlt/offers.d.mts +55 -78
- package/resources/dealers/nlt/offers.d.mts.map +1 -1
- package/resources/dealers/nlt/offers.d.ts +55 -78
- package/resources/dealers/nlt/offers.d.ts.map +1 -1
- package/resources/dealers/nlt/offers.js +9 -11
- package/resources/dealers/nlt/offers.js.map +1 -1
- package/resources/dealers/nlt/offers.mjs +9 -11
- package/resources/dealers/nlt/offers.mjs.map +1 -1
- package/resources/dealers/nlt-settings.d.mts +24 -64
- package/resources/dealers/nlt-settings.d.mts.map +1 -1
- package/resources/dealers/nlt-settings.d.ts +24 -64
- package/resources/dealers/nlt-settings.d.ts.map +1 -1
- package/resources/dealers/nlt-settings.js +4 -13
- package/resources/dealers/nlt-settings.js.map +1 -1
- package/resources/dealers/nlt-settings.mjs +4 -13
- package/resources/dealers/nlt-settings.mjs.map +1 -1
- package/resources/dealers/vehicles/images.d.mts +3 -2
- package/resources/dealers/vehicles/images.d.mts.map +1 -1
- package/resources/dealers/vehicles/images.d.ts +3 -2
- package/resources/dealers/vehicles/images.d.ts.map +1 -1
- package/resources/dealers/vehicles/images.js +3 -2
- package/resources/dealers/vehicles/images.js.map +1 -1
- package/resources/dealers/vehicles/images.mjs +3 -2
- package/resources/dealers/vehicles/images.mjs.map +1 -1
- package/resources/dealers/vehicles/index.d.mts +1 -1
- package/resources/dealers/vehicles/index.d.mts.map +1 -1
- package/resources/dealers/vehicles/index.d.ts +1 -1
- package/resources/dealers/vehicles/index.d.ts.map +1 -1
- package/resources/dealers/vehicles/index.js.map +1 -1
- package/resources/dealers/vehicles/index.mjs.map +1 -1
- package/resources/dealers/vehicles/vehicles.d.mts +57 -70
- package/resources/dealers/vehicles/vehicles.d.mts.map +1 -1
- package/resources/dealers/vehicles/vehicles.d.ts +57 -70
- package/resources/dealers/vehicles/vehicles.d.ts.map +1 -1
- package/resources/dealers/vehicles/vehicles.js +18 -18
- package/resources/dealers/vehicles/vehicles.js.map +1 -1
- package/resources/dealers/vehicles/vehicles.mjs +18 -18
- package/resources/dealers/vehicles/vehicles.mjs.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/keys.d.mts +7 -6
- package/resources/keys.d.mts.map +1 -1
- package/resources/keys.d.ts +7 -6
- package/resources/keys.d.ts.map +1 -1
- package/resources/keys.js +7 -6
- package/resources/keys.js.map +1 -1
- package/resources/keys.mjs +7 -6
- package/resources/keys.mjs.map +1 -1
- package/src/client.ts +32 -5
- package/src/core/pagination.ts +170 -0
- package/src/index.ts +1 -0
- package/src/pagination.ts +2 -0
- package/src/resources/dealers/dealers.ts +9 -97
- package/src/resources/dealers/index.ts +2 -2
- package/src/resources/dealers/nlt/index.ts +1 -1
- package/src/resources/dealers/nlt/nlt.ts +2 -2
- package/src/resources/dealers/nlt/offers.ts +60 -84
- package/src/resources/dealers/nlt-settings.ts +24 -64
- package/src/resources/dealers/vehicles/images.ts +3 -2
- package/src/resources/dealers/vehicles/index.ts +1 -0
- package/src/resources/dealers/vehicles/vehicles.ts +62 -72
- package/src/resources/index.ts +1 -2
- package/src/resources/keys.ts +7 -6
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/resources/keys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/resources/keys.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,EAAE,UAAU,EAAE,+BAA4B;AAEjD,OAAO,EAAE,cAAc,EAAE,uCAAoC;AAG7D;;GAEG;AACH,qBAAa,IAAK,SAAQ,WAAW;IACnC;;;;;OAKG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;IAI3D
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/resources/keys.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,EAAE,UAAU,EAAE,+BAA4B;AAEjD,OAAO,EAAE,cAAc,EAAE,uCAAoC;AAG7D;;GAEG;AACH,qBAAa,IAAK,SAAQ,WAAW;IACnC;;;;;OAKG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;IAI3D;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,gBAAgB,CAAC;IAYrF;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;CAMlE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;CACnC;AAED,yBAAiB,eAAe,CAAC;IAC/B;;OAEG;IACH,UAAiB,IAAI;QACnB,UAAU,EAAE,MAAM,CAAC;QAEnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAE1B,SAAS,EAAE,OAAO,CAAC;QAEnB,MAAM,EAAE,MAAM,CAAC;QAEf,UAAU,EAAE,MAAM,CAAC;QAEnB,KAAK,EAAE,MAAM,CAAC;QAEd,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B;CACF;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IAEnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,OAAO,EACL,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,cAAc,IAAI,cAAc,GACtC,CAAC;CACH"}
|
package/resources/keys.js
CHANGED
|
@@ -6,7 +6,7 @@ const resource_1 = require("../core/resource.js");
|
|
|
6
6
|
const headers_1 = require("../internal/headers.js");
|
|
7
7
|
const path_1 = require("../internal/utils/path.js");
|
|
8
8
|
/**
|
|
9
|
-
* API key lifecycle management
|
|
9
|
+
* API key lifecycle management. PartnerMAX v1 allows one active API key per partner/environment; partners authenticate every request with `X-Api-Key` (preferred) or `Authorization: Bearer <key>`, and replacement is handled through DealerMAX support.
|
|
10
10
|
*/
|
|
11
11
|
class Keys extends resource_1.APIResource {
|
|
12
12
|
/**
|
|
@@ -19,12 +19,13 @@ class Keys extends resource_1.APIResource {
|
|
|
19
19
|
return this._client.get('/v1/keys', options);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Rotate the partner API key during a DealerMAX support flow.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* Plaintext is returned exactly once. The key authenticating this request is
|
|
25
|
+
* deactivated in the same transaction that inserts the replacement, preserving
|
|
26
|
+
* PartnerMAX v1's one-active-key invariant. Callers must not use this endpoint for
|
|
27
|
+
* per-deployment, CI, or engineer credentials. Capability gate: caller's key must
|
|
28
|
+
* hold `can_issue_keys`.
|
|
28
29
|
*/
|
|
29
30
|
issue(params, options) {
|
|
30
31
|
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
package/resources/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/resources/keys.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAE/C,oDAAmD;AAEnD,oDAA8C;AAE9C;;GAEG;AACH,MAAa,IAAK,SAAQ,sBAAW;IACnC;;;;;OAKG;IACH,IAAI,CAAC,OAAwB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/resources/keys.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAE/C,oDAAmD;AAEnD,oDAA8C;AAE9C;;GAEG;AACH,MAAa,IAAK,SAAQ,sBAAW;IACnC;;;;;OAKG;IACH,IAAI,CAAC,OAAwB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAsB,EAAE,OAAwB;QACpD,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACzC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB,EAAE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;gBACnF,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAa,EAAE,OAAwB;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,YAAY,KAAK,EAAE,EAAE;YAClD,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;CACF;AAzCD,oBAyCC"}
|
package/resources/keys.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { APIResource } from "../core/resource.mjs";
|
|
|
3
3
|
import { buildHeaders } from "../internal/headers.mjs";
|
|
4
4
|
import { path } from "../internal/utils/path.mjs";
|
|
5
5
|
/**
|
|
6
|
-
* API key lifecycle management
|
|
6
|
+
* API key lifecycle management. PartnerMAX v1 allows one active API key per partner/environment; partners authenticate every request with `X-Api-Key` (preferred) or `Authorization: Bearer <key>`, and replacement is handled through DealerMAX support.
|
|
7
7
|
*/
|
|
8
8
|
export class Keys extends APIResource {
|
|
9
9
|
/**
|
|
@@ -16,12 +16,13 @@ export class Keys extends APIResource {
|
|
|
16
16
|
return this._client.get('/v1/keys', options);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Rotate the partner API key during a DealerMAX support flow.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Plaintext is returned exactly once. The key authenticating this request is
|
|
22
|
+
* deactivated in the same transaction that inserts the replacement, preserving
|
|
23
|
+
* PartnerMAX v1's one-active-key invariant. Callers must not use this endpoint for
|
|
24
|
+
* per-deployment, CI, or engineer credentials. Capability gate: caller's key must
|
|
25
|
+
* hold `can_issue_keys`.
|
|
25
26
|
*/
|
|
26
27
|
issue(params, options) {
|
|
27
28
|
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
package/resources/keys.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.mjs","sourceRoot":"","sources":["../src/resources/keys.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAE/C,OAAO,EAAE,YAAY,EAAE,gCAA4B;AAEnD,OAAO,EAAE,IAAI,EAAE,mCAA+B;AAE9C;;GAEG;AACH,MAAM,OAAO,IAAK,SAAQ,WAAW;IACnC;;;;;OAKG;IACH,IAAI,CAAC,OAAwB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"keys.mjs","sourceRoot":"","sources":["../src/resources/keys.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAE/C,OAAO,EAAE,YAAY,EAAE,gCAA4B;AAEnD,OAAO,EAAE,IAAI,EAAE,mCAA+B;AAE9C;;GAEG;AACH,MAAM,OAAO,IAAK,SAAQ,WAAW;IACnC;;;;;OAKG;IACH,IAAI,CAAC,OAAwB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAsB,EAAE,OAAwB;QACpD,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACzC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC;gBACpB,EAAE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;gBACnF,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAa,EAAE,OAAwB;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,YAAY,KAAK,EAAE,EAAE;YAClD,GAAG,OAAO;YACV,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/src/client.ts
CHANGED
|
@@ -14,15 +14,16 @@ import * as Opts from './internal/request-options';
|
|
|
14
14
|
import { stringifyQuery } from './internal/utils/query';
|
|
15
15
|
import { VERSION } from './version';
|
|
16
16
|
import * as Errors from './core/error';
|
|
17
|
+
import * as Pagination from './core/pagination';
|
|
18
|
+
import { AbstractPage, type CursorPageParams, CursorPageResponse } from './core/pagination';
|
|
17
19
|
import * as Uploads from './core/uploads';
|
|
18
20
|
import * as API from './resources/index';
|
|
19
21
|
import { APIPromise } from './core/api-promise';
|
|
20
22
|
import { KeyIssueParams, KeyIssueResponse, KeyListResponse, Keys } from './resources/keys';
|
|
21
23
|
import {
|
|
22
|
-
DealerCreateParams,
|
|
23
24
|
DealerDetail,
|
|
24
25
|
DealerListParams,
|
|
25
|
-
|
|
26
|
+
DealerSummariesCursorPage,
|
|
26
27
|
DealerSummary,
|
|
27
28
|
DealerUpdateParams,
|
|
28
29
|
Dealers,
|
|
@@ -551,6 +552,30 @@ export class Partnermax {
|
|
|
551
552
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
552
553
|
}
|
|
553
554
|
|
|
555
|
+
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
556
|
+
path: string,
|
|
557
|
+
Page: new (...args: any[]) => PageClass,
|
|
558
|
+
opts?: PromiseOrValue<RequestOptions>,
|
|
559
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
560
|
+
return this.requestAPIList(
|
|
561
|
+
Page,
|
|
562
|
+
opts && 'then' in opts ?
|
|
563
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
564
|
+
: { method: 'get', path, ...opts },
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
requestAPIList<
|
|
569
|
+
Item = unknown,
|
|
570
|
+
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
571
|
+
>(
|
|
572
|
+
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
573
|
+
options: PromiseOrValue<FinalRequestOptions>,
|
|
574
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
575
|
+
const request = this.makeRequest(options, null, undefined);
|
|
576
|
+
return new Pagination.PagePromise<PageClass, Item>(this as any as Partnermax, request, Page);
|
|
577
|
+
}
|
|
578
|
+
|
|
554
579
|
async fetchWithTimeout(
|
|
555
580
|
url: RequestInfo,
|
|
556
581
|
init: RequestInit | undefined,
|
|
@@ -807,7 +832,7 @@ export class Partnermax {
|
|
|
807
832
|
static toFile = Uploads.toFile;
|
|
808
833
|
|
|
809
834
|
/**
|
|
810
|
-
* API key lifecycle management
|
|
835
|
+
* API key lifecycle management. PartnerMAX v1 allows one active API key per partner/environment; partners authenticate every request with `X-Api-Key` (preferred) or `Authorization: Bearer <key>`, and replacement is handled through DealerMAX support.
|
|
811
836
|
*/
|
|
812
837
|
keys: API.Keys = new API.Keys(this);
|
|
813
838
|
/**
|
|
@@ -822,6 +847,9 @@ Partnermax.Dealers = Dealers;
|
|
|
822
847
|
export declare namespace Partnermax {
|
|
823
848
|
export type RequestOptions = Opts.RequestOptions;
|
|
824
849
|
|
|
850
|
+
export import CursorPage = Pagination.CursorPage;
|
|
851
|
+
export { type CursorPageParams as CursorPageParams, type CursorPageResponse as CursorPageResponse };
|
|
852
|
+
|
|
825
853
|
export {
|
|
826
854
|
Keys as Keys,
|
|
827
855
|
type KeyListResponse as KeyListResponse,
|
|
@@ -833,8 +861,7 @@ export declare namespace Partnermax {
|
|
|
833
861
|
Dealers as Dealers,
|
|
834
862
|
type DealerDetail as DealerDetail,
|
|
835
863
|
type DealerSummary as DealerSummary,
|
|
836
|
-
type
|
|
837
|
-
type DealerCreateParams as DealerCreateParams,
|
|
864
|
+
type DealerSummariesCursorPage as DealerSummariesCursorPage,
|
|
838
865
|
type DealerUpdateParams as DealerUpdateParams,
|
|
839
866
|
type DealerListParams as DealerListParams,
|
|
840
867
|
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { PartnermaxError } from './error';
|
|
4
|
+
import { FinalRequestOptions } from '../internal/request-options';
|
|
5
|
+
import { defaultParseResponse } from '../internal/parse';
|
|
6
|
+
import { type Partnermax } from '../client';
|
|
7
|
+
import { APIPromise } from './api-promise';
|
|
8
|
+
import { type APIResponseProps } from '../internal/parse';
|
|
9
|
+
import { maybeObj } from '../internal/utils/values';
|
|
10
|
+
|
|
11
|
+
export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
|
|
12
|
+
|
|
13
|
+
export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
14
|
+
#client: Partnermax;
|
|
15
|
+
protected options: FinalRequestOptions;
|
|
16
|
+
|
|
17
|
+
protected response: Response;
|
|
18
|
+
protected body: unknown;
|
|
19
|
+
|
|
20
|
+
constructor(client: Partnermax, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
21
|
+
this.#client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.response = response;
|
|
24
|
+
this.body = body;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
abstract nextPageRequestOptions(): PageRequestOptions | null;
|
|
28
|
+
|
|
29
|
+
abstract getPaginatedItems(): Item[];
|
|
30
|
+
|
|
31
|
+
hasNextPage(): boolean {
|
|
32
|
+
const items = this.getPaginatedItems();
|
|
33
|
+
if (!items.length) return false;
|
|
34
|
+
return this.nextPageRequestOptions() != null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getNextPage(): Promise<this> {
|
|
38
|
+
const nextOptions = this.nextPageRequestOptions();
|
|
39
|
+
if (!nextOptions) {
|
|
40
|
+
throw new PartnermaxError(
|
|
41
|
+
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async *iterPages(): AsyncGenerator<this> {
|
|
49
|
+
let page: this = this;
|
|
50
|
+
yield page;
|
|
51
|
+
while (page.hasNextPage()) {
|
|
52
|
+
page = await page.getNextPage();
|
|
53
|
+
yield page;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
58
|
+
for await (const page of this.iterPages()) {
|
|
59
|
+
for (const item of page.getPaginatedItems()) {
|
|
60
|
+
yield item;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
68
|
+
*
|
|
69
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
70
|
+
*
|
|
71
|
+
* for await (const item of client.items.list()) {
|
|
72
|
+
* console.log(item)
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
export class PagePromise<
|
|
76
|
+
PageClass extends AbstractPage<Item>,
|
|
77
|
+
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
78
|
+
>
|
|
79
|
+
extends APIPromise<PageClass>
|
|
80
|
+
implements AsyncIterable<Item>
|
|
81
|
+
{
|
|
82
|
+
constructor(
|
|
83
|
+
client: Partnermax,
|
|
84
|
+
request: Promise<APIResponseProps>,
|
|
85
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
86
|
+
) {
|
|
87
|
+
super(
|
|
88
|
+
client,
|
|
89
|
+
request,
|
|
90
|
+
async (client, props) =>
|
|
91
|
+
new Page(client, props.response, await defaultParseResponse(client, props), props.options),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
97
|
+
*
|
|
98
|
+
* for await (const item of client.items.list()) {
|
|
99
|
+
* console.log(item)
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
103
|
+
const page = await this;
|
|
104
|
+
for await (const item of page) {
|
|
105
|
+
yield item;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface CursorPageResponse<Item> {
|
|
111
|
+
data: Array<Item>;
|
|
112
|
+
|
|
113
|
+
has_more: boolean;
|
|
114
|
+
|
|
115
|
+
next_cursor: string | null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface CursorPageParams {
|
|
119
|
+
cursor?: string | null;
|
|
120
|
+
|
|
121
|
+
limit?: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export class CursorPage<Item> extends AbstractPage<Item> implements CursorPageResponse<Item> {
|
|
125
|
+
data: Array<Item>;
|
|
126
|
+
|
|
127
|
+
has_more: boolean;
|
|
128
|
+
|
|
129
|
+
next_cursor: string | null;
|
|
130
|
+
|
|
131
|
+
constructor(
|
|
132
|
+
client: Partnermax,
|
|
133
|
+
response: Response,
|
|
134
|
+
body: CursorPageResponse<Item>,
|
|
135
|
+
options: FinalRequestOptions,
|
|
136
|
+
) {
|
|
137
|
+
super(client, response, body, options);
|
|
138
|
+
|
|
139
|
+
this.data = body.data || [];
|
|
140
|
+
this.has_more = body.has_more || false;
|
|
141
|
+
this.next_cursor = body.next_cursor || null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getPaginatedItems(): Item[] {
|
|
145
|
+
return this.data ?? [];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
override hasNextPage(): boolean {
|
|
149
|
+
if (this.has_more === false) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return super.hasNextPage();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
nextPageRequestOptions(): PageRequestOptions | null {
|
|
157
|
+
const cursor = this.next_cursor;
|
|
158
|
+
if (!cursor) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
...this.options,
|
|
164
|
+
query: {
|
|
165
|
+
...maybeObj(this.options.query),
|
|
166
|
+
cursor,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { Partnermax as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { Partnermax, type ClientOptions } from './client';
|
|
8
|
+
export { PagePromise } from './core/pagination';
|
|
8
9
|
export {
|
|
9
10
|
PartnermaxError,
|
|
10
11
|
APIError,
|
|
@@ -17,11 +17,13 @@ import {
|
|
|
17
17
|
VehicleList,
|
|
18
18
|
VehicleListParams,
|
|
19
19
|
VehicleRetrieveParams,
|
|
20
|
+
VehicleSummariesCursorPage,
|
|
20
21
|
VehicleSummary,
|
|
21
22
|
VehicleUpdateParams,
|
|
22
23
|
Vehicles,
|
|
23
24
|
} from './vehicles/vehicles';
|
|
24
25
|
import { APIPromise } from '../../core/api-promise';
|
|
26
|
+
import { CursorPage, type CursorPageParams, PagePromise } from '../../core/pagination';
|
|
25
27
|
import { buildHeaders } from '../../internal/headers';
|
|
26
28
|
import { RequestOptions } from '../../internal/request-options';
|
|
27
29
|
import { path } from '../../internal/utils/path';
|
|
@@ -34,21 +36,6 @@ export class Dealers extends APIResource {
|
|
|
34
36
|
nlt: NltAPI.Nlt = new NltAPI.Nlt(this._client);
|
|
35
37
|
vehicles: VehiclesAPI.Vehicles = new VehiclesAPI.Vehicles(this._client);
|
|
36
38
|
|
|
37
|
-
/**
|
|
38
|
-
* Provision a new dealer as child of the calling partner.
|
|
39
|
-
*/
|
|
40
|
-
create(params: DealerCreateParams, options?: RequestOptions): APIPromise<DealerDetail> {
|
|
41
|
-
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
42
|
-
return this._client.post('/v1/dealers', {
|
|
43
|
-
body,
|
|
44
|
-
...options,
|
|
45
|
-
headers: buildHeaders([
|
|
46
|
-
{ ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined) },
|
|
47
|
-
options?.headers,
|
|
48
|
-
]),
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
39
|
/**
|
|
53
40
|
* Fetch a dealer's full detail. ACL-protected.
|
|
54
41
|
*/
|
|
@@ -77,8 +64,8 @@ export class Dealers extends APIResource {
|
|
|
77
64
|
list(
|
|
78
65
|
query: DealerListParams | null | undefined = {},
|
|
79
66
|
options?: RequestOptions,
|
|
80
|
-
):
|
|
81
|
-
return this._client.
|
|
67
|
+
): PagePromise<DealerSummariesCursorPage, DealerSummary> {
|
|
68
|
+
return this._client.getAPIList('/v1/dealers', CursorPage<DealerSummary>, { query, ...options });
|
|
82
69
|
}
|
|
83
70
|
|
|
84
71
|
/**
|
|
@@ -92,6 +79,8 @@ export class Dealers extends APIResource {
|
|
|
92
79
|
}
|
|
93
80
|
}
|
|
94
81
|
|
|
82
|
+
export type DealerSummariesCursorPage = CursorPage<DealerSummary>;
|
|
83
|
+
|
|
95
84
|
/**
|
|
96
85
|
* Full dealer payload used by single-resource and write endpoints.
|
|
97
86
|
*/
|
|
@@ -176,79 +165,6 @@ export interface DealerSummary {
|
|
|
176
165
|
last_active_at?: string | null;
|
|
177
166
|
}
|
|
178
167
|
|
|
179
|
-
/**
|
|
180
|
-
* Response envelope for `GET /v1/dealers`.
|
|
181
|
-
*/
|
|
182
|
-
export interface DealerListResponse {
|
|
183
|
-
data: Array<DealerSummary>;
|
|
184
|
-
|
|
185
|
-
has_more: boolean;
|
|
186
|
-
|
|
187
|
-
next_cursor?: string | null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface DealerCreateParams {
|
|
191
|
-
/**
|
|
192
|
-
* Body param
|
|
193
|
-
*/
|
|
194
|
-
address: string;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Body param
|
|
198
|
-
*/
|
|
199
|
-
business_name: string;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Body param
|
|
203
|
-
*/
|
|
204
|
-
city: string;
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Body param
|
|
208
|
-
*/
|
|
209
|
-
contact_email: string;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Body param
|
|
213
|
-
*/
|
|
214
|
-
contact_phone: string;
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Body param
|
|
218
|
-
*/
|
|
219
|
-
postal_code: string;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Body param
|
|
223
|
-
*/
|
|
224
|
-
primary_domain: string;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Body param
|
|
228
|
-
*/
|
|
229
|
-
province_code: string;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Body param
|
|
233
|
-
*/
|
|
234
|
-
vat_number: string;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Body param
|
|
238
|
-
*/
|
|
239
|
-
activate?: boolean;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Body param
|
|
243
|
-
*/
|
|
244
|
-
metadata?: { [key: string]: string };
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Header param
|
|
248
|
-
*/
|
|
249
|
-
'Idempotency-Key'?: string;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
168
|
export interface DealerUpdateParams {
|
|
253
169
|
/**
|
|
254
170
|
* Body param
|
|
@@ -301,11 +217,7 @@ export interface DealerUpdateParams {
|
|
|
301
217
|
'Idempotency-Key'?: string;
|
|
302
218
|
}
|
|
303
219
|
|
|
304
|
-
export interface DealerListParams {
|
|
305
|
-
cursor?: string | null;
|
|
306
|
-
|
|
307
|
-
limit?: number;
|
|
308
|
-
|
|
220
|
+
export interface DealerListParams extends CursorPageParams {
|
|
309
221
|
status?: 'active' | 'inactive' | 'all';
|
|
310
222
|
}
|
|
311
223
|
|
|
@@ -316,8 +228,7 @@ export declare namespace Dealers {
|
|
|
316
228
|
export {
|
|
317
229
|
type DealerDetail as DealerDetail,
|
|
318
230
|
type DealerSummary as DealerSummary,
|
|
319
|
-
type
|
|
320
|
-
type DealerCreateParams as DealerCreateParams,
|
|
231
|
+
type DealerSummariesCursorPage as DealerSummariesCursorPage,
|
|
321
232
|
type DealerUpdateParams as DealerUpdateParams,
|
|
322
233
|
type DealerListParams as DealerListParams,
|
|
323
234
|
};
|
|
@@ -338,6 +249,7 @@ export declare namespace Dealers {
|
|
|
338
249
|
type VehicleDetail as VehicleDetail,
|
|
339
250
|
type VehicleList as VehicleList,
|
|
340
251
|
type VehicleSummary as VehicleSummary,
|
|
252
|
+
type VehicleSummariesCursorPage as VehicleSummariesCursorPage,
|
|
341
253
|
type VehicleCreateParams as VehicleCreateParams,
|
|
342
254
|
type VehicleRetrieveParams as VehicleRetrieveParams,
|
|
343
255
|
type VehicleUpdateParams as VehicleUpdateParams,
|
|
@@ -4,10 +4,9 @@ export {
|
|
|
4
4
|
Dealers,
|
|
5
5
|
type DealerDetail,
|
|
6
6
|
type DealerSummary,
|
|
7
|
-
type DealerListResponse,
|
|
8
|
-
type DealerCreateParams,
|
|
9
7
|
type DealerUpdateParams,
|
|
10
8
|
type DealerListParams,
|
|
9
|
+
type DealerSummariesCursorPage,
|
|
11
10
|
} from './dealers';
|
|
12
11
|
export { Nlt } from './nlt/index';
|
|
13
12
|
export { NltSettings, type DownPaymentTiers, type NltSettingUpdateParams } from './nlt-settings';
|
|
@@ -25,4 +24,5 @@ export {
|
|
|
25
24
|
type VehicleListParams,
|
|
26
25
|
type VehicleDeleteParams,
|
|
27
26
|
type VehicleBulkParams,
|
|
27
|
+
type VehicleSummariesCursorPage,
|
|
28
28
|
} from './vehicles/index';
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { APIResource } from '../../../core/resource';
|
|
4
4
|
import * as OffersAPI from './offers';
|
|
5
5
|
import {
|
|
6
|
+
NltOfferSummariesCursorPage,
|
|
6
7
|
NltOfferSummary,
|
|
7
8
|
OfferListParams,
|
|
8
|
-
OfferListResponse,
|
|
9
9
|
OfferRetrieveParams,
|
|
10
10
|
OfferRetrieveResponse,
|
|
11
11
|
Offers,
|
|
@@ -22,7 +22,7 @@ export declare namespace Nlt {
|
|
|
22
22
|
Offers as Offers,
|
|
23
23
|
type NltOfferSummary as NltOfferSummary,
|
|
24
24
|
type OfferRetrieveResponse as OfferRetrieveResponse,
|
|
25
|
-
type
|
|
25
|
+
type NltOfferSummariesCursorPage as NltOfferSummariesCursorPage,
|
|
26
26
|
type OfferRetrieveParams as OfferRetrieveParams,
|
|
27
27
|
type OfferListParams as OfferListParams,
|
|
28
28
|
};
|