@seamapi/http 1.6.0 → 1.8.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/dist/connect.cjs CHANGED
@@ -1847,15 +1847,6 @@ var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
1847
1847
  responseKey: "acs_entrances"
1848
1848
  });
1849
1849
  }
1850
- readCard(body, options = {}) {
1851
- return new SeamHttpRequest(this, {
1852
- path: "/acs/credentials/read_card",
1853
- method: "post",
1854
- body,
1855
- responseKey: "action_attempt",
1856
- options
1857
- });
1858
- }
1859
1850
  unassign(body) {
1860
1851
  return new SeamHttpRequest(this, {
1861
1852
  path: "/acs/credentials/unassign",
@@ -2456,6 +2447,111 @@ var SeamHttpAcs = class _SeamHttpAcs {
2456
2447
  }
2457
2448
  };
2458
2449
 
2450
+ // src/lib/seam/connect/routes/acs-encoders.ts
2451
+ var SeamHttpAcsEncoders = class _SeamHttpAcsEncoders {
2452
+ constructor(apiKeyOrOptions = {}) {
2453
+ const options = parseOptions(apiKeyOrOptions);
2454
+ this.client = "client" in options ? options.client : createClient(options);
2455
+ this.defaults = limitToSeamHttpRequestOptions(options);
2456
+ }
2457
+ static fromClient(client, options = {}) {
2458
+ const constructorOptions = { ...options, client };
2459
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
2460
+ throw new SeamHttpInvalidOptionsError("Missing client");
2461
+ }
2462
+ return new _SeamHttpAcsEncoders(constructorOptions);
2463
+ }
2464
+ static fromApiKey(apiKey, options = {}) {
2465
+ const constructorOptions = { ...options, apiKey };
2466
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
2467
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
2468
+ }
2469
+ return new _SeamHttpAcsEncoders(constructorOptions);
2470
+ }
2471
+ static fromClientSessionToken(clientSessionToken, options = {}) {
2472
+ const constructorOptions = { ...options, clientSessionToken };
2473
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
2474
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
2475
+ }
2476
+ return new _SeamHttpAcsEncoders(constructorOptions);
2477
+ }
2478
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
2479
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
2480
+ const clientOptions = parseOptions({ ...options, publishableKey });
2481
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
2482
+ throw new SeamHttpInvalidOptionsError(
2483
+ "The client option cannot be used with SeamHttp.fromPublishableKey"
2484
+ );
2485
+ }
2486
+ const client = createClient(clientOptions);
2487
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
2488
+ const { token } = await clientSessions.getOrCreate({
2489
+ user_identifier_key: userIdentifierKey
2490
+ });
2491
+ return _SeamHttpAcsEncoders.fromClientSessionToken(token, options);
2492
+ }
2493
+ static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
2494
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId };
2495
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
2496
+ throw new SeamHttpInvalidOptionsError(
2497
+ "Missing consoleSessionToken or workspaceId"
2498
+ );
2499
+ }
2500
+ return new _SeamHttpAcsEncoders(constructorOptions);
2501
+ }
2502
+ static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
2503
+ const constructorOptions = { ...options, personalAccessToken, workspaceId };
2504
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
2505
+ throw new SeamHttpInvalidOptionsError(
2506
+ "Missing personalAccessToken or workspaceId"
2507
+ );
2508
+ }
2509
+ return new _SeamHttpAcsEncoders(constructorOptions);
2510
+ }
2511
+ async updateClientSessionToken(clientSessionToken) {
2512
+ const { headers } = this.client.defaults;
2513
+ const authHeaders = getAuthHeadersForClientSessionToken({
2514
+ clientSessionToken
2515
+ });
2516
+ for (const key of Object.keys(authHeaders)) {
2517
+ if (headers[key] == null) {
2518
+ throw new Error(
2519
+ "Cannot update a clientSessionToken on a client created without a clientSessionToken"
2520
+ );
2521
+ }
2522
+ }
2523
+ this.client.defaults.headers = { ...headers, ...authHeaders };
2524
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client);
2525
+ await clientSessions.get();
2526
+ }
2527
+ encodeCard(body, options = {}) {
2528
+ return new SeamHttpRequest(this, {
2529
+ path: "/acs/encoders/encode_card",
2530
+ method: "post",
2531
+ body,
2532
+ responseKey: "action_attempt",
2533
+ options
2534
+ });
2535
+ }
2536
+ list(body) {
2537
+ return new SeamHttpRequest(this, {
2538
+ path: "/acs/encoders/list",
2539
+ method: "post",
2540
+ body,
2541
+ responseKey: "devices"
2542
+ });
2543
+ }
2544
+ readCard(body, options = {}) {
2545
+ return new SeamHttpRequest(this, {
2546
+ path: "/acs/encoders/read_card",
2547
+ method: "post",
2548
+ body,
2549
+ responseKey: "action_attempt",
2550
+ options
2551
+ });
2552
+ }
2553
+ };
2554
+
2459
2555
  // src/lib/seam/connect/routes/action-attempts.ts
2460
2556
  var SeamHttpActionAttempts = class _SeamHttpActionAttempts {
2461
2557
  constructor(apiKeyOrOptions = {}) {
@@ -2769,7 +2865,7 @@ var SeamHttpConnectedAccounts = class _SeamHttpConnectedAccounts {
2769
2865
  path: "/connected_accounts/update",
2770
2866
  method: "post",
2771
2867
  body,
2772
- responseKey: "connected_account"
2868
+ responseKey: void 0
2773
2869
  });
2774
2870
  }
2775
2871
  };
@@ -4120,7 +4216,7 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
4120
4216
  path: "/thermostats/create_climate_preset",
4121
4217
  method: "post",
4122
4218
  body,
4123
- responseKey: "climate_preset"
4219
+ responseKey: void 0
4124
4220
  });
4125
4221
  }
4126
4222
  deleteClimatePreset(body) {
@@ -4912,6 +5008,7 @@ exports.SeamHttpAcsCredentialPools = SeamHttpAcsCredentialPools;
4912
5008
  exports.SeamHttpAcsCredentialProvisioningAutomations = SeamHttpAcsCredentialProvisioningAutomations;
4913
5009
  exports.SeamHttpAcsCredentials = SeamHttpAcsCredentials;
4914
5010
  exports.SeamHttpAcsCredentialsUnmanaged = SeamHttpAcsCredentialsUnmanaged;
5011
+ exports.SeamHttpAcsEncoders = SeamHttpAcsEncoders;
4915
5012
  exports.SeamHttpAcsEntrances = SeamHttpAcsEntrances;
4916
5013
  exports.SeamHttpAcsSystems = SeamHttpAcsSystems;
4917
5014
  exports.SeamHttpAcsUsers = SeamHttpAcsUsers;