@seamapi/http 0.21.1 → 0.23.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/README.md +1 -1
- package/dist/connect.cjs +161 -10
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +29 -11
- package/lib/seam/connect/routes/index.d.ts +1 -0
- package/lib/seam/connect/routes/index.js +1 -0
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/phones-simulate.d.ts +20 -0
- package/lib/seam/connect/routes/phones-simulate.js +87 -0
- package/lib/seam/connect/routes/phones-simulate.js.map +1 -0
- package/lib/seam/connect/routes/phones.d.ts +2 -0
- package/lib/seam/connect/routes/phones.js +4 -0
- package/lib/seam/connect/routes/phones.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +10 -10
- package/lib/seam/connect/routes/thermostats.js +52 -10
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/src/lib/seam/connect/routes/index.ts +1 -0
- package/src/lib/seam/connect/routes/phones-simulate.ts +177 -0
- package/src/lib/seam/connect/routes/phones.ts +5 -0
- package/src/lib/seam/connect/routes/thermostats.ts +112 -15
- package/src/lib/version.ts +1 -1
package/README.md
CHANGED
|
@@ -366,7 +366,7 @@ Either pass the `endpoint` option, or set the `SEAM_ENDPOINT` environment variab
|
|
|
366
366
|
#### Configuring the Axios Client
|
|
367
367
|
|
|
368
368
|
The Axios client and retry behavior may be configured with custom initiation options
|
|
369
|
-
via [`axiosOptions`] and [`axiosRetryOptions`][axiosRetryOptions].
|
|
369
|
+
via [`axiosOptions`][axiosOptions] and [`axiosRetryOptions`][axiosRetryOptions].
|
|
370
370
|
Options are deep merged with the default options.
|
|
371
371
|
|
|
372
372
|
[axiosOptions]: https://axios-http.com/docs/config_defaults
|
package/dist/connect.cjs
CHANGED
|
@@ -3015,6 +3015,93 @@ var SeamHttpNoiseSensors = class _SeamHttpNoiseSensors {
|
|
|
3015
3015
|
}
|
|
3016
3016
|
};
|
|
3017
3017
|
|
|
3018
|
+
// src/lib/seam/connect/routes/phones-simulate.ts
|
|
3019
|
+
var SeamHttpPhonesSimulate = class _SeamHttpPhonesSimulate {
|
|
3020
|
+
constructor(apiKeyOrOptions = {}) {
|
|
3021
|
+
const options = parseOptions(apiKeyOrOptions);
|
|
3022
|
+
this.client = "client" in options ? options.client : createClient(options);
|
|
3023
|
+
this.defaults = limitToSeamHttpRequestOptions(options);
|
|
3024
|
+
}
|
|
3025
|
+
static fromClient(client, options = {}) {
|
|
3026
|
+
const constructorOptions = { ...options, client };
|
|
3027
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
3028
|
+
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
3029
|
+
}
|
|
3030
|
+
return new _SeamHttpPhonesSimulate(constructorOptions);
|
|
3031
|
+
}
|
|
3032
|
+
static fromApiKey(apiKey, options = {}) {
|
|
3033
|
+
const constructorOptions = { ...options, apiKey };
|
|
3034
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
3035
|
+
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
3036
|
+
}
|
|
3037
|
+
return new _SeamHttpPhonesSimulate(constructorOptions);
|
|
3038
|
+
}
|
|
3039
|
+
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
3040
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
3041
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
3042
|
+
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
3043
|
+
}
|
|
3044
|
+
return new _SeamHttpPhonesSimulate(constructorOptions);
|
|
3045
|
+
}
|
|
3046
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
3047
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
3048
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
3049
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
3050
|
+
throw new SeamHttpInvalidOptionsError(
|
|
3051
|
+
"The client option cannot be used with SeamHttp.fromPublishableKey"
|
|
3052
|
+
);
|
|
3053
|
+
}
|
|
3054
|
+
const client = createClient(clientOptions);
|
|
3055
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
3056
|
+
const { token } = await clientSessions.getOrCreate({
|
|
3057
|
+
user_identifier_key: userIdentifierKey
|
|
3058
|
+
});
|
|
3059
|
+
return _SeamHttpPhonesSimulate.fromClientSessionToken(token, options);
|
|
3060
|
+
}
|
|
3061
|
+
static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
|
|
3062
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId };
|
|
3063
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
3064
|
+
throw new SeamHttpInvalidOptionsError(
|
|
3065
|
+
"Missing consoleSessionToken or workspaceId"
|
|
3066
|
+
);
|
|
3067
|
+
}
|
|
3068
|
+
return new _SeamHttpPhonesSimulate(constructorOptions);
|
|
3069
|
+
}
|
|
3070
|
+
static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
|
|
3071
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId };
|
|
3072
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
3073
|
+
throw new SeamHttpInvalidOptionsError(
|
|
3074
|
+
"Missing personalAccessToken or workspaceId"
|
|
3075
|
+
);
|
|
3076
|
+
}
|
|
3077
|
+
return new _SeamHttpPhonesSimulate(constructorOptions);
|
|
3078
|
+
}
|
|
3079
|
+
async updateClientSessionToken(clientSessionToken) {
|
|
3080
|
+
const { headers } = this.client.defaults;
|
|
3081
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
3082
|
+
clientSessionToken
|
|
3083
|
+
});
|
|
3084
|
+
for (const key of Object.keys(authHeaders)) {
|
|
3085
|
+
if (headers[key] == null) {
|
|
3086
|
+
throw new Error(
|
|
3087
|
+
"Cannot update a clientSessionToken on a client created without a clientSessionToken"
|
|
3088
|
+
);
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
this.client.defaults.headers = { ...headers, ...authHeaders };
|
|
3092
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client);
|
|
3093
|
+
await clientSessions.get();
|
|
3094
|
+
}
|
|
3095
|
+
async createSandboxPhone(body) {
|
|
3096
|
+
const { data } = await this.client.request({
|
|
3097
|
+
url: "/phones/simulate/create_sandbox_phone",
|
|
3098
|
+
method: "post",
|
|
3099
|
+
data: body
|
|
3100
|
+
});
|
|
3101
|
+
return data.phone;
|
|
3102
|
+
}
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3018
3105
|
// src/lib/seam/connect/routes/phones.ts
|
|
3019
3106
|
var SeamHttpPhones = class _SeamHttpPhones {
|
|
3020
3107
|
constructor(apiKeyOrOptions = {}) {
|
|
@@ -3092,6 +3179,9 @@ var SeamHttpPhones = class _SeamHttpPhones {
|
|
|
3092
3179
|
const clientSessions = SeamHttpClientSessions.fromClient(this.client);
|
|
3093
3180
|
await clientSessions.get();
|
|
3094
3181
|
}
|
|
3182
|
+
get simulate() {
|
|
3183
|
+
return SeamHttpPhonesSimulate.fromClient(this.client, this.defaults);
|
|
3184
|
+
}
|
|
3095
3185
|
async deactivate(body) {
|
|
3096
3186
|
await this.client.request({
|
|
3097
3187
|
url: "/phones/deactivate",
|
|
@@ -3320,12 +3410,24 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
|
3320
3410
|
this.defaults
|
|
3321
3411
|
);
|
|
3322
3412
|
}
|
|
3323
|
-
async cool(body) {
|
|
3324
|
-
await this.client.request({
|
|
3413
|
+
async cool(body, options = {}) {
|
|
3414
|
+
const { data } = await this.client.request({
|
|
3325
3415
|
url: "/thermostats/cool",
|
|
3326
3416
|
method: "post",
|
|
3327
3417
|
data: body
|
|
3328
3418
|
});
|
|
3419
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3420
|
+
if (waitForActionAttempt !== false) {
|
|
3421
|
+
return await resolveActionAttempt(
|
|
3422
|
+
data.action_attempt,
|
|
3423
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3424
|
+
...this.defaults,
|
|
3425
|
+
waitForActionAttempt: false
|
|
3426
|
+
}),
|
|
3427
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3428
|
+
);
|
|
3429
|
+
}
|
|
3430
|
+
return data.action_attempt;
|
|
3329
3431
|
}
|
|
3330
3432
|
async get(body) {
|
|
3331
3433
|
const { data } = await this.client.request({
|
|
@@ -3335,19 +3437,43 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
|
3335
3437
|
});
|
|
3336
3438
|
return data.thermostat;
|
|
3337
3439
|
}
|
|
3338
|
-
async heat(body) {
|
|
3339
|
-
await this.client.request({
|
|
3440
|
+
async heat(body, options = {}) {
|
|
3441
|
+
const { data } = await this.client.request({
|
|
3340
3442
|
url: "/thermostats/heat",
|
|
3341
3443
|
method: "post",
|
|
3342
3444
|
data: body
|
|
3343
3445
|
});
|
|
3446
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3447
|
+
if (waitForActionAttempt !== false) {
|
|
3448
|
+
return await resolveActionAttempt(
|
|
3449
|
+
data.action_attempt,
|
|
3450
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3451
|
+
...this.defaults,
|
|
3452
|
+
waitForActionAttempt: false
|
|
3453
|
+
}),
|
|
3454
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3455
|
+
);
|
|
3456
|
+
}
|
|
3457
|
+
return data.action_attempt;
|
|
3344
3458
|
}
|
|
3345
|
-
async heatCool(body) {
|
|
3346
|
-
await this.client.request({
|
|
3459
|
+
async heatCool(body, options = {}) {
|
|
3460
|
+
const { data } = await this.client.request({
|
|
3347
3461
|
url: "/thermostats/heat_cool",
|
|
3348
3462
|
method: "post",
|
|
3349
3463
|
data: body
|
|
3350
3464
|
});
|
|
3465
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3466
|
+
if (waitForActionAttempt !== false) {
|
|
3467
|
+
return await resolveActionAttempt(
|
|
3468
|
+
data.action_attempt,
|
|
3469
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3470
|
+
...this.defaults,
|
|
3471
|
+
waitForActionAttempt: false
|
|
3472
|
+
}),
|
|
3473
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3474
|
+
);
|
|
3475
|
+
}
|
|
3476
|
+
return data.action_attempt;
|
|
3351
3477
|
}
|
|
3352
3478
|
async list(body) {
|
|
3353
3479
|
const { data } = await this.client.request({
|
|
@@ -3357,19 +3483,43 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
|
3357
3483
|
});
|
|
3358
3484
|
return data.thermostats;
|
|
3359
3485
|
}
|
|
3360
|
-
async off(body) {
|
|
3361
|
-
await this.client.request({
|
|
3486
|
+
async off(body, options = {}) {
|
|
3487
|
+
const { data } = await this.client.request({
|
|
3362
3488
|
url: "/thermostats/off",
|
|
3363
3489
|
method: "post",
|
|
3364
3490
|
data: body
|
|
3365
3491
|
});
|
|
3492
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3493
|
+
if (waitForActionAttempt !== false) {
|
|
3494
|
+
return await resolveActionAttempt(
|
|
3495
|
+
data.action_attempt,
|
|
3496
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3497
|
+
...this.defaults,
|
|
3498
|
+
waitForActionAttempt: false
|
|
3499
|
+
}),
|
|
3500
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3501
|
+
);
|
|
3502
|
+
}
|
|
3503
|
+
return data.action_attempt;
|
|
3366
3504
|
}
|
|
3367
|
-
async setFanMode(body) {
|
|
3368
|
-
await this.client.request({
|
|
3505
|
+
async setFanMode(body, options = {}) {
|
|
3506
|
+
const { data } = await this.client.request({
|
|
3369
3507
|
url: "/thermostats/set_fan_mode",
|
|
3370
3508
|
method: "post",
|
|
3371
3509
|
data: body
|
|
3372
3510
|
});
|
|
3511
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3512
|
+
if (waitForActionAttempt !== false) {
|
|
3513
|
+
return await resolveActionAttempt(
|
|
3514
|
+
data.action_attempt,
|
|
3515
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3516
|
+
...this.defaults,
|
|
3517
|
+
waitForActionAttempt: false
|
|
3518
|
+
}),
|
|
3519
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3520
|
+
);
|
|
3521
|
+
}
|
|
3522
|
+
return data.action_attempt;
|
|
3373
3523
|
}
|
|
3374
3524
|
async update(body) {
|
|
3375
3525
|
await this.client.request({
|
|
@@ -4106,6 +4256,7 @@ exports.SeamHttpNetworks = SeamHttpNetworks;
|
|
|
4106
4256
|
exports.SeamHttpNoiseSensors = SeamHttpNoiseSensors;
|
|
4107
4257
|
exports.SeamHttpNoiseSensorsNoiseThresholds = SeamHttpNoiseSensorsNoiseThresholds;
|
|
4108
4258
|
exports.SeamHttpPhones = SeamHttpPhones;
|
|
4259
|
+
exports.SeamHttpPhonesSimulate = SeamHttpPhonesSimulate;
|
|
4109
4260
|
exports.SeamHttpThermostats = SeamHttpThermostats;
|
|
4110
4261
|
exports.SeamHttpThermostatsClimateSettingSchedules = SeamHttpThermostatsClimateSettingSchedules;
|
|
4111
4262
|
exports.SeamHttpUnauthorizedError = SeamHttpUnauthorizedError;
|