deere-sdk 0.1.0
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 +38 -0
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/api/assets.d.ts +78 -0
- package/dist/api/assets.d.ts.map +1 -0
- package/dist/api/assets.js +115 -0
- package/dist/api/assets.js.map +1 -0
- package/dist/api/boundaries.d.ts +69 -0
- package/dist/api/boundaries.d.ts.map +1 -0
- package/dist/api/boundaries.js +102 -0
- package/dist/api/boundaries.js.map +1 -0
- package/dist/api/clients.d.ts +71 -0
- package/dist/api/clients.d.ts.map +1 -0
- package/dist/api/clients.js +104 -0
- package/dist/api/clients.js.map +1 -0
- package/dist/api/connection-management.d.ts +41 -0
- package/dist/api/connection-management.d.ts.map +1 -0
- package/dist/api/connection-management.js +56 -0
- package/dist/api/connection-management.js.map +1 -0
- package/dist/api/crop-types.d.ts +48 -0
- package/dist/api/crop-types.d.ts.map +1 -0
- package/dist/api/crop-types.js +69 -0
- package/dist/api/crop-types.js.map +1 -0
- package/dist/api/equipment.d.ts +138 -0
- package/dist/api/equipment.d.ts.map +1 -0
- package/dist/api/equipment.js +214 -0
- package/dist/api/equipment.js.map +1 -0
- package/dist/api/farms.d.ts +69 -0
- package/dist/api/farms.d.ts.map +1 -0
- package/dist/api/farms.js +100 -0
- package/dist/api/farms.js.map +1 -0
- package/dist/api/field-operations-api.d.ts +56 -0
- package/dist/api/field-operations-api.d.ts.map +1 -0
- package/dist/api/field-operations-api.js +88 -0
- package/dist/api/field-operations-api.js.map +1 -0
- package/dist/api/field-operations.d.ts +83 -0
- package/dist/api/field-operations.d.ts.map +1 -0
- package/dist/api/field-operations.js +134 -0
- package/dist/api/field-operations.js.map +1 -0
- package/dist/api/fields.d.ts +73 -0
- package/dist/api/fields.d.ts.map +1 -0
- package/dist/api/fields.js +113 -0
- package/dist/api/fields.js.map +1 -0
- package/dist/api/files.d.ts +63 -0
- package/dist/api/files.d.ts.map +1 -0
- package/dist/api/files.js +96 -0
- package/dist/api/files.js.map +1 -0
- package/dist/api/flags.d.ts +96 -0
- package/dist/api/flags.d.ts.map +1 -0
- package/dist/api/flags.js +159 -0
- package/dist/api/flags.js.map +1 -0
- package/dist/api/guidance-lines.d.ts +52 -0
- package/dist/api/guidance-lines.d.ts.map +1 -0
- package/dist/api/guidance-lines.js +77 -0
- package/dist/api/guidance-lines.js.map +1 -0
- package/dist/api/index.d.ts +43 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +25 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/map-layers.d.ts +49 -0
- package/dist/api/map-layers.d.ts.map +1 -0
- package/dist/api/map-layers.js +69 -0
- package/dist/api/map-layers.js.map +1 -0
- package/dist/api/operators.d.ts +67 -0
- package/dist/api/operators.d.ts.map +1 -0
- package/dist/api/operators.js +99 -0
- package/dist/api/operators.js.map +1 -0
- package/dist/api/organizations.d.ts +45 -0
- package/dist/api/organizations.d.ts.map +1 -0
- package/dist/api/organizations.js +64 -0
- package/dist/api/organizations.js.map +1 -0
- package/dist/api/products.d.ts +88 -0
- package/dist/api/products.d.ts.map +1 -0
- package/dist/api/products.js +132 -0
- package/dist/api/products.js.map +1 -0
- package/dist/api/users.d.ts +22 -0
- package/dist/api/users.d.ts.map +1 -0
- package/dist/api/users.js +26 -0
- package/dist/api/users.js.map +1 -0
- package/dist/api/webhook.d.ts +42 -0
- package/dist/api/webhook.d.ts.map +1 -0
- package/dist/api/webhook.js +57 -0
- package/dist/api/webhook.js.map +1 -0
- package/dist/client.d.ts +114 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +224 -0
- package/dist/client.js.map +1 -0
- package/dist/deere.d.ts +98 -0
- package/dist/deere.d.ts.map +1 -0
- package/dist/deere.js +120 -0
- package/dist/deere.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/types/generated/assets.d.ts +839 -0
- package/dist/types/generated/assets.d.ts.map +1 -0
- package/dist/types/generated/assets.js +6 -0
- package/dist/types/generated/assets.js.map +1 -0
- package/dist/types/generated/boundaries.d.ts +734 -0
- package/dist/types/generated/boundaries.d.ts.map +1 -0
- package/dist/types/generated/boundaries.js +6 -0
- package/dist/types/generated/boundaries.js.map +1 -0
- package/dist/types/generated/clients.d.ts +602 -0
- package/dist/types/generated/clients.d.ts.map +1 -0
- package/dist/types/generated/clients.js +6 -0
- package/dist/types/generated/clients.js.map +1 -0
- package/dist/types/generated/connection-management.d.ts +210 -0
- package/dist/types/generated/connection-management.d.ts.map +1 -0
- package/dist/types/generated/connection-management.js +6 -0
- package/dist/types/generated/connection-management.js.map +1 -0
- package/dist/types/generated/crop-types.d.ts +541 -0
- package/dist/types/generated/crop-types.d.ts.map +1 -0
- package/dist/types/generated/crop-types.js +6 -0
- package/dist/types/generated/crop-types.js.map +1 -0
- package/dist/types/generated/equipment.d.ts +2599 -0
- package/dist/types/generated/equipment.d.ts.map +1 -0
- package/dist/types/generated/equipment.js +6 -0
- package/dist/types/generated/equipment.js.map +1 -0
- package/dist/types/generated/farms.d.ts +520 -0
- package/dist/types/generated/farms.d.ts.map +1 -0
- package/dist/types/generated/farms.js +6 -0
- package/dist/types/generated/farms.js.map +1 -0
- package/dist/types/generated/field-operations-api.d.ts +1724 -0
- package/dist/types/generated/field-operations-api.d.ts.map +1 -0
- package/dist/types/generated/field-operations-api.js +6 -0
- package/dist/types/generated/field-operations-api.js.map +1 -0
- package/dist/types/generated/fields.d.ts +904 -0
- package/dist/types/generated/fields.d.ts.map +1 -0
- package/dist/types/generated/fields.js +6 -0
- package/dist/types/generated/fields.js.map +1 -0
- package/dist/types/generated/files.d.ts +598 -0
- package/dist/types/generated/files.d.ts.map +1 -0
- package/dist/types/generated/files.js +6 -0
- package/dist/types/generated/files.js.map +1 -0
- package/dist/types/generated/flags.d.ts +593 -0
- package/dist/types/generated/flags.d.ts.map +1 -0
- package/dist/types/generated/flags.js +6 -0
- package/dist/types/generated/flags.js.map +1 -0
- package/dist/types/generated/guidance-lines.d.ts +405 -0
- package/dist/types/generated/guidance-lines.d.ts.map +1 -0
- package/dist/types/generated/guidance-lines.js +6 -0
- package/dist/types/generated/guidance-lines.js.map +1 -0
- package/dist/types/generated/index.d.ts +44 -0
- package/dist/types/generated/index.d.ts.map +1 -0
- package/dist/types/generated/index.js +26 -0
- package/dist/types/generated/index.js.map +1 -0
- package/dist/types/generated/map-layers.d.ts +696 -0
- package/dist/types/generated/map-layers.d.ts.map +1 -0
- package/dist/types/generated/map-layers.js +6 -0
- package/dist/types/generated/map-layers.js.map +1 -0
- package/dist/types/generated/operators.d.ts +361 -0
- package/dist/types/generated/operators.d.ts.map +1 -0
- package/dist/types/generated/operators.js +6 -0
- package/dist/types/generated/operators.js.map +1 -0
- package/dist/types/generated/organizations.d.ts +308 -0
- package/dist/types/generated/organizations.d.ts.map +1 -0
- package/dist/types/generated/organizations.js +6 -0
- package/dist/types/generated/organizations.js.map +1 -0
- package/dist/types/generated/products.d.ts +1165 -0
- package/dist/types/generated/products.d.ts.map +1 -0
- package/dist/types/generated/products.js +6 -0
- package/dist/types/generated/products.js.map +1 -0
- package/dist/types/generated/users.d.ts +96 -0
- package/dist/types/generated/users.d.ts.map +1 -0
- package/dist/types/generated/users.js +6 -0
- package/dist/types/generated/users.js.map +1 -0
- package/dist/types/generated/webhook.d.ts +475 -0
- package/dist/types/generated/webhook.d.ts.map +1 -0
- package/dist/types/generated/webhook.js +6 -0
- package/dist/types/generated/webhook.js.map +1 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProductsApi
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated SDK wrapper for John Deere products API.
|
|
5
|
+
* @generated from products.yaml
|
|
6
|
+
*/
|
|
7
|
+
export class ProductsApi {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* View varieties for an org
|
|
14
|
+
* @description This endpoint will retrieve a collection of varieties for the specified org.
|
|
15
|
+
* @generated from GET /organizations/{organizationId}/varieties
|
|
16
|
+
*/
|
|
17
|
+
async list(organizationId, params, options) {
|
|
18
|
+
const query = new URLSearchParams();
|
|
19
|
+
if (params?.status !== undefined)
|
|
20
|
+
query.set('status', String(params.status));
|
|
21
|
+
if (params?.embed !== undefined)
|
|
22
|
+
query.set('embed', String(params.embed));
|
|
23
|
+
const queryString = query.toString();
|
|
24
|
+
const path = `/organizations/${organizationId}/varieties${queryString ? `?${queryString}` : ''}`;
|
|
25
|
+
return this.client.get(path, options);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get all items (follows pagination automatically)
|
|
29
|
+
* @generated from GET /organizations/{organizationId}/varieties
|
|
30
|
+
*/
|
|
31
|
+
async listAll(organizationId, params, options) {
|
|
32
|
+
const query = new URLSearchParams();
|
|
33
|
+
if (params?.status !== undefined)
|
|
34
|
+
query.set('status', String(params.status));
|
|
35
|
+
if (params?.embed !== undefined)
|
|
36
|
+
query.set('embed', String(params.embed));
|
|
37
|
+
const queryString = query.toString();
|
|
38
|
+
const path = `/organizations/${organizationId}/varieties${queryString ? `?${queryString}` : ''}`;
|
|
39
|
+
return this.client.getAll(path, options);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Add a variety
|
|
43
|
+
* @description This endpoint will add a custom variety into the organization. Its name+cropName must be unique within your organization. Its crop name must be a supported crop name (see /cropTypes). There are a number of crop names that are deprecated in the system. If the crop name is set to one of these, then it will be mapped to its corresponding valid crop name. </br> </br> Additionally, POST can be used for supporting offline creation of varieties from e.g. a mobile app, by sending a payload with an `id` generated by the client. If an `id` is present in the payload, the service checks the database for that `id`.</br> </br> In case no record is found, a new one is created with that `id` and the request is responded with 201.</br> Otherwise no creation happens and the request is responded with 409 and error message that a resource with that `id` already exists.
|
|
44
|
+
* @generated from POST /organizations/{organizationId}/varieties
|
|
45
|
+
*/
|
|
46
|
+
async create(organizationId, data, options) {
|
|
47
|
+
const path = `/organizations/${organizationId}/varieties`;
|
|
48
|
+
await this.client.post(path, data, options);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* View a specific variety
|
|
52
|
+
* @description This endpoint will return the variety with the specified erid.
|
|
53
|
+
* @generated from GET /organizations/{organizationId}/varieties/{erid}
|
|
54
|
+
*/
|
|
55
|
+
async get(organizationId, erid, params, options) {
|
|
56
|
+
const query = new URLSearchParams();
|
|
57
|
+
if (params?.embed !== undefined)
|
|
58
|
+
query.set('embed', String(params.embed));
|
|
59
|
+
const queryString = query.toString();
|
|
60
|
+
const path = `/organizations/${organizationId}/varieties/${erid}${queryString ? `?${queryString}` : ''}`;
|
|
61
|
+
return this.client.get(path, options);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Update a single variety
|
|
65
|
+
* @description This endpoint allows the custom variety to be renamed, made active/archived, or associated to a different manufacturer or crop type.
|
|
66
|
+
* @generated from PUT /organizations/{organizationId}/varieties/{erid}
|
|
67
|
+
*/
|
|
68
|
+
async update(organizationId, erid, data, options) {
|
|
69
|
+
const path = `/organizations/${organizationId}/varieties/${erid}`;
|
|
70
|
+
await this.client.put(path, data, options);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Adds a single reference variety to organization
|
|
74
|
+
* @description This endpoint will associate a reference variety to your organization from the global reference list.
|
|
75
|
+
* @generated from POST /varieties/{erid}/associateToOrg/{organizationId}
|
|
76
|
+
*/
|
|
77
|
+
async createAssociatetoorg(erid, organizationId, data, options) {
|
|
78
|
+
const path = `/varieties/${erid}/associateToOrg/${organizationId}`;
|
|
79
|
+
await this.client.post(path, data, options);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Search reference catalog varieties
|
|
83
|
+
* @description This endpoint searches the reference catalog for varieties that match the given search criteria. This data can be used in a subsequent request to create a variety in an organization. Results are limited to 100 items.
|
|
84
|
+
* @generated from GET /varieties
|
|
85
|
+
*/
|
|
86
|
+
async listVarieties(params, options) {
|
|
87
|
+
const query = new URLSearchParams();
|
|
88
|
+
if (params?.searchString !== undefined)
|
|
89
|
+
query.set('searchString', String(params.searchString));
|
|
90
|
+
if (params?.cropName !== undefined)
|
|
91
|
+
query.set('cropName', String(params.cropName));
|
|
92
|
+
if (params?.productName !== undefined)
|
|
93
|
+
query.set('productName', String(params.productName));
|
|
94
|
+
if (params?.brandName !== undefined)
|
|
95
|
+
query.set('brandName', String(params.brandName));
|
|
96
|
+
if (params?.sourceSystemProductId !== undefined)
|
|
97
|
+
query.set('sourceSystemProductId', String(params.sourceSystemProductId));
|
|
98
|
+
if (params?.countryCode !== undefined)
|
|
99
|
+
query.set('countryCode', String(params.countryCode));
|
|
100
|
+
const queryString = query.toString();
|
|
101
|
+
const path = `/varieties${queryString ? `?${queryString}` : ''}`;
|
|
102
|
+
return this.client.get(path, options);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get a single reference variety.
|
|
106
|
+
* @description Single variety from industry data sources, such as CDMS.
|
|
107
|
+
* @generated from GET /varieties/{erid}
|
|
108
|
+
*/
|
|
109
|
+
async getVarieties(erid, options) {
|
|
110
|
+
const path = `/varieties/${erid}`;
|
|
111
|
+
return this.client.get(path, options);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Reference list of documents for an associated seed variety.
|
|
115
|
+
* @description List of all the documents for a variety from industry data sources, such as CDMS.
|
|
116
|
+
* @generated from GET /varieties/{erid}/documents
|
|
117
|
+
*/
|
|
118
|
+
async listDocuments(erid, options) {
|
|
119
|
+
const path = `/varieties/${erid}/documents`;
|
|
120
|
+
return this.client.get(path, options);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sets organizational attributes such as isCarrier, archived, registration, etc.
|
|
124
|
+
* @description This endpoint will set attribute overrides while importing a reference variety to your organization. The reference varieties are immutable, however, they can still be archived or made available. The response headers from the GET endpoints will include the attributes that can be overridden.
|
|
125
|
+
* @generated from PATCH /varieties/{erid}/setOverridesForOrg/{organizationId}
|
|
126
|
+
*/
|
|
127
|
+
async patch(erid, organizationId, data, options) {
|
|
128
|
+
const path = `/varieties/${erid}/setOverridesForOrg/${organizationId}`;
|
|
129
|
+
await this.client.patch(path, data, options);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.js","sourceRoot":"","sources":["../../src/api/products.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,cAAsB,EAAE,MAAkG,EAAE,OAAwB;QAC7J,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7E,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,kBAAkB,cAAc,aAAa,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACjG,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAgE,IAAI,EAAE,OA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,uBAAuB,cAAc,EAAE,CAAC;QACvE,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UsersApi
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated SDK wrapper for John Deere users API.
|
|
5
|
+
* @generated from users.yaml
|
|
6
|
+
*/
|
|
7
|
+
import type { DeereClient, RequestOptions } from '../client.js';
|
|
8
|
+
import type { components } from '../types/generated/users.js';
|
|
9
|
+
export declare class UsersApi {
|
|
10
|
+
private readonly client;
|
|
11
|
+
constructor(client: DeereClient);
|
|
12
|
+
/**
|
|
13
|
+
* View User Info
|
|
14
|
+
* @description This endpoint returns information about the user, such as first and last name, the account name, etc. This call can be used by a logged-in user to view their own information.<br/> The response also contains links to the following resources: <ul><li><b>organizations:</b> View a list of organizations to which the user belongs.</li> <li><b>files:</b> View a list of files belonging to the user.</li></ul>
|
|
15
|
+
* @generated from GET /users/{username}
|
|
16
|
+
*/
|
|
17
|
+
get(username: string, params?: {
|
|
18
|
+
embed?: string;
|
|
19
|
+
}, options?: RequestOptions): Promise<components['schemas']['UsersValue']>;
|
|
20
|
+
}
|
|
21
|
+
export type { components as UsersTypes } from '../types/generated/users.js';
|
|
22
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/api/users.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;OAIG;IACG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC;CAOjI;AAGD,YAAY,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UsersApi
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated SDK wrapper for John Deere users API.
|
|
5
|
+
* @generated from users.yaml
|
|
6
|
+
*/
|
|
7
|
+
export class UsersApi {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* View User Info
|
|
14
|
+
* @description This endpoint returns information about the user, such as first and last name, the account name, etc. This call can be used by a logged-in user to view their own information.<br/> The response also contains links to the following resources: <ul><li><b>organizations:</b> View a list of organizations to which the user belongs.</li> <li><b>files:</b> View a list of files belonging to the user.</li></ul>
|
|
15
|
+
* @generated from GET /users/{username}
|
|
16
|
+
*/
|
|
17
|
+
async get(username, params, options) {
|
|
18
|
+
const query = new URLSearchParams();
|
|
19
|
+
if (params?.embed !== undefined)
|
|
20
|
+
query.set('embed', String(params.embed));
|
|
21
|
+
const queryString = query.toString();
|
|
22
|
+
const path = `/users/${username}${queryString ? `?${queryString}` : ''}`;
|
|
23
|
+
return this.client.get(path, options);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/api/users.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,OAAO,QAAQ;IACU;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,MAA2B,EAAE,OAAwB;QAC/E,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,UAAU,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAsC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebhookApi
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated SDK wrapper for John Deere webhook API.
|
|
5
|
+
* @generated from webhook.yaml
|
|
6
|
+
*/
|
|
7
|
+
import type { DeereClient, RequestOptions } from '../client.js';
|
|
8
|
+
export declare class WebhookApi {
|
|
9
|
+
private readonly client;
|
|
10
|
+
constructor(client: DeereClient);
|
|
11
|
+
/**
|
|
12
|
+
* Get Event Subscriptions
|
|
13
|
+
* @description This resource will return a paged list of event subscriptions for the user. The endpoint will return all Active, Expired, and Terminated subscriptions.
|
|
14
|
+
* @generated from GET /eventSubscriptions
|
|
15
|
+
*/
|
|
16
|
+
list(options?: RequestOptions): Promise<unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Get all items (follows pagination automatically)
|
|
19
|
+
* @generated from GET /eventSubscriptions
|
|
20
|
+
*/
|
|
21
|
+
listAll(options?: RequestOptions): Promise<unknown[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Create an Event Subscription
|
|
24
|
+
* @description This resource will create an event subscription for a user. It returns a list of event subscriptions. To create a subscription for an event, your client must have access to the event's associated api. The response will include links to:- <ul> <li><b>user:</b> The subscribed user provided by the current authorization context.</li> <li><b>self:</b> The created subscription.</li> </ul>
|
|
25
|
+
* @generated from POST /eventSubscriptions
|
|
26
|
+
*/
|
|
27
|
+
create(data: Record<string, unknown>, options?: RequestOptions): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Get an Event Subscription
|
|
30
|
+
* @description This resource will get a single event subscription by id. The response will include links to: <ul> <li><b>user:</b> The subscribed user provided by the current authorization context.</li> <li><b>self:</b> The subscription itself.</li> </ul>
|
|
31
|
+
* @generated from GET /eventSubscriptions/{id}
|
|
32
|
+
*/
|
|
33
|
+
get(id: string, options?: RequestOptions): Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Update an Event Subscription
|
|
36
|
+
* @description This resource will update an event subscription for a user. Only certain fields are editable.
|
|
37
|
+
* @generated from PUT /eventSubscriptions/{id}
|
|
38
|
+
*/
|
|
39
|
+
update(id: string, data: Record<string, unknown>, options?: RequestOptions): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export type { components as WebhookTypes } from '../types/generated/webhook.js';
|
|
42
|
+
//# sourceMappingURL=webhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/api/webhook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAqB,MAAM,cAAc,CAAC;AAGnF,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;OAIG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAItD;;;OAGG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAK3D;;;;OAIG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpF;;;;OAIG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjE;;;;OAIG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAIjG;AAGD,YAAY,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebhookApi
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated SDK wrapper for John Deere webhook API.
|
|
5
|
+
* @generated from webhook.yaml
|
|
6
|
+
*/
|
|
7
|
+
export class WebhookApi {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get Event Subscriptions
|
|
14
|
+
* @description This resource will return a paged list of event subscriptions for the user. The endpoint will return all Active, Expired, and Terminated subscriptions.
|
|
15
|
+
* @generated from GET /eventSubscriptions
|
|
16
|
+
*/
|
|
17
|
+
async list(options) {
|
|
18
|
+
const path = `/eventSubscriptions`;
|
|
19
|
+
return this.client.get(path, options);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get all items (follows pagination automatically)
|
|
23
|
+
* @generated from GET /eventSubscriptions
|
|
24
|
+
*/
|
|
25
|
+
async listAll(options) {
|
|
26
|
+
const path = `/eventSubscriptions`;
|
|
27
|
+
return this.client.getAll(path, options);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create an Event Subscription
|
|
31
|
+
* @description This resource will create an event subscription for a user. It returns a list of event subscriptions. To create a subscription for an event, your client must have access to the event's associated api. The response will include links to:- <ul> <li><b>user:</b> The subscribed user provided by the current authorization context.</li> <li><b>self:</b> The created subscription.</li> </ul>
|
|
32
|
+
* @generated from POST /eventSubscriptions
|
|
33
|
+
*/
|
|
34
|
+
async create(data, options) {
|
|
35
|
+
const path = `/eventSubscriptions`;
|
|
36
|
+
await this.client.post(path, data, options);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get an Event Subscription
|
|
40
|
+
* @description This resource will get a single event subscription by id. The response will include links to: <ul> <li><b>user:</b> The subscribed user provided by the current authorization context.</li> <li><b>self:</b> The subscription itself.</li> </ul>
|
|
41
|
+
* @generated from GET /eventSubscriptions/{id}
|
|
42
|
+
*/
|
|
43
|
+
async get(id, options) {
|
|
44
|
+
const path = `/eventSubscriptions/${id}`;
|
|
45
|
+
return this.client.get(path, options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Update an Event Subscription
|
|
49
|
+
* @description This resource will update an event subscription for a user. Only certain fields are editable.
|
|
50
|
+
* @generated from PUT /eventSubscriptions/{id}
|
|
51
|
+
*/
|
|
52
|
+
async update(id, data, options) {
|
|
53
|
+
const path = `/eventSubscriptions/${id}`;
|
|
54
|
+
await this.client.put(path, data, options);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/api/webhook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,OAAO,UAAU;IACQ;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,OAAwB;QACjC,MAAM,IAAI,GAAG,qBAAqB,CAAC;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAU,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IACD;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,OAAwB;QACpC,MAAM,IAAI,GAAG,qBAAqB,CAAC;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAU,IAAI,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,IAA6B,EAAE,OAAwB;QAClE,MAAM,IAAI,GAAG,qBAAqB,CAAC;QACnC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,OAAwB;QAC5C,MAAM,IAAI,GAAG,uBAAuB,EAAE,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAU,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,IAA6B,EAAE,OAAwB;QAC9E,MAAM,IAAI,GAAG,uBAAuB,EAAE,EAAE,CAAC;QACzC,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* John Deere API Client
|
|
3
|
+
*
|
|
4
|
+
* Unofficial TypeScript SDK for John Deere Operations Center API.
|
|
5
|
+
* Provides typed access to all John Deere agricultural APIs.
|
|
6
|
+
*/
|
|
7
|
+
export type Environment = 'production' | 'sandbox' | 'partner' | 'cert' | 'qa';
|
|
8
|
+
export interface DeereClientConfig {
|
|
9
|
+
/** OAuth access token */
|
|
10
|
+
accessToken: string;
|
|
11
|
+
/** API environment. Defaults to 'sandbox' */
|
|
12
|
+
environment?: Environment;
|
|
13
|
+
/** Custom base URL (overrides environment) */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/** Custom fetch implementation */
|
|
16
|
+
fetch?: typeof fetch;
|
|
17
|
+
/** Default headers to include in all requests */
|
|
18
|
+
defaultHeaders?: Record<string, string>;
|
|
19
|
+
/** Timeout in milliseconds. Defaults to 30000 */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface RequestOptions {
|
|
23
|
+
/** Additional headers for this request */
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
/** AbortSignal for request cancellation */
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
/** Override timeout for this request */
|
|
28
|
+
timeout?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface PaginatedResponse<T> {
|
|
31
|
+
values: T[];
|
|
32
|
+
total?: number;
|
|
33
|
+
links?: Link[];
|
|
34
|
+
}
|
|
35
|
+
export interface Link {
|
|
36
|
+
'@type'?: string;
|
|
37
|
+
rel: string;
|
|
38
|
+
uri: string;
|
|
39
|
+
}
|
|
40
|
+
export declare class DeereError extends Error {
|
|
41
|
+
readonly status: number;
|
|
42
|
+
readonly statusText: string;
|
|
43
|
+
readonly body?: unknown | undefined;
|
|
44
|
+
constructor(message: string, status: number, statusText: string, body?: unknown | undefined);
|
|
45
|
+
}
|
|
46
|
+
export declare class RateLimitError extends DeereError {
|
|
47
|
+
readonly retryAfter?: number | undefined;
|
|
48
|
+
constructor(message: string, status: number, statusText: string, retryAfter?: number | undefined, body?: unknown);
|
|
49
|
+
}
|
|
50
|
+
export declare class AuthError extends DeereError {
|
|
51
|
+
constructor(message: string, status: number, statusText: string, body?: unknown);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* John Deere API Client
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const client = new DeereClient({
|
|
59
|
+
* accessToken: 'your-token',
|
|
60
|
+
* environment: 'sandbox',
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* const orgs = await client.get('/organizations');
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare class DeereClient {
|
|
67
|
+
private readonly baseUrl;
|
|
68
|
+
private readonly accessToken;
|
|
69
|
+
private readonly fetchFn;
|
|
70
|
+
private readonly defaultHeaders;
|
|
71
|
+
private readonly timeout;
|
|
72
|
+
constructor(config: DeereClientConfig);
|
|
73
|
+
/**
|
|
74
|
+
* Make a GET request to the John Deere API
|
|
75
|
+
*/
|
|
76
|
+
get<T = unknown>(path: string, options?: RequestOptions): Promise<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Make a POST request to the John Deere API
|
|
79
|
+
*/
|
|
80
|
+
post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Make a PUT request to the John Deere API
|
|
83
|
+
*/
|
|
84
|
+
put<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
85
|
+
/**
|
|
86
|
+
* Make a DELETE request to the John Deere API
|
|
87
|
+
*/
|
|
88
|
+
delete<T = unknown>(path: string, options?: RequestOptions): Promise<T>;
|
|
89
|
+
/**
|
|
90
|
+
* Make a PATCH request to the John Deere API
|
|
91
|
+
*/
|
|
92
|
+
patch<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
93
|
+
/**
|
|
94
|
+
* Follow a HAL link from a response
|
|
95
|
+
*/
|
|
96
|
+
followLink<T = unknown>(link: Link | string, options?: RequestOptions): Promise<T>;
|
|
97
|
+
/**
|
|
98
|
+
* Paginate through all results following nextPage links
|
|
99
|
+
*/
|
|
100
|
+
paginate<T>(path: string, options?: RequestOptions): AsyncGenerator<T[], void, unknown>;
|
|
101
|
+
/**
|
|
102
|
+
* Get all items from a paginated endpoint
|
|
103
|
+
*/
|
|
104
|
+
getAll<T>(path: string, options?: RequestOptions): Promise<T[]>;
|
|
105
|
+
private request;
|
|
106
|
+
private requestUrl;
|
|
107
|
+
private handleError;
|
|
108
|
+
private extractErrorMessage;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create a John Deere API client
|
|
112
|
+
*/
|
|
113
|
+
export declare function createClient(config: DeereClientConfig): DeereClient;
|
|
114
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/E,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2CAA2C;IAC3C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,CAAC,EAAE,MAAM,CAA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;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EACnB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IAIb;;OAEG;IACG,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAI7E;;OAEG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IAIb;;OAEG;IACG,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAOxF;;OAEG;IACI,QAAQ,CAAC,CAAC,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,cAAc,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC;IAgBrC;;OAEG;IACG,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;YAQvD,OAAO;YAUP,UAAU;YAuDV,WAAW;IA4BzB,OAAO,CAAC,mBAAmB;CAkB5B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CAEnE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* John Deere API Client
|
|
3
|
+
*
|
|
4
|
+
* Unofficial TypeScript SDK for John Deere Operations Center API.
|
|
5
|
+
* Provides typed access to all John Deere agricultural APIs.
|
|
6
|
+
*/
|
|
7
|
+
export class DeereError extends Error {
|
|
8
|
+
status;
|
|
9
|
+
statusText;
|
|
10
|
+
body;
|
|
11
|
+
constructor(message, status, statusText, body) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.statusText = statusText;
|
|
15
|
+
this.body = body;
|
|
16
|
+
this.name = 'DeereError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class RateLimitError extends DeereError {
|
|
20
|
+
retryAfter;
|
|
21
|
+
constructor(message, status, statusText, retryAfter, body) {
|
|
22
|
+
super(message, status, statusText, body);
|
|
23
|
+
this.retryAfter = retryAfter;
|
|
24
|
+
this.name = 'RateLimitError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class AuthError extends DeereError {
|
|
28
|
+
constructor(message, status, statusText, body) {
|
|
29
|
+
super(message, status, statusText, body);
|
|
30
|
+
this.name = 'AuthError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const ENVIRONMENT_URLS = {
|
|
34
|
+
production: 'https://api.deere.com/platform',
|
|
35
|
+
sandbox: 'https://sandboxapi.deere.com/platform',
|
|
36
|
+
partner: 'https://partnerapi.deere.com/platform',
|
|
37
|
+
cert: 'https://apicert.deere.com/platform',
|
|
38
|
+
qa: 'https://apiqa.tal.deere.com/platform',
|
|
39
|
+
};
|
|
40
|
+
const DEERE_ACCEPT_HEADER = 'application/vnd.deere.axiom.v3+json';
|
|
41
|
+
/**
|
|
42
|
+
* John Deere API Client
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const client = new DeereClient({
|
|
47
|
+
* accessToken: 'your-token',
|
|
48
|
+
* environment: 'sandbox',
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* const orgs = await client.get('/organizations');
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export class DeereClient {
|
|
55
|
+
baseUrl;
|
|
56
|
+
accessToken;
|
|
57
|
+
fetchFn;
|
|
58
|
+
defaultHeaders;
|
|
59
|
+
timeout;
|
|
60
|
+
constructor(config) {
|
|
61
|
+
this.accessToken = config.accessToken;
|
|
62
|
+
this.baseUrl = config.baseUrl ?? ENVIRONMENT_URLS[config.environment ?? 'sandbox'];
|
|
63
|
+
this.fetchFn = config.fetch ?? fetch;
|
|
64
|
+
this.timeout = config.timeout ?? 30000;
|
|
65
|
+
this.defaultHeaders = {
|
|
66
|
+
Accept: DEERE_ACCEPT_HEADER,
|
|
67
|
+
'Content-Type': DEERE_ACCEPT_HEADER,
|
|
68
|
+
...config.defaultHeaders,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Make a GET request to the John Deere API
|
|
73
|
+
*/
|
|
74
|
+
async get(path, options) {
|
|
75
|
+
return this.request('GET', path, undefined, options);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Make a POST request to the John Deere API
|
|
79
|
+
*/
|
|
80
|
+
async post(path, body, options) {
|
|
81
|
+
return this.request('POST', path, body, options);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Make a PUT request to the John Deere API
|
|
85
|
+
*/
|
|
86
|
+
async put(path, body, options) {
|
|
87
|
+
return this.request('PUT', path, body, options);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Make a DELETE request to the John Deere API
|
|
91
|
+
*/
|
|
92
|
+
async delete(path, options) {
|
|
93
|
+
return this.request('DELETE', path, undefined, options);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Make a PATCH request to the John Deere API
|
|
97
|
+
*/
|
|
98
|
+
async patch(path, body, options) {
|
|
99
|
+
return this.request('PATCH', path, body, options);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Follow a HAL link from a response
|
|
103
|
+
*/
|
|
104
|
+
async followLink(link, options) {
|
|
105
|
+
const uri = typeof link === 'string' ? link : link.uri;
|
|
106
|
+
// If it's a full URL, use it directly; otherwise treat as path
|
|
107
|
+
const url = uri.startsWith('http') ? uri : `${this.baseUrl}${uri}`;
|
|
108
|
+
return this.requestUrl('GET', url, undefined, options);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Paginate through all results following nextPage links
|
|
112
|
+
*/
|
|
113
|
+
async *paginate(path, options) {
|
|
114
|
+
let url = `${this.baseUrl}${path}`;
|
|
115
|
+
while (url) {
|
|
116
|
+
const response = await this.requestUrl('GET', url, undefined, options);
|
|
117
|
+
if (response.values && response.values.length > 0) {
|
|
118
|
+
yield response.values;
|
|
119
|
+
}
|
|
120
|
+
// Find nextPage link
|
|
121
|
+
const nextPageLink = response.links?.find((l) => l.rel === 'nextPage');
|
|
122
|
+
url = nextPageLink?.uri;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get all items from a paginated endpoint
|
|
127
|
+
*/
|
|
128
|
+
async getAll(path, options) {
|
|
129
|
+
const items = [];
|
|
130
|
+
for await (const page of this.paginate(path, options)) {
|
|
131
|
+
items.push(...page);
|
|
132
|
+
}
|
|
133
|
+
return items;
|
|
134
|
+
}
|
|
135
|
+
async request(method, path, body, options) {
|
|
136
|
+
const url = path.startsWith('http') ? path : `${this.baseUrl}${path}`;
|
|
137
|
+
return this.requestUrl(method, url, body, options);
|
|
138
|
+
}
|
|
139
|
+
async requestUrl(method, url, body, options) {
|
|
140
|
+
const timeout = options?.timeout ?? this.timeout;
|
|
141
|
+
const controller = new AbortController();
|
|
142
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
143
|
+
try {
|
|
144
|
+
const response = await this.fetchFn(url, {
|
|
145
|
+
method,
|
|
146
|
+
headers: {
|
|
147
|
+
...this.defaultHeaders,
|
|
148
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
149
|
+
...options?.headers,
|
|
150
|
+
},
|
|
151
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
152
|
+
signal: options?.signal ?? controller.signal,
|
|
153
|
+
});
|
|
154
|
+
clearTimeout(timeoutId);
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
await this.handleError(response);
|
|
157
|
+
}
|
|
158
|
+
// Handle empty responses
|
|
159
|
+
const contentLength = response.headers.get('content-length');
|
|
160
|
+
if (contentLength === '0' || response.status === 204) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
const contentType = response.headers.get('content-type');
|
|
164
|
+
if (contentType?.includes('application/json') || contentType?.includes('application/vnd.deere')) {
|
|
165
|
+
return (await response.json());
|
|
166
|
+
}
|
|
167
|
+
return (await response.text());
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
clearTimeout(timeoutId);
|
|
171
|
+
if (error instanceof DeereError) {
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
175
|
+
throw new DeereError('Request timeout', 0, 'Timeout');
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async handleError(response) {
|
|
181
|
+
let body;
|
|
182
|
+
try {
|
|
183
|
+
body = await response.json();
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
body = await response.text().catch(() => undefined);
|
|
187
|
+
}
|
|
188
|
+
const message = this.extractErrorMessage(body) ?? response.statusText;
|
|
189
|
+
if (response.status === 429) {
|
|
190
|
+
const retryAfter = parseInt(response.headers.get('retry-after') ?? '', 10);
|
|
191
|
+
throw new RateLimitError(message, response.status, response.statusText, isNaN(retryAfter) ? undefined : retryAfter, body);
|
|
192
|
+
}
|
|
193
|
+
if (response.status === 401 || response.status === 403) {
|
|
194
|
+
throw new AuthError(message, response.status, response.statusText, body);
|
|
195
|
+
}
|
|
196
|
+
throw new DeereError(message, response.status, response.statusText, body);
|
|
197
|
+
}
|
|
198
|
+
extractErrorMessage(body) {
|
|
199
|
+
if (!body || typeof body !== 'object')
|
|
200
|
+
return undefined;
|
|
201
|
+
const obj = body;
|
|
202
|
+
// Try common error message fields
|
|
203
|
+
if (typeof obj.message === 'string')
|
|
204
|
+
return obj.message;
|
|
205
|
+
if (typeof obj.error === 'string')
|
|
206
|
+
return obj.error;
|
|
207
|
+
if (typeof obj.error_description === 'string')
|
|
208
|
+
return obj.error_description;
|
|
209
|
+
// Try nested errors array
|
|
210
|
+
if (Array.isArray(obj.errors) && obj.errors.length > 0) {
|
|
211
|
+
const first = obj.errors[0];
|
|
212
|
+
if (typeof first.message === 'string')
|
|
213
|
+
return first.message;
|
|
214
|
+
}
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Create a John Deere API client
|
|
220
|
+
*/
|
|
221
|
+
export function createClient(config) {
|
|
222
|
+
return new DeereClient(config);
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=client.js.map
|