@linqapp/sdk 0.24.2 → 0.26.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 (98) hide show
  1. package/CHANGELOG.md +2 -506
  2. package/client.d.mts +165 -87
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +165 -87
  5. package/client.d.ts.map +1 -1
  6. package/client.js +162 -84
  7. package/client.js.map +1 -1
  8. package/client.mjs +162 -84
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/chats/chats.d.mts +67 -63
  12. package/resources/chats/chats.d.mts.map +1 -1
  13. package/resources/chats/chats.d.ts +67 -63
  14. package/resources/chats/chats.d.ts.map +1 -1
  15. package/resources/chats/chats.js +63 -59
  16. package/resources/chats/chats.js.map +1 -1
  17. package/resources/chats/chats.mjs +63 -59
  18. package/resources/chats/chats.mjs.map +1 -1
  19. package/resources/chats/index.d.mts +3 -2
  20. package/resources/chats/index.d.mts.map +1 -1
  21. package/resources/chats/index.d.ts +3 -2
  22. package/resources/chats/index.d.ts.map +1 -1
  23. package/resources/chats/index.js +3 -1
  24. package/resources/chats/index.js.map +1 -1
  25. package/resources/chats/index.mjs +1 -0
  26. package/resources/chats/index.mjs.map +1 -1
  27. package/resources/chats/location.d.mts +107 -0
  28. package/resources/chats/location.d.mts.map +1 -0
  29. package/resources/chats/location.d.ts +107 -0
  30. package/resources/chats/location.d.ts.map +1 -0
  31. package/resources/chats/location.js +68 -0
  32. package/resources/chats/location.js.map +1 -0
  33. package/resources/chats/location.mjs +64 -0
  34. package/resources/chats/location.mjs.map +1 -0
  35. package/resources/chats/messages.d.mts +17 -17
  36. package/resources/chats/messages.d.mts.map +1 -1
  37. package/resources/chats/messages.d.ts +17 -17
  38. package/resources/chats/messages.d.ts.map +1 -1
  39. package/resources/chats/messages.js +16 -16
  40. package/resources/chats/messages.js.map +1 -1
  41. package/resources/chats/messages.mjs +16 -16
  42. package/resources/chats/messages.mjs.map +1 -1
  43. package/resources/contact-card.d.mts +18 -18
  44. package/resources/contact-card.d.mts.map +1 -1
  45. package/resources/contact-card.d.ts +18 -18
  46. package/resources/contact-card.d.ts.map +1 -1
  47. package/resources/contact-card.js +12 -12
  48. package/resources/contact-card.js.map +1 -1
  49. package/resources/contact-card.mjs +12 -12
  50. package/resources/contact-card.mjs.map +1 -1
  51. package/resources/index.d.mts +3 -3
  52. package/resources/index.d.mts.map +1 -1
  53. package/resources/index.d.ts +3 -3
  54. package/resources/index.d.ts.map +1 -1
  55. package/resources/messages.d.mts +34 -34
  56. package/resources/messages.d.mts.map +1 -1
  57. package/resources/messages.d.ts +34 -34
  58. package/resources/messages.d.ts.map +1 -1
  59. package/resources/messages.js +29 -29
  60. package/resources/messages.js.map +1 -1
  61. package/resources/messages.mjs +29 -29
  62. package/resources/messages.mjs.map +1 -1
  63. package/resources/webhook-events.d.mts +83 -44
  64. package/resources/webhook-events.d.mts.map +1 -1
  65. package/resources/webhook-events.d.ts +83 -44
  66. package/resources/webhook-events.d.ts.map +1 -1
  67. package/resources/webhook-events.js +81 -42
  68. package/resources/webhook-events.js.map +1 -1
  69. package/resources/webhook-events.mjs +81 -42
  70. package/resources/webhook-events.mjs.map +1 -1
  71. package/resources/webhook-subscriptions.d.mts +100 -55
  72. package/resources/webhook-subscriptions.d.mts.map +1 -1
  73. package/resources/webhook-subscriptions.d.ts +100 -55
  74. package/resources/webhook-subscriptions.d.ts.map +1 -1
  75. package/resources/webhook-subscriptions.js +103 -58
  76. package/resources/webhook-subscriptions.js.map +1 -1
  77. package/resources/webhook-subscriptions.mjs +103 -58
  78. package/resources/webhook-subscriptions.mjs.map +1 -1
  79. package/resources/webhooks.d.mts +4 -4
  80. package/resources/webhooks.d.mts.map +1 -1
  81. package/resources/webhooks.d.ts +4 -4
  82. package/resources/webhooks.d.ts.map +1 -1
  83. package/src/client.ts +166 -88
  84. package/src/resources/chats/chats.ts +88 -78
  85. package/src/resources/chats/index.ts +3 -2
  86. package/src/resources/chats/location.ts +138 -0
  87. package/src/resources/chats/messages.ts +28 -28
  88. package/src/resources/contact-card.ts +25 -25
  89. package/src/resources/index.ts +4 -4
  90. package/src/resources/messages.ts +46 -46
  91. package/src/resources/webhook-events.ts +85 -44
  92. package/src/resources/webhook-subscriptions.ts +103 -58
  93. package/src/resources/webhooks.ts +6 -4
  94. package/src/version.ts +1 -1
  95. package/version.d.mts +1 -1
  96. package/version.d.ts +1 -1
  97. package/version.js +1 -1
  98. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -1093,55 +1093,82 @@ export class LinqAPIV3 {
1093
1093
  *
1094
1094
  * ## Webhook Headers
1095
1095
  *
1096
- * Each webhook request includes the following headers:
1096
+ * All webhook requests include two sets of headers. **If you have an existing integration
1097
+ * using the `X-Webhook-*` headers, nothing changes** — those headers are still sent on
1098
+ * every delivery and work exactly as before. The new `webhook-*` headers follow the
1099
+ * [Standard Webhooks](https://github.com/standard-webhooks/standard-webhooks) specification.
1100
+ * You can safely ignore them if your current verification code works and you don't want to use this convention.
1101
+ *
1102
+ * ### Standard Webhooks Headers (Recommended)
1103
+ *
1104
+ * Used by [our SDK](https://github.com/linq-team/linq-node) and any [Standard Webhooks library](https://github.com/standard-webhooks/standard-webhooks).
1097
1105
  *
1098
1106
  * | Header | Description |
1099
1107
  * |--------|-------------|
1100
- * | `X-Webhook-Event` | The event type (e.g., `message.sent`, `message.received`) |
1101
- * | `X-Webhook-Subscription-ID` | Your webhook subscription ID |
1102
- * | `X-Webhook-Timestamp` | Unix timestamp (seconds) when the webhook was sent |
1103
- * | `X-Webhook-Signature` | HMAC-SHA256 signature for verification |
1108
+ * | `webhook-id` | Unique event identifier (use as idempotency key) |
1109
+ * | `webhook-timestamp` | Unix timestamp (seconds) when the webhook was sent |
1110
+ * | `webhook-signature` | Standard Webhooks signature (`v1,{base64}` format) |
1104
1111
  *
1105
- * ## Verifying Webhook Signatures
1112
+ * ### Legacy Headers (Deprecated)
1113
+ *
1114
+ * Still sent on every delivery for backwards compatibility. Existing verification code
1115
+ * using these headers continues to work — no changes required.
1116
+ *
1117
+ * | Header | Description |
1118
+ * |--------|-------------|
1119
+ * | `X-Webhook-Event` | *(deprecated)* Event type (e.g., `message.sent`) |
1120
+ * | `X-Webhook-Subscription-ID` | *(deprecated)* Webhook subscription ID |
1121
+ * | `X-Webhook-Timestamp` | *(deprecated)* Unix timestamp (seconds) |
1122
+ * | `X-Webhook-Signature` | *(deprecated)* HMAC-SHA256 signature (hex-encoded) |
1106
1123
  *
1107
- * All webhooks are signed using HMAC-SHA256. You should always verify the signature
1108
- * to ensure the webhook originated from Linq and hasn't been tampered with.
1124
+ * ## Signing Secrets
1109
1125
  *
1110
- * **Signature Construction:**
1126
+ * Signing secrets use the Standard Webhooks format: a `whsec_` prefix followed
1127
+ * by base64-encoded random bytes (e.g., `whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw7Jxx2Oll+OE=`).
1111
1128
  *
1112
- * The signature is computed over a concatenation of the timestamp and payload:
1129
+ * Strip the `whsec_` prefix and base64-decode the remainder to get the raw key bytes.
1113
1130
  *
1114
- * ```
1115
- * {timestamp}.{payload}
1116
- * ```
1131
+ * ## Verifying Webhook Signatures
1117
1132
  *
1118
- * Where:
1119
- * - `timestamp` is the value from the `X-Webhook-Timestamp` header
1120
- * - `payload` is the raw JSON request body (exact bytes, not re-serialized)
1133
+ * Webhooks are signed following the [Standard Webhooks specification](https://github.com/standard-webhooks/standard-webhooks).
1134
+ * You can use any [Standard Webhooks library](https://github.com/standard-webhooks/standard-webhooks) to verify
1135
+ * signatures, or implement verification manually:
1136
+ *
1137
+ * **Signed content:** `{webhook-id}.{webhook-timestamp}.{body}`
1121
1138
  *
1122
1139
  * **Verification Steps:**
1123
1140
  *
1124
- * 1. Extract the `X-Webhook-Timestamp` and `X-Webhook-Signature` headers
1125
- * 2. Get the raw request body bytes (do not parse and re-serialize)
1126
- * 3. Concatenate: `"{timestamp}.{payload}"`
1127
- * 4. Compute HMAC-SHA256 using your signing secret as the key
1128
- * 5. Hex-encode the result and compare with `X-Webhook-Signature`
1129
- * 6. Use constant-time comparison to prevent timing attacks
1141
+ * 1. Extract the `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers
1142
+ * 2. Reject if the timestamp is more than 5 minutes old (replay protection)
1143
+ * 3. Get the raw request body bytes (do not parse and re-serialize)
1144
+ * 4. Construct signed content: `"{webhook-id}.{webhook-timestamp}.{body}"`
1145
+ * 5. Strip the `whsec_` prefix from your secret and base64-decode to get key bytes
1146
+ * 6. Compute HMAC-SHA256 using the key bytes over the signed content
1147
+ * 7. Base64-encode the result and compare with the value after `v1,` in `webhook-signature`
1148
+ * 8. Use constant-time comparison to prevent timing attacks
1130
1149
  *
1131
1150
  * **Example (Python):**
1132
1151
  *
1133
1152
  * ```python
1134
- * import hmac
1135
- * import hashlib
1136
- *
1137
- * def verify_webhook(signing_secret, payload, timestamp, signature):
1138
- * message = f"{timestamp}.{payload.decode('utf-8')}"
1139
- * expected = hmac.new(
1140
- * signing_secret.encode('utf-8'),
1141
- * message.encode('utf-8'),
1142
- * hashlib.sha256
1143
- * ).hexdigest()
1144
- * return hmac.compare_digest(expected, signature)
1153
+ * import base64, hmac, hashlib
1154
+ *
1155
+ * def verify_webhook(secret, body, headers):
1156
+ * msg_id = headers['webhook-id']
1157
+ * timestamp = headers['webhook-timestamp']
1158
+ * signature = headers['webhook-signature']
1159
+ *
1160
+ * secret_str = secret.removeprefix('whsec_')
1161
+ * key = base64.b64decode(secret_str)
1162
+ *
1163
+ * signed_content = f"{msg_id}.{timestamp}.{body}"
1164
+ * expected = base64.b64encode(
1165
+ * hmac.new(key, signed_content.encode(), hashlib.sha256).digest()
1166
+ * ).decode()
1167
+ *
1168
+ * for sig in signature.split(' '):
1169
+ * if sig.startswith('v1,') and hmac.compare_digest(expected, sig[3:]):
1170
+ * return True
1171
+ * return False
1145
1172
  * ```
1146
1173
  *
1147
1174
  * **Example (Node.js):**
@@ -1149,16 +1176,28 @@ export class LinqAPIV3 {
1149
1176
  * ```javascript
1150
1177
  * const crypto = require('crypto');
1151
1178
  *
1152
- * function verifyWebhook(signingSecret, payload, timestamp, signature) {
1153
- * const message = `${timestamp}.${payload}`;
1179
+ * function verifyWebhook(secret, rawBody, headers) {
1180
+ * const msgId = headers['webhook-id'];
1181
+ * const timestamp = headers['webhook-timestamp'];
1182
+ * const signature = headers['webhook-signature'];
1183
+ *
1184
+ * const secretStr = secret.startsWith('whsec_') ? secret.slice(6) : secret;
1185
+ * const keyBytes = Buffer.from(secretStr, 'base64');
1186
+ * const signedContent = `${msgId}.${timestamp}.${rawBody}`;
1154
1187
  * const expected = crypto
1155
- * .createHmac('sha256', signingSecret)
1156
- * .update(message)
1157
- * .digest('hex');
1158
- * return crypto.timingSafeEqual(
1159
- * Buffer.from(expected),
1160
- * Buffer.from(signature)
1161
- * );
1188
+ * .createHmac('sha256', keyBytes)
1189
+ * .update(signedContent)
1190
+ * .digest('base64');
1191
+ *
1192
+ * return signature.split(' ').some(sig => {
1193
+ * if (!sig.startsWith('v1,')) return false;
1194
+ * try {
1195
+ * return crypto.timingSafeEqual(
1196
+ * Buffer.from(expected, 'base64'),
1197
+ * Buffer.from(sig.slice(3), 'base64')
1198
+ * );
1199
+ * } catch { return false; }
1200
+ * });
1162
1201
  * }
1163
1202
  * ```
1164
1203
  *
@@ -1184,55 +1223,82 @@ export class LinqAPIV3 {
1184
1223
  *
1185
1224
  * ## Webhook Headers
1186
1225
  *
1187
- * Each webhook request includes the following headers:
1226
+ * All webhook requests include two sets of headers. **If you have an existing integration
1227
+ * using the `X-Webhook-*` headers, nothing changes** — those headers are still sent on
1228
+ * every delivery and work exactly as before. The new `webhook-*` headers follow the
1229
+ * [Standard Webhooks](https://github.com/standard-webhooks/standard-webhooks) specification.
1230
+ * You can safely ignore them if your current verification code works and you don't want to use this convention.
1231
+ *
1232
+ * ### Standard Webhooks Headers (Recommended)
1233
+ *
1234
+ * Used by [our SDK](https://github.com/linq-team/linq-node) and any [Standard Webhooks library](https://github.com/standard-webhooks/standard-webhooks).
1188
1235
  *
1189
1236
  * | Header | Description |
1190
1237
  * |--------|-------------|
1191
- * | `X-Webhook-Event` | The event type (e.g., `message.sent`, `message.received`) |
1192
- * | `X-Webhook-Subscription-ID` | Your webhook subscription ID |
1193
- * | `X-Webhook-Timestamp` | Unix timestamp (seconds) when the webhook was sent |
1194
- * | `X-Webhook-Signature` | HMAC-SHA256 signature for verification |
1238
+ * | `webhook-id` | Unique event identifier (use as idempotency key) |
1239
+ * | `webhook-timestamp` | Unix timestamp (seconds) when the webhook was sent |
1240
+ * | `webhook-signature` | Standard Webhooks signature (`v1,{base64}` format) |
1195
1241
  *
1196
- * ## Verifying Webhook Signatures
1242
+ * ### Legacy Headers (Deprecated)
1243
+ *
1244
+ * Still sent on every delivery for backwards compatibility. Existing verification code
1245
+ * using these headers continues to work — no changes required.
1197
1246
  *
1198
- * All webhooks are signed using HMAC-SHA256. You should always verify the signature
1199
- * to ensure the webhook originated from Linq and hasn't been tampered with.
1247
+ * | Header | Description |
1248
+ * |--------|-------------|
1249
+ * | `X-Webhook-Event` | *(deprecated)* Event type (e.g., `message.sent`) |
1250
+ * | `X-Webhook-Subscription-ID` | *(deprecated)* Webhook subscription ID |
1251
+ * | `X-Webhook-Timestamp` | *(deprecated)* Unix timestamp (seconds) |
1252
+ * | `X-Webhook-Signature` | *(deprecated)* HMAC-SHA256 signature (hex-encoded) |
1200
1253
  *
1201
- * **Signature Construction:**
1254
+ * ## Signing Secrets
1202
1255
  *
1203
- * The signature is computed over a concatenation of the timestamp and payload:
1256
+ * Signing secrets use the Standard Webhooks format: a `whsec_` prefix followed
1257
+ * by base64-encoded random bytes (e.g., `whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw7Jxx2Oll+OE=`).
1204
1258
  *
1205
- * ```
1206
- * {timestamp}.{payload}
1207
- * ```
1259
+ * Strip the `whsec_` prefix and base64-decode the remainder to get the raw key bytes.
1260
+ *
1261
+ * ## Verifying Webhook Signatures
1262
+ *
1263
+ * Webhooks are signed following the [Standard Webhooks specification](https://github.com/standard-webhooks/standard-webhooks).
1264
+ * You can use any [Standard Webhooks library](https://github.com/standard-webhooks/standard-webhooks) to verify
1265
+ * signatures, or implement verification manually:
1208
1266
  *
1209
- * Where:
1210
- * - `timestamp` is the value from the `X-Webhook-Timestamp` header
1211
- * - `payload` is the raw JSON request body (exact bytes, not re-serialized)
1267
+ * **Signed content:** `{webhook-id}.{webhook-timestamp}.{body}`
1212
1268
  *
1213
1269
  * **Verification Steps:**
1214
1270
  *
1215
- * 1. Extract the `X-Webhook-Timestamp` and `X-Webhook-Signature` headers
1216
- * 2. Get the raw request body bytes (do not parse and re-serialize)
1217
- * 3. Concatenate: `"{timestamp}.{payload}"`
1218
- * 4. Compute HMAC-SHA256 using your signing secret as the key
1219
- * 5. Hex-encode the result and compare with `X-Webhook-Signature`
1220
- * 6. Use constant-time comparison to prevent timing attacks
1271
+ * 1. Extract the `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers
1272
+ * 2. Reject if the timestamp is more than 5 minutes old (replay protection)
1273
+ * 3. Get the raw request body bytes (do not parse and re-serialize)
1274
+ * 4. Construct signed content: `"{webhook-id}.{webhook-timestamp}.{body}"`
1275
+ * 5. Strip the `whsec_` prefix from your secret and base64-decode to get key bytes
1276
+ * 6. Compute HMAC-SHA256 using the key bytes over the signed content
1277
+ * 7. Base64-encode the result and compare with the value after `v1,` in `webhook-signature`
1278
+ * 8. Use constant-time comparison to prevent timing attacks
1221
1279
  *
1222
1280
  * **Example (Python):**
1223
1281
  *
1224
1282
  * ```python
1225
- * import hmac
1226
- * import hashlib
1227
- *
1228
- * def verify_webhook(signing_secret, payload, timestamp, signature):
1229
- * message = f"{timestamp}.{payload.decode('utf-8')}"
1230
- * expected = hmac.new(
1231
- * signing_secret.encode('utf-8'),
1232
- * message.encode('utf-8'),
1233
- * hashlib.sha256
1234
- * ).hexdigest()
1235
- * return hmac.compare_digest(expected, signature)
1283
+ * import base64, hmac, hashlib
1284
+ *
1285
+ * def verify_webhook(secret, body, headers):
1286
+ * msg_id = headers['webhook-id']
1287
+ * timestamp = headers['webhook-timestamp']
1288
+ * signature = headers['webhook-signature']
1289
+ *
1290
+ * secret_str = secret.removeprefix('whsec_')
1291
+ * key = base64.b64decode(secret_str)
1292
+ *
1293
+ * signed_content = f"{msg_id}.{timestamp}.{body}"
1294
+ * expected = base64.b64encode(
1295
+ * hmac.new(key, signed_content.encode(), hashlib.sha256).digest()
1296
+ * ).decode()
1297
+ *
1298
+ * for sig in signature.split(' '):
1299
+ * if sig.startswith('v1,') and hmac.compare_digest(expected, sig[3:]):
1300
+ * return True
1301
+ * return False
1236
1302
  * ```
1237
1303
  *
1238
1304
  * **Example (Node.js):**
@@ -1240,16 +1306,28 @@ export class LinqAPIV3 {
1240
1306
  * ```javascript
1241
1307
  * const crypto = require('crypto');
1242
1308
  *
1243
- * function verifyWebhook(signingSecret, payload, timestamp, signature) {
1244
- * const message = `${timestamp}.${payload}`;
1309
+ * function verifyWebhook(secret, rawBody, headers) {
1310
+ * const msgId = headers['webhook-id'];
1311
+ * const timestamp = headers['webhook-timestamp'];
1312
+ * const signature = headers['webhook-signature'];
1313
+ *
1314
+ * const secretStr = secret.startsWith('whsec_') ? secret.slice(6) : secret;
1315
+ * const keyBytes = Buffer.from(secretStr, 'base64');
1316
+ * const signedContent = `${msgId}.${timestamp}.${rawBody}`;
1245
1317
  * const expected = crypto
1246
- * .createHmac('sha256', signingSecret)
1247
- * .update(message)
1248
- * .digest('hex');
1249
- * return crypto.timingSafeEqual(
1250
- * Buffer.from(expected),
1251
- * Buffer.from(signature)
1252
- * );
1318
+ * .createHmac('sha256', keyBytes)
1319
+ * .update(signedContent)
1320
+ * .digest('base64');
1321
+ *
1322
+ * return signature.split(' ').some(sig => {
1323
+ * if (!sig.startsWith('v1,')) return false;
1324
+ * try {
1325
+ * return crypto.timingSafeEqual(
1326
+ * Buffer.from(expected, 'base64'),
1327
+ * Buffer.from(sig.slice(3), 'base64')
1328
+ * );
1329
+ * } catch { return false; }
1330
+ * });
1253
1331
  * }
1254
1332
  * ```
1255
1333
  *
@@ -1320,8 +1398,8 @@ export declare namespace LinqAPIV3 {
1320
1398
  type ChatSendVoicememoResponse as ChatSendVoicememoResponse,
1321
1399
  type ChatsListChatsPagination as ChatsListChatsPagination,
1322
1400
  type ChatCreateParams as ChatCreateParams,
1323
- type ChatUpdateParams as ChatUpdateParams,
1324
1401
  type ChatListChatsParams as ChatListChatsParams,
1402
+ type ChatUpdateParams as ChatUpdateParams,
1325
1403
  type ChatSendVoicememoParams as ChatSendVoicememoParams,
1326
1404
  };
1327
1405
 
@@ -1332,9 +1410,9 @@ export declare namespace LinqAPIV3 {
1332
1410
  type ReplyTo as ReplyTo,
1333
1411
  type MessageAddReactionResponse as MessageAddReactionResponse,
1334
1412
  type MessagesListMessagesPagination as MessagesListMessagesPagination,
1335
- type MessageUpdateParams as MessageUpdateParams,
1336
- type MessageAddReactionParams as MessageAddReactionParams,
1337
1413
  type MessageListMessagesThreadParams as MessageListMessagesThreadParams,
1414
+ type MessageAddReactionParams as MessageAddReactionParams,
1415
+ type MessageUpdateParams as MessageUpdateParams,
1338
1416
  };
1339
1417
 
1340
1418
  export {
@@ -1405,8 +1483,8 @@ export declare namespace LinqAPIV3 {
1405
1483
  ContactCard as ContactCard,
1406
1484
  type SetContactCard as SetContactCard,
1407
1485
  type ContactCardRetrieveResponse as ContactCardRetrieveResponse,
1408
- type ContactCardCreateParams as ContactCardCreateParams,
1409
1486
  type ContactCardRetrieveParams as ContactCardRetrieveParams,
1487
+ type ContactCardCreateParams as ContactCardCreateParams,
1410
1488
  type ContactCardUpdateParams as ContactCardUpdateParams,
1411
1489
  };
1412
1490
 
@@ -3,6 +3,8 @@
3
3
  import { APIResource } from '../../core/resource';
4
4
  import * as MessagesAPI from '../messages';
5
5
  import * as Shared from '../shared';
6
+ import * as LocationAPI from './location';
7
+ import { GetChatLocationResponse, Location, LocationRequestResponse } from './location';
6
8
  import * as ChatsMessagesAPI from './messages';
7
9
  import { MessageListParams, MessageSendParams, MessageSendResponse, Messages, SentMessage } from './messages';
8
10
  import * as ParticipantsAPI from './participants';
@@ -25,6 +27,7 @@ export class Chats extends APIResource {
25
27
  participants: ParticipantsAPI.Participants = new ParticipantsAPI.Participants(this._client);
26
28
  typing: TypingAPI.Typing = new TypingAPI.Typing(this._client);
27
29
  messages: ChatsMessagesAPI.Messages = new ChatsMessagesAPI.Messages(this._client);
30
+ location: LocationAPI.Location = new LocationAPI.Location(this._client);
28
31
 
29
32
  /**
30
33
  * Create a new chat with specified participants and send an initial message. The
@@ -101,6 +104,46 @@ export class Chats extends APIResource {
101
104
  return this._client.post('/v3/chats', { body, ...options });
102
105
  }
103
106
 
107
+ /**
108
+ * Retrieves a paginated list of chats for the authenticated partner.
109
+ *
110
+ * **Filtering:**
111
+ *
112
+ * - If `from` is provided, returns chats for that specific phone number
113
+ * - If `from` is omitted, returns chats across all phone numbers owned by the
114
+ * partner
115
+ * - If `to` is provided, only returns chats where the specified handle is a
116
+ * participant
117
+ *
118
+ * **Pagination:**
119
+ *
120
+ * - Use `limit` to control page size (default: 20, max: 100)
121
+ * - The response includes `next_cursor` for fetching the next page
122
+ * - When `next_cursor` is `null`, there are no more results to fetch
123
+ * - Pass the `next_cursor` value as the `cursor` parameter for the next request
124
+ *
125
+ * **Example pagination flow:**
126
+ *
127
+ * 1. First request: `GET /v3/chats?from=%2B12223334444&limit=20`
128
+ * 2. Response includes `next_cursor: "20"` (more results exist)
129
+ * 3. Next request: `GET /v3/chats?from=%2B12223334444&limit=20&cursor=20`
130
+ * 4. Response includes `next_cursor: null` (no more results)
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * // Automatically fetches more pages as needed.
135
+ * for await (const chat of client.chats.listChats()) {
136
+ * // ...
137
+ * }
138
+ * ```
139
+ */
140
+ listChats(
141
+ query: ChatListChatsParams | null | undefined = {},
142
+ options?: RequestOptions,
143
+ ): PagePromise<ChatsListChatsPagination, Chat> {
144
+ return this._client.getAPIList('/v3/chats', ListChatsPagination<Chat>, { query, ...options });
145
+ }
146
+
104
147
  /**
105
148
  * Retrieve a chat by its unique identifier.
106
149
  *
@@ -134,6 +177,23 @@ export class Chats extends APIResource {
134
177
  return this._client.put(path`/v3/chats/${chatID}`, { body, ...options });
135
178
  }
136
179
 
180
+ /**
181
+ * Mark all messages in a chat as read.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * await client.chats.markAsRead(
186
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
187
+ * );
188
+ * ```
189
+ */
190
+ markAsRead(chatID: string, options?: RequestOptions): APIPromise<void> {
191
+ return this._client.post(path`/v3/chats/${chatID}/read`, {
192
+ ...options,
193
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
194
+ });
195
+ }
196
+
137
197
  /**
138
198
  * Removes your phone number from a group chat. Once you leave, you will no longer
139
199
  * receive messages from the group and all interaction endpoints (send message,
@@ -161,57 +221,21 @@ export class Chats extends APIResource {
161
221
  }
162
222
 
163
223
  /**
164
- * Retrieves a paginated list of chats for the authenticated partner.
165
- *
166
- * **Filtering:**
167
- *
168
- * - If `from` is provided, returns chats for that specific phone number
169
- * - If `from` is omitted, returns chats across all phone numbers owned by the
170
- * partner
171
- * - If `to` is provided, only returns chats where the specified handle is a
172
- * participant
173
- *
174
- * **Pagination:**
175
- *
176
- * - Use `limit` to control page size (default: 20, max: 100)
177
- * - The response includes `next_cursor` for fetching the next page
178
- * - When `next_cursor` is `null`, there are no more results to fetch
179
- * - Pass the `next_cursor` value as the `cursor` parameter for the next request
180
- *
181
- * **Example pagination flow:**
182
- *
183
- * 1. First request: `GET /v3/chats?from=%2B12223334444&limit=20`
184
- * 2. Response includes `next_cursor: "20"` (more results exist)
185
- * 3. Next request: `GET /v3/chats?from=%2B12223334444&limit=20&cursor=20`
186
- * 4. Response includes `next_cursor: null` (no more results)
224
+ * Share your contact information (Name and Photo Sharing) with a chat.
187
225
  *
188
- * @example
189
- * ```ts
190
- * // Automatically fetches more pages as needed.
191
- * for await (const chat of client.chats.listChats()) {
192
- * // ...
193
- * }
194
- * ```
195
- */
196
- listChats(
197
- query: ChatListChatsParams | null | undefined = {},
198
- options?: RequestOptions,
199
- ): PagePromise<ChatsListChatsPagination, Chat> {
200
- return this._client.getAPIList('/v3/chats', ListChatsPagination<Chat>, { query, ...options });
201
- }
202
-
203
- /**
204
- * Mark all messages in a chat as read.
226
+ * **Note:** A contact card must be configured before sharing. You can set up your
227
+ * contact card via the [Contact Card API](#tag/Contact-Card) or on the
228
+ * [Linq dashboard](https://dashboard.linqapp.com/contact-cards).
205
229
  *
206
230
  * @example
207
231
  * ```ts
208
- * await client.chats.markAsRead(
232
+ * await client.chats.shareContactCard(
209
233
  * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
210
234
  * );
211
235
  * ```
212
236
  */
213
- markAsRead(chatID: string, options?: RequestOptions): APIPromise<void> {
214
- return this._client.post(path`/v3/chats/${chatID}/read`, {
237
+ shareContactCard(chatID: string, options?: RequestOptions): APIPromise<void> {
238
+ return this._client.post(path`/v3/chats/${chatID}/share_contact_card`, {
215
239
  ...options,
216
240
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
217
241
  });
@@ -248,27 +272,6 @@ export class Chats extends APIResource {
248
272
  ): APIPromise<ChatSendVoicememoResponse> {
249
273
  return this._client.post(path`/v3/chats/${chatID}/voicememo`, { body, ...options });
250
274
  }
251
-
252
- /**
253
- * Share your contact information (Name and Photo Sharing) with a chat.
254
- *
255
- * **Note:** A contact card must be configured before sharing. You can set up your
256
- * contact card via the [Contact Card API](#tag/Contact-Card) or on the
257
- * [Linq dashboard](https://dashboard.linqapp.com/contact-cards).
258
- *
259
- * @example
260
- * ```ts
261
- * await client.chats.shareContactCard(
262
- * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
263
- * );
264
- * ```
265
- */
266
- shareContactCard(chatID: string, options?: RequestOptions): APIPromise<void> {
267
- return this._client.post(path`/v3/chats/${chatID}/share_contact_card`, {
268
- ...options,
269
- headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
270
- });
271
- }
272
275
  }
273
276
 
274
277
  export type ChatsListChatsPagination = ListChatsPagination<Chat>;
@@ -767,18 +770,6 @@ export interface ChatCreateParams {
767
770
  to: Array<string>;
768
771
  }
769
772
 
770
- export interface ChatUpdateParams {
771
- /**
772
- * New display name for the chat (group chats only)
773
- */
774
- display_name?: string;
775
-
776
- /**
777
- * URL of an image to set as the group chat icon (group chats only)
778
- */
779
- group_chat_icon?: string;
780
- }
781
-
782
773
  export interface ChatListChatsParams extends ListChatsPaginationParams {
783
774
  /**
784
775
  * Phone number to filter chats by. Returns chats made from this phone number. Must
@@ -797,6 +788,18 @@ export interface ChatListChatsParams extends ListChatsPaginationParams {
797
788
  to?: string;
798
789
  }
799
790
 
791
+ export interface ChatUpdateParams {
792
+ /**
793
+ * New display name for the chat (group chats only)
794
+ */
795
+ display_name?: string;
796
+
797
+ /**
798
+ * URL of an image to set as the group chat icon (group chats only)
799
+ */
800
+ group_chat_icon?: string;
801
+ }
802
+
800
803
  export interface ChatSendVoicememoParams {
801
804
  /**
802
805
  * Reference to a voice memo file pre-uploaded via `POST /v3/attachments`. The file
@@ -817,6 +820,7 @@ export interface ChatSendVoicememoParams {
817
820
  Chats.Participants = Participants;
818
821
  Chats.Typing = Typing;
819
822
  Chats.Messages = Messages;
823
+ Chats.Location = Location;
820
824
 
821
825
  export declare namespace Chats {
822
826
  export {
@@ -831,8 +835,8 @@ export declare namespace Chats {
831
835
  type ChatSendVoicememoResponse as ChatSendVoicememoResponse,
832
836
  type ChatsListChatsPagination as ChatsListChatsPagination,
833
837
  type ChatCreateParams as ChatCreateParams,
834
- type ChatUpdateParams as ChatUpdateParams,
835
838
  type ChatListChatsParams as ChatListChatsParams,
839
+ type ChatUpdateParams as ChatUpdateParams,
836
840
  type ChatSendVoicememoParams as ChatSendVoicememoParams,
837
841
  };
838
842
 
@@ -850,7 +854,13 @@ export declare namespace Chats {
850
854
  Messages as Messages,
851
855
  type SentMessage as SentMessage,
852
856
  type MessageSendResponse as MessageSendResponse,
853
- type MessageListParams as MessageListParams,
854
857
  type MessageSendParams as MessageSendParams,
858
+ type MessageListParams as MessageListParams,
859
+ };
860
+
861
+ export {
862
+ Location as Location,
863
+ type GetChatLocationResponse as GetChatLocationResponse,
864
+ type LocationRequestResponse as LocationRequestResponse,
855
865
  };
856
866
  }
@@ -12,17 +12,18 @@ export {
12
12
  type ChatLeaveChatResponse,
13
13
  type ChatSendVoicememoResponse,
14
14
  type ChatCreateParams,
15
- type ChatUpdateParams,
16
15
  type ChatListChatsParams,
16
+ type ChatUpdateParams,
17
17
  type ChatSendVoicememoParams,
18
18
  type ChatsListChatsPagination,
19
19
  } from './chats';
20
+ export { Location, type GetChatLocationResponse, type LocationRequestResponse } from './location';
20
21
  export {
21
22
  Messages,
22
23
  type SentMessage,
23
24
  type MessageSendResponse,
24
- type MessageListParams,
25
25
  type MessageSendParams,
26
+ type MessageListParams,
26
27
  } from './messages';
27
28
  export {
28
29
  Participants,