@chrt-inc/typescript-sdk 0.231.0 → 0.252.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.
Files changed (116) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/tracking/client/Client.d.ts +6 -0
  3. package/dist/cjs/api/resources/tracking/client/Client.js +12 -2
  4. package/dist/cjs/api/resources/tracking/resources/devices/client/Client.d.ts +103 -0
  5. package/dist/cjs/api/resources/tracking/resources/devices/client/Client.js +371 -0
  6. package/dist/cjs/api/resources/tracking/resources/devices/client/index.d.ts +2 -0
  7. package/dist/cjs/api/resources/tracking/resources/devices/client/index.js +17 -0
  8. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesGetRequest.d.ts +12 -0
  9. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesGetRequest.js +5 -0
  10. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesLinkToCargoRequest.d.ts +14 -0
  11. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesLinkToCargoRequest.js +5 -0
  12. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesRegisterToOrgRequest.d.ts +12 -0
  13. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesRegisterToOrgRequest.js +5 -0
  14. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesUnlinkFromCargoRequest.d.ts +12 -0
  15. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/DevicesUnlinkFromCargoRequest.js +5 -0
  16. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/index.d.ts +4 -0
  17. package/dist/cjs/api/resources/tracking/resources/devices/client/requests/index.js +2 -0
  18. package/dist/cjs/api/resources/tracking/resources/devices/index.d.ts +1 -0
  19. package/dist/cjs/api/resources/tracking/resources/devices/index.js +17 -0
  20. package/dist/cjs/api/resources/tracking/resources/index.d.ts +4 -0
  21. package/dist/cjs/api/resources/tracking/resources/index.js +5 -1
  22. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/Client.d.ts +137 -0
  23. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/Client.js +510 -0
  24. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/index.d.ts +2 -0
  25. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/index.js +17 -0
  26. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceCreateSessionRequest1.d.ts +13 -0
  27. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceCreateSessionRequest1.js +5 -0
  28. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceEndSessionRequest.d.ts +12 -0
  29. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceEndSessionRequest.js +5 -0
  30. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceLastSeenRequest.d.ts +12 -0
  31. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceLastSeenRequest.js +5 -0
  32. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDevicePauseSessionRequest.d.ts +12 -0
  33. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDevicePauseSessionRequest.js +5 -0
  34. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceResumeSessionRequest.d.ts +12 -0
  35. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceResumeSessionRequest.js +5 -0
  36. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceStartSessionRequest.d.ts +12 -0
  37. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceStartSessionRequest.js +5 -0
  38. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceUpdateCommentsRequest1.d.ts +14 -0
  39. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceUpdateCommentsRequest1.js +5 -0
  40. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/index.d.ts +7 -0
  41. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/client/requests/index.js +2 -0
  42. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/index.d.ts +1 -0
  43. package/dist/cjs/api/resources/tracking/resources/sessionByDevice/index.js +17 -0
  44. package/dist/cjs/api/types/Cargo1.d.ts +1 -1
  45. package/dist/cjs/api/types/DecodedJwtWithOrgAndUserId.d.ts +1 -1
  46. package/dist/cjs/api/types/Device1.d.ts +19 -0
  47. package/dist/cjs/api/types/Device1.js +5 -0
  48. package/dist/cjs/api/types/TrackingDeviceTypeEnum1.d.ts +9 -0
  49. package/dist/cjs/api/types/TrackingDeviceTypeEnum1.js +11 -0
  50. package/dist/cjs/api/types/TrackingSessionByDeviceDataPoint1.d.ts +12 -0
  51. package/dist/cjs/api/types/TrackingSessionByDeviceDataPoint1.js +5 -0
  52. package/dist/cjs/api/types/TrackingSessionByDeviceDataPointMetadata1.d.ts +6 -0
  53. package/dist/cjs/api/types/TrackingSessionByDeviceDataPointMetadata1.js +5 -0
  54. package/dist/cjs/api/types/index.d.ts +4 -0
  55. package/dist/cjs/api/types/index.js +4 -0
  56. package/dist/cjs/version.d.ts +1 -1
  57. package/dist/cjs/version.js +1 -1
  58. package/dist/esm/Client.mjs +2 -2
  59. package/dist/esm/api/resources/tracking/client/Client.d.mts +6 -0
  60. package/dist/esm/api/resources/tracking/client/Client.mjs +10 -0
  61. package/dist/esm/api/resources/tracking/resources/devices/client/Client.d.mts +103 -0
  62. package/dist/esm/api/resources/tracking/resources/devices/client/Client.mjs +334 -0
  63. package/dist/esm/api/resources/tracking/resources/devices/client/index.d.mts +2 -0
  64. package/dist/esm/api/resources/tracking/resources/devices/client/index.mjs +1 -0
  65. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesGetRequest.d.mts +12 -0
  66. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesGetRequest.mjs +4 -0
  67. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesLinkToCargoRequest.d.mts +14 -0
  68. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesLinkToCargoRequest.mjs +4 -0
  69. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesRegisterToOrgRequest.d.mts +12 -0
  70. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesRegisterToOrgRequest.mjs +4 -0
  71. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesUnlinkFromCargoRequest.d.mts +12 -0
  72. package/dist/esm/api/resources/tracking/resources/devices/client/requests/DevicesUnlinkFromCargoRequest.mjs +4 -0
  73. package/dist/esm/api/resources/tracking/resources/devices/client/requests/index.d.mts +4 -0
  74. package/dist/esm/api/resources/tracking/resources/devices/client/requests/index.mjs +1 -0
  75. package/dist/esm/api/resources/tracking/resources/devices/index.d.mts +1 -0
  76. package/dist/esm/api/resources/tracking/resources/devices/index.mjs +1 -0
  77. package/dist/esm/api/resources/tracking/resources/index.d.mts +4 -0
  78. package/dist/esm/api/resources/tracking/resources/index.mjs +4 -0
  79. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/Client.d.mts +137 -0
  80. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/Client.mjs +473 -0
  81. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/index.d.mts +2 -0
  82. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/index.mjs +1 -0
  83. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceCreateSessionRequest1.d.mts +13 -0
  84. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceCreateSessionRequest1.mjs +4 -0
  85. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceEndSessionRequest.d.mts +12 -0
  86. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceEndSessionRequest.mjs +4 -0
  87. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceLastSeenRequest.d.mts +12 -0
  88. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceLastSeenRequest.mjs +4 -0
  89. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDevicePauseSessionRequest.d.mts +12 -0
  90. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDevicePauseSessionRequest.mjs +4 -0
  91. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceResumeSessionRequest.d.mts +12 -0
  92. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceResumeSessionRequest.mjs +4 -0
  93. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceStartSessionRequest.d.mts +12 -0
  94. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceStartSessionRequest.mjs +4 -0
  95. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceUpdateCommentsRequest1.d.mts +14 -0
  96. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/SessionByDeviceUpdateCommentsRequest1.mjs +4 -0
  97. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/index.d.mts +7 -0
  98. package/dist/esm/api/resources/tracking/resources/sessionByDevice/client/requests/index.mjs +1 -0
  99. package/dist/esm/api/resources/tracking/resources/sessionByDevice/index.d.mts +1 -0
  100. package/dist/esm/api/resources/tracking/resources/sessionByDevice/index.mjs +1 -0
  101. package/dist/esm/api/types/Cargo1.d.mts +1 -1
  102. package/dist/esm/api/types/DecodedJwtWithOrgAndUserId.d.mts +1 -1
  103. package/dist/esm/api/types/Device1.d.mts +19 -0
  104. package/dist/esm/api/types/Device1.mjs +4 -0
  105. package/dist/esm/api/types/TrackingDeviceTypeEnum1.d.mts +9 -0
  106. package/dist/esm/api/types/TrackingDeviceTypeEnum1.mjs +8 -0
  107. package/dist/esm/api/types/TrackingSessionByDeviceDataPoint1.d.mts +12 -0
  108. package/dist/esm/api/types/TrackingSessionByDeviceDataPoint1.mjs +4 -0
  109. package/dist/esm/api/types/TrackingSessionByDeviceDataPointMetadata1.d.mts +6 -0
  110. package/dist/esm/api/types/TrackingSessionByDeviceDataPointMetadata1.mjs +4 -0
  111. package/dist/esm/api/types/index.d.mts +4 -0
  112. package/dist/esm/api/types/index.mjs +4 -0
  113. package/dist/esm/version.d.mts +1 -1
  114. package/dist/esm/version.mjs +1 -1
  115. package/package.json +1 -1
  116. package/reference.md +790 -15
@@ -68,8 +68,8 @@ class ChrtClient {
68
68
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
69
69
  "X-Fern-Language": "JavaScript",
70
70
  "X-Fern-SDK-Name": "@chrt-inc/typescript-sdk",
71
- "X-Fern-SDK-Version": "0.231.0",
72
- "User-Agent": "@chrt-inc/typescript-sdk/0.231.0",
71
+ "X-Fern-SDK-Version": "0.252.0",
72
+ "User-Agent": "@chrt-inc/typescript-sdk/0.252.0",
73
73
  "X-Fern-Runtime": core.RUNTIME.type,
74
74
  "X-Fern-Runtime-Version": core.RUNTIME.version,
75
75
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -4,7 +4,9 @@
4
4
  import * as environments from "../../../../environments.js";
5
5
  import * as core from "../../../../core/index.js";
6
6
  import { CargoByDriver } from "../resources/cargoByDriver/client/Client.js";
7
+ import { Devices } from "../resources/devices/client/Client.js";
7
8
  import { TaskGroupByDriver } from "../resources/taskGroupByDriver/client/Client.js";
9
+ import { SessionByDevice } from "../resources/sessionByDevice/client/Client.js";
8
10
  export declare namespace Tracking {
9
11
  interface Options {
10
12
  environment?: core.Supplier<environments.ChrtEnvironment | string>;
@@ -19,8 +21,12 @@ export declare namespace Tracking {
19
21
  export declare class Tracking {
20
22
  protected readonly _options: Tracking.Options;
21
23
  protected _cargoByDriver: CargoByDriver | undefined;
24
+ protected _devices: Devices | undefined;
22
25
  protected _taskGroupByDriver: TaskGroupByDriver | undefined;
26
+ protected _sessionByDevice: SessionByDevice | undefined;
23
27
  constructor(_options?: Tracking.Options);
24
28
  get cargoByDriver(): CargoByDriver;
29
+ get devices(): Devices;
25
30
  get taskGroupByDriver(): TaskGroupByDriver;
31
+ get sessionByDevice(): SessionByDevice;
26
32
  }
@@ -5,7 +5,9 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Tracking = void 0;
7
7
  const Client_js_1 = require("../resources/cargoByDriver/client/Client.js");
8
- const Client_js_2 = require("../resources/taskGroupByDriver/client/Client.js");
8
+ const Client_js_2 = require("../resources/devices/client/Client.js");
9
+ const Client_js_3 = require("../resources/taskGroupByDriver/client/Client.js");
10
+ const Client_js_4 = require("../resources/sessionByDevice/client/Client.js");
9
11
  class Tracking {
10
12
  constructor(_options = {}) {
11
13
  this._options = _options;
@@ -14,9 +16,17 @@ class Tracking {
14
16
  var _a;
15
17
  return ((_a = this._cargoByDriver) !== null && _a !== void 0 ? _a : (this._cargoByDriver = new Client_js_1.CargoByDriver(this._options)));
16
18
  }
19
+ get devices() {
20
+ var _a;
21
+ return ((_a = this._devices) !== null && _a !== void 0 ? _a : (this._devices = new Client_js_2.Devices(this._options)));
22
+ }
17
23
  get taskGroupByDriver() {
18
24
  var _a;
19
- return ((_a = this._taskGroupByDriver) !== null && _a !== void 0 ? _a : (this._taskGroupByDriver = new Client_js_2.TaskGroupByDriver(this._options)));
25
+ return ((_a = this._taskGroupByDriver) !== null && _a !== void 0 ? _a : (this._taskGroupByDriver = new Client_js_3.TaskGroupByDriver(this._options)));
26
+ }
27
+ get sessionByDevice() {
28
+ var _a;
29
+ return ((_a = this._sessionByDevice) !== null && _a !== void 0 ? _a : (this._sessionByDevice = new Client_js_4.SessionByDevice(this._options)));
20
30
  }
21
31
  }
22
32
  exports.Tracking = Tracking;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../../../environments.js";
5
+ import * as core from "../../../../../../core/index.js";
6
+ import * as Chrt from "../../../../../index.js";
7
+ export declare namespace Devices {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.ChrtEnvironment | string>;
10
+ /** Specify a custom URL to connect the client to. */
11
+ baseUrl?: core.Supplier<string>;
12
+ token?: core.Supplier<core.BearerToken | undefined>;
13
+ /** Additional headers to include in requests. */
14
+ headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
15
+ fetcher?: core.FetchFunction;
16
+ }
17
+ interface RequestOptions {
18
+ /** The maximum time to wait for a response in seconds. */
19
+ timeoutInSeconds?: number;
20
+ /** The number of times to retry the request. Defaults to 2. */
21
+ maxRetries?: number;
22
+ /** A hook to abort the request. */
23
+ abortSignal?: AbortSignal;
24
+ /** Additional headers to include in the request. */
25
+ headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
26
+ }
27
+ }
28
+ export declare class Devices {
29
+ protected readonly _options: Devices.Options;
30
+ constructor(_options?: Devices.Options);
31
+ /**
32
+ * Register a device to the caller's org.
33
+ *
34
+ * @param {Chrt.tracking.DevicesRegisterToOrgRequest} request
35
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
36
+ *
37
+ * @throws {@link Chrt.UnprocessableEntityError}
38
+ *
39
+ * @example
40
+ * await client.tracking.devices.registerToOrg({
41
+ * device_mac_address: "device_mac_address"
42
+ * })
43
+ */
44
+ registerToOrg(request: Chrt.tracking.DevicesRegisterToOrgRequest, requestOptions?: Devices.RequestOptions): core.HttpResponsePromise<string>;
45
+ private __registerToOrg;
46
+ /**
47
+ * Get a device by device_mac_address.
48
+ *
49
+ * @param {Chrt.tracking.DevicesGetRequest} request
50
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
51
+ *
52
+ * @throws {@link Chrt.UnprocessableEntityError}
53
+ *
54
+ * @example
55
+ * await client.tracking.devices.get({
56
+ * device_mac_address: "device_mac_address"
57
+ * })
58
+ */
59
+ get(request: Chrt.tracking.DevicesGetRequest, requestOptions?: Devices.RequestOptions): core.HttpResponsePromise<Chrt.Device1>;
60
+ private __get;
61
+ /**
62
+ * List all devices registered to the caller's org.
63
+ *
64
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
65
+ *
66
+ * @example
67
+ * await client.tracking.devices.list()
68
+ */
69
+ list(requestOptions?: Devices.RequestOptions): core.HttpResponsePromise<Chrt.Device1[]>;
70
+ private __list;
71
+ /**
72
+ * Link a device to a cargo (bidirectional references).
73
+ *
74
+ * @param {Chrt.tracking.DevicesLinkToCargoRequest} request
75
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
76
+ *
77
+ * @throws {@link Chrt.UnprocessableEntityError}
78
+ *
79
+ * @example
80
+ * await client.tracking.devices.linkToCargo({
81
+ * device_mac_address: "device_mac_address",
82
+ * cargo_id: "cargo_id"
83
+ * })
84
+ */
85
+ linkToCargo(request: Chrt.tracking.DevicesLinkToCargoRequest, requestOptions?: Devices.RequestOptions): core.HttpResponsePromise<boolean>;
86
+ private __linkToCargo;
87
+ /**
88
+ * Unlink a device from its cargo if linked.
89
+ *
90
+ * @param {Chrt.tracking.DevicesUnlinkFromCargoRequest} request
91
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
92
+ *
93
+ * @throws {@link Chrt.UnprocessableEntityError}
94
+ *
95
+ * @example
96
+ * await client.tracking.devices.unlinkFromCargo({
97
+ * device_mac_address: "device_mac_address"
98
+ * })
99
+ */
100
+ unlinkFromCargo(request: Chrt.tracking.DevicesUnlinkFromCargoRequest, requestOptions?: Devices.RequestOptions): core.HttpResponsePromise<boolean>;
101
+ private __unlinkFromCargo;
102
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
103
+ }
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.Devices = void 0;
49
+ const environments = __importStar(require("../../../../../../environments.js"));
50
+ const core = __importStar(require("../../../../../../core/index.js"));
51
+ const Chrt = __importStar(require("../../../../../index.js"));
52
+ const headers_js_1 = require("../../../../../../core/headers.js");
53
+ const errors = __importStar(require("../../../../../../errors/index.js"));
54
+ class Devices {
55
+ constructor(_options = {}) {
56
+ this._options = _options;
57
+ }
58
+ /**
59
+ * Register a device to the caller's org.
60
+ *
61
+ * @param {Chrt.tracking.DevicesRegisterToOrgRequest} request
62
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
63
+ *
64
+ * @throws {@link Chrt.UnprocessableEntityError}
65
+ *
66
+ * @example
67
+ * await client.tracking.devices.registerToOrg({
68
+ * device_mac_address: "device_mac_address"
69
+ * })
70
+ */
71
+ registerToOrg(request, requestOptions) {
72
+ return core.HttpResponsePromise.fromPromise(this.__registerToOrg(request, requestOptions));
73
+ }
74
+ __registerToOrg(request, requestOptions) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ var _a, _b, _c, _d;
77
+ const { device_mac_address: deviceMacAddress } = request;
78
+ const _queryParams = {};
79
+ _queryParams["device_mac_address"] = deviceMacAddress;
80
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
81
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ChrtEnvironment.Local, "tracking/devices/register_to_org"),
82
+ method: "POST",
83
+ headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
84
+ queryParameters: _queryParams,
85
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
86
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
87
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
88
+ });
89
+ if (_response.ok) {
90
+ return { data: _response.body, rawResponse: _response.rawResponse };
91
+ }
92
+ if (_response.error.reason === "status-code") {
93
+ switch (_response.error.statusCode) {
94
+ case 422:
95
+ throw new Chrt.UnprocessableEntityError(_response.error.body, _response.rawResponse);
96
+ default:
97
+ throw new errors.ChrtError({
98
+ statusCode: _response.error.statusCode,
99
+ body: _response.error.body,
100
+ rawResponse: _response.rawResponse,
101
+ });
102
+ }
103
+ }
104
+ switch (_response.error.reason) {
105
+ case "non-json":
106
+ throw new errors.ChrtError({
107
+ statusCode: _response.error.statusCode,
108
+ body: _response.error.rawBody,
109
+ rawResponse: _response.rawResponse,
110
+ });
111
+ case "timeout":
112
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling POST /tracking/devices/register_to_org.");
113
+ case "unknown":
114
+ throw new errors.ChrtError({
115
+ message: _response.error.errorMessage,
116
+ rawResponse: _response.rawResponse,
117
+ });
118
+ }
119
+ });
120
+ }
121
+ /**
122
+ * Get a device by device_mac_address.
123
+ *
124
+ * @param {Chrt.tracking.DevicesGetRequest} request
125
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
126
+ *
127
+ * @throws {@link Chrt.UnprocessableEntityError}
128
+ *
129
+ * @example
130
+ * await client.tracking.devices.get({
131
+ * device_mac_address: "device_mac_address"
132
+ * })
133
+ */
134
+ get(request, requestOptions) {
135
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
136
+ }
137
+ __get(request, requestOptions) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ var _a, _b, _c, _d;
140
+ const { device_mac_address: deviceMacAddress } = request;
141
+ const _queryParams = {};
142
+ _queryParams["device_mac_address"] = deviceMacAddress;
143
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
144
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ChrtEnvironment.Local, "tracking/devices"),
145
+ method: "GET",
146
+ headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
147
+ queryParameters: _queryParams,
148
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
149
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
150
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
151
+ });
152
+ if (_response.ok) {
153
+ return { data: _response.body, rawResponse: _response.rawResponse };
154
+ }
155
+ if (_response.error.reason === "status-code") {
156
+ switch (_response.error.statusCode) {
157
+ case 422:
158
+ throw new Chrt.UnprocessableEntityError(_response.error.body, _response.rawResponse);
159
+ default:
160
+ throw new errors.ChrtError({
161
+ statusCode: _response.error.statusCode,
162
+ body: _response.error.body,
163
+ rawResponse: _response.rawResponse,
164
+ });
165
+ }
166
+ }
167
+ switch (_response.error.reason) {
168
+ case "non-json":
169
+ throw new errors.ChrtError({
170
+ statusCode: _response.error.statusCode,
171
+ body: _response.error.rawBody,
172
+ rawResponse: _response.rawResponse,
173
+ });
174
+ case "timeout":
175
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling GET /tracking/devices.");
176
+ case "unknown":
177
+ throw new errors.ChrtError({
178
+ message: _response.error.errorMessage,
179
+ rawResponse: _response.rawResponse,
180
+ });
181
+ }
182
+ });
183
+ }
184
+ /**
185
+ * List all devices registered to the caller's org.
186
+ *
187
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
188
+ *
189
+ * @example
190
+ * await client.tracking.devices.list()
191
+ */
192
+ list(requestOptions) {
193
+ return core.HttpResponsePromise.fromPromise(this.__list(requestOptions));
194
+ }
195
+ __list(requestOptions) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ var _a, _b, _c, _d;
198
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
199
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ChrtEnvironment.Local, "tracking/devices/list"),
200
+ method: "GET",
201
+ headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
202
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
203
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
204
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
205
+ });
206
+ if (_response.ok) {
207
+ return { data: _response.body, rawResponse: _response.rawResponse };
208
+ }
209
+ if (_response.error.reason === "status-code") {
210
+ throw new errors.ChrtError({
211
+ statusCode: _response.error.statusCode,
212
+ body: _response.error.body,
213
+ rawResponse: _response.rawResponse,
214
+ });
215
+ }
216
+ switch (_response.error.reason) {
217
+ case "non-json":
218
+ throw new errors.ChrtError({
219
+ statusCode: _response.error.statusCode,
220
+ body: _response.error.rawBody,
221
+ rawResponse: _response.rawResponse,
222
+ });
223
+ case "timeout":
224
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling GET /tracking/devices/list.");
225
+ case "unknown":
226
+ throw new errors.ChrtError({
227
+ message: _response.error.errorMessage,
228
+ rawResponse: _response.rawResponse,
229
+ });
230
+ }
231
+ });
232
+ }
233
+ /**
234
+ * Link a device to a cargo (bidirectional references).
235
+ *
236
+ * @param {Chrt.tracking.DevicesLinkToCargoRequest} request
237
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
238
+ *
239
+ * @throws {@link Chrt.UnprocessableEntityError}
240
+ *
241
+ * @example
242
+ * await client.tracking.devices.linkToCargo({
243
+ * device_mac_address: "device_mac_address",
244
+ * cargo_id: "cargo_id"
245
+ * })
246
+ */
247
+ linkToCargo(request, requestOptions) {
248
+ return core.HttpResponsePromise.fromPromise(this.__linkToCargo(request, requestOptions));
249
+ }
250
+ __linkToCargo(request, requestOptions) {
251
+ return __awaiter(this, void 0, void 0, function* () {
252
+ var _a, _b, _c, _d;
253
+ const { device_mac_address: deviceMacAddress, cargo_id: cargoId } = request;
254
+ const _queryParams = {};
255
+ _queryParams["device_mac_address"] = deviceMacAddress;
256
+ _queryParams["cargo_id"] = cargoId;
257
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
258
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ChrtEnvironment.Local, "tracking/devices/link_to_cargo"),
259
+ method: "POST",
260
+ headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
261
+ queryParameters: _queryParams,
262
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
263
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
264
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
265
+ });
266
+ if (_response.ok) {
267
+ return { data: _response.body, rawResponse: _response.rawResponse };
268
+ }
269
+ if (_response.error.reason === "status-code") {
270
+ switch (_response.error.statusCode) {
271
+ case 422:
272
+ throw new Chrt.UnprocessableEntityError(_response.error.body, _response.rawResponse);
273
+ default:
274
+ throw new errors.ChrtError({
275
+ statusCode: _response.error.statusCode,
276
+ body: _response.error.body,
277
+ rawResponse: _response.rawResponse,
278
+ });
279
+ }
280
+ }
281
+ switch (_response.error.reason) {
282
+ case "non-json":
283
+ throw new errors.ChrtError({
284
+ statusCode: _response.error.statusCode,
285
+ body: _response.error.rawBody,
286
+ rawResponse: _response.rawResponse,
287
+ });
288
+ case "timeout":
289
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling POST /tracking/devices/link_to_cargo.");
290
+ case "unknown":
291
+ throw new errors.ChrtError({
292
+ message: _response.error.errorMessage,
293
+ rawResponse: _response.rawResponse,
294
+ });
295
+ }
296
+ });
297
+ }
298
+ /**
299
+ * Unlink a device from its cargo if linked.
300
+ *
301
+ * @param {Chrt.tracking.DevicesUnlinkFromCargoRequest} request
302
+ * @param {Devices.RequestOptions} requestOptions - Request-specific configuration.
303
+ *
304
+ * @throws {@link Chrt.UnprocessableEntityError}
305
+ *
306
+ * @example
307
+ * await client.tracking.devices.unlinkFromCargo({
308
+ * device_mac_address: "device_mac_address"
309
+ * })
310
+ */
311
+ unlinkFromCargo(request, requestOptions) {
312
+ return core.HttpResponsePromise.fromPromise(this.__unlinkFromCargo(request, requestOptions));
313
+ }
314
+ __unlinkFromCargo(request, requestOptions) {
315
+ return __awaiter(this, void 0, void 0, function* () {
316
+ var _a, _b, _c, _d;
317
+ const { device_mac_address: deviceMacAddress } = request;
318
+ const _queryParams = {};
319
+ _queryParams["device_mac_address"] = deviceMacAddress;
320
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
321
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.ChrtEnvironment.Local, "tracking/devices/unlink_from_cargo"),
322
+ method: "POST",
323
+ headers: (0, headers_js_1.mergeHeaders)((_d = this._options) === null || _d === void 0 ? void 0 : _d.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
324
+ queryParameters: _queryParams,
325
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
326
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
327
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
328
+ });
329
+ if (_response.ok) {
330
+ return { data: _response.body, rawResponse: _response.rawResponse };
331
+ }
332
+ if (_response.error.reason === "status-code") {
333
+ switch (_response.error.statusCode) {
334
+ case 422:
335
+ throw new Chrt.UnprocessableEntityError(_response.error.body, _response.rawResponse);
336
+ default:
337
+ throw new errors.ChrtError({
338
+ statusCode: _response.error.statusCode,
339
+ body: _response.error.body,
340
+ rawResponse: _response.rawResponse,
341
+ });
342
+ }
343
+ }
344
+ switch (_response.error.reason) {
345
+ case "non-json":
346
+ throw new errors.ChrtError({
347
+ statusCode: _response.error.statusCode,
348
+ body: _response.error.rawBody,
349
+ rawResponse: _response.rawResponse,
350
+ });
351
+ case "timeout":
352
+ throw new errors.ChrtTimeoutError("Timeout exceeded when calling POST /tracking/devices/unlink_from_cargo.");
353
+ case "unknown":
354
+ throw new errors.ChrtError({
355
+ message: _response.error.errorMessage,
356
+ rawResponse: _response.rawResponse,
357
+ });
358
+ }
359
+ });
360
+ }
361
+ _getAuthorizationHeader() {
362
+ return __awaiter(this, void 0, void 0, function* () {
363
+ const bearer = yield core.Supplier.get(this._options.token);
364
+ if (bearer != null) {
365
+ return `Bearer ${bearer}`;
366
+ }
367
+ return undefined;
368
+ });
369
+ }
370
+ }
371
+ exports.Devices = Devices;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ export * from "./requests/index.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests/index.js"), exports);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * device_mac_address: "device_mac_address"
8
+ * }
9
+ */
10
+ export interface DevicesGetRequest {
11
+ device_mac_address: string;
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * device_mac_address: "device_mac_address",
8
+ * cargo_id: "cargo_id"
9
+ * }
10
+ */
11
+ export interface DevicesLinkToCargoRequest {
12
+ device_mac_address: string;
13
+ cargo_id: string;
14
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * device_mac_address: "device_mac_address"
8
+ * }
9
+ */
10
+ export interface DevicesRegisterToOrgRequest {
11
+ device_mac_address: string;
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * device_mac_address: "device_mac_address"
8
+ * }
9
+ */
10
+ export interface DevicesUnlinkFromCargoRequest {
11
+ device_mac_address: string;
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export { type DevicesRegisterToOrgRequest } from "./DevicesRegisterToOrgRequest.js";
2
+ export { type DevicesGetRequest } from "./DevicesGetRequest.js";
3
+ export { type DevicesLinkToCargoRequest } from "./DevicesLinkToCargoRequest.js";
4
+ export { type DevicesUnlinkFromCargoRequest } from "./DevicesUnlinkFromCargoRequest.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client/index.js";