agentphone 1.0.2 → 1.0.3

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 (158) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/Client.d.ts +6 -0
  3. package/dist/cjs/Client.js +18 -8
  4. package/dist/cjs/api/resources/agentWebhooks/client/Client.d.ts +1 -1
  5. package/dist/cjs/api/resources/agentWebhooks/client/Client.js +1 -1
  6. package/dist/cjs/api/resources/agents/client/Client.d.ts +20 -2
  7. package/dist/cjs/api/resources/agents/client/Client.js +56 -2
  8. package/dist/cjs/api/resources/agents/client/requests/CreateAgentRequest.d.ts +1 -0
  9. package/dist/cjs/api/resources/agents/client/requests/DetachNumberFromAgentV1AgentsAgentIdNumbersNumberIdDeleteRequest.d.ts +11 -0
  10. package/dist/cjs/api/resources/agents/client/requests/DetachNumberFromAgentV1AgentsAgentIdNumbersNumberIdDeleteRequest.js +3 -0
  11. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +1 -0
  12. package/dist/cjs/api/resources/agents/client/requests/index.d.ts +1 -0
  13. package/dist/cjs/api/resources/calls/client/Client.d.ts +27 -3
  14. package/dist/cjs/api/resources/calls/client/Client.js +68 -4
  15. package/dist/cjs/api/resources/calls/client/requests/ListCallsV1CallsGetRequest.d.ts +8 -0
  16. package/dist/cjs/api/resources/calls/client/requests/StreamCallTranscriptV1CallsCallIdTranscriptStreamGetRequest.d.ts +9 -0
  17. package/dist/cjs/api/resources/calls/client/requests/StreamCallTranscriptV1CallsCallIdTranscriptStreamGetRequest.js +3 -0
  18. package/dist/cjs/api/resources/calls/client/requests/index.d.ts +1 -0
  19. package/dist/cjs/api/resources/contacts/client/Client.d.ts +94 -0
  20. package/dist/cjs/api/resources/contacts/client/Client.js +341 -0
  21. package/dist/cjs/api/resources/contacts/client/index.d.ts +1 -0
  22. package/dist/cjs/api/resources/contacts/client/index.js +17 -0
  23. package/dist/cjs/api/resources/contacts/client/requests/CreateContactRequest.d.ts +13 -0
  24. package/dist/cjs/api/resources/contacts/client/requests/CreateContactRequest.js +3 -0
  25. package/dist/cjs/api/resources/contacts/client/requests/DeleteContactV1ContactsContactIdDeleteRequest.d.ts +9 -0
  26. package/dist/cjs/api/resources/contacts/client/requests/DeleteContactV1ContactsContactIdDeleteRequest.js +3 -0
  27. package/dist/cjs/api/resources/contacts/client/requests/GetContactV1ContactsContactIdGetRequest.d.ts +9 -0
  28. package/dist/cjs/api/resources/contacts/client/requests/GetContactV1ContactsContactIdGetRequest.js +3 -0
  29. package/dist/cjs/api/resources/contacts/client/requests/ListContactsV1ContactsGetRequest.d.ts +9 -0
  30. package/dist/cjs/api/resources/contacts/client/requests/ListContactsV1ContactsGetRequest.js +3 -0
  31. package/dist/cjs/api/resources/contacts/client/requests/UpdateContactRequest.d.ts +13 -0
  32. package/dist/cjs/api/resources/contacts/client/requests/UpdateContactRequest.js +3 -0
  33. package/dist/cjs/api/resources/contacts/client/requests/index.d.ts +5 -0
  34. package/dist/cjs/api/resources/contacts/client/requests/index.js +2 -0
  35. package/dist/cjs/api/resources/contacts/index.d.ts +1 -0
  36. package/dist/cjs/api/resources/contacts/index.js +17 -0
  37. package/dist/cjs/api/resources/conversations/client/Client.d.ts +1 -1
  38. package/dist/cjs/api/resources/conversations/client/Client.js +1 -1
  39. package/dist/cjs/api/resources/index.d.ts +4 -0
  40. package/dist/cjs/api/resources/index.js +5 -1
  41. package/dist/cjs/api/resources/messages/client/Client.d.ts +49 -0
  42. package/dist/cjs/api/resources/messages/client/Client.js +183 -0
  43. package/dist/cjs/api/resources/messages/client/index.d.ts +1 -0
  44. package/dist/cjs/api/resources/messages/client/index.js +17 -0
  45. package/dist/cjs/api/resources/messages/client/requests/SendMessageRequest.d.ts +15 -0
  46. package/dist/cjs/api/resources/messages/client/requests/SendMessageRequest.js +3 -0
  47. package/dist/cjs/api/resources/messages/client/requests/SendReactionRequest.d.ts +11 -0
  48. package/dist/cjs/api/resources/messages/client/requests/SendReactionRequest.js +3 -0
  49. package/dist/cjs/api/resources/messages/client/requests/index.d.ts +2 -0
  50. package/dist/cjs/api/resources/messages/client/requests/index.js +2 -0
  51. package/dist/cjs/api/resources/messages/index.d.ts +1 -0
  52. package/dist/cjs/api/resources/messages/index.js +17 -0
  53. package/dist/cjs/api/resources/numbers/client/Client.d.ts +1 -1
  54. package/dist/cjs/api/resources/numbers/client/Client.js +1 -1
  55. package/dist/cjs/api/resources/usage/client/Client.d.ts +1 -1
  56. package/dist/cjs/api/resources/usage/client/Client.js +1 -1
  57. package/dist/cjs/api/resources/webhooks/client/Client.d.ts +6 -6
  58. package/dist/cjs/api/resources/webhooks/client/Client.js +6 -6
  59. package/dist/cjs/api/types/AgentNumberResponse.d.ts +1 -0
  60. package/dist/cjs/api/types/AgentResponse.d.ts +1 -0
  61. package/dist/cjs/api/types/CallSummary.d.ts +1 -1
  62. package/dist/cjs/api/types/ContactListResponse.d.ts +6 -0
  63. package/dist/cjs/api/types/ContactListResponse.js +3 -0
  64. package/dist/cjs/api/types/ContactResponse.d.ts +9 -0
  65. package/dist/cjs/api/types/ContactResponse.js +3 -0
  66. package/dist/cjs/api/types/MessageInConversation.d.ts +2 -0
  67. package/dist/cjs/api/types/MessageResponse.d.ts +2 -0
  68. package/dist/cjs/api/types/PhoneNumberResponse.d.ts +1 -0
  69. package/dist/cjs/api/types/SendMessageResponse.d.ts +7 -0
  70. package/dist/cjs/api/types/SendMessageResponse.js +3 -0
  71. package/dist/cjs/api/types/SendReactionResponse.d.ts +6 -0
  72. package/dist/cjs/api/types/SendReactionResponse.js +3 -0
  73. package/dist/cjs/api/types/WebhookCreateRequest.d.ts +1 -0
  74. package/dist/cjs/api/types/WebhookResponse.d.ts +1 -0
  75. package/dist/cjs/api/types/index.d.ts +4 -0
  76. package/dist/cjs/api/types/index.js +4 -0
  77. package/dist/cjs/version.d.ts +1 -1
  78. package/dist/cjs/version.js +1 -1
  79. package/dist/esm/BaseClient.mjs +2 -2
  80. package/dist/esm/Client.d.mts +6 -0
  81. package/dist/esm/Client.mjs +10 -0
  82. package/dist/esm/api/resources/agentWebhooks/client/Client.d.mts +1 -1
  83. package/dist/esm/api/resources/agentWebhooks/client/Client.mjs +1 -1
  84. package/dist/esm/api/resources/agents/client/Client.d.mts +20 -2
  85. package/dist/esm/api/resources/agents/client/Client.mjs +56 -2
  86. package/dist/esm/api/resources/agents/client/requests/CreateAgentRequest.d.mts +1 -0
  87. package/dist/esm/api/resources/agents/client/requests/DetachNumberFromAgentV1AgentsAgentIdNumbersNumberIdDeleteRequest.d.mts +11 -0
  88. package/dist/esm/api/resources/agents/client/requests/DetachNumberFromAgentV1AgentsAgentIdNumbersNumberIdDeleteRequest.mjs +2 -0
  89. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +1 -0
  90. package/dist/esm/api/resources/agents/client/requests/index.d.mts +1 -0
  91. package/dist/esm/api/resources/calls/client/Client.d.mts +27 -3
  92. package/dist/esm/api/resources/calls/client/Client.mjs +68 -4
  93. package/dist/esm/api/resources/calls/client/requests/ListCallsV1CallsGetRequest.d.mts +8 -0
  94. package/dist/esm/api/resources/calls/client/requests/StreamCallTranscriptV1CallsCallIdTranscriptStreamGetRequest.d.mts +9 -0
  95. package/dist/esm/api/resources/calls/client/requests/StreamCallTranscriptV1CallsCallIdTranscriptStreamGetRequest.mjs +2 -0
  96. package/dist/esm/api/resources/calls/client/requests/index.d.mts +1 -0
  97. package/dist/esm/api/resources/contacts/client/Client.d.mts +94 -0
  98. package/dist/esm/api/resources/contacts/client/Client.mjs +304 -0
  99. package/dist/esm/api/resources/contacts/client/index.d.mts +1 -0
  100. package/dist/esm/api/resources/contacts/client/index.mjs +1 -0
  101. package/dist/esm/api/resources/contacts/client/requests/CreateContactRequest.d.mts +13 -0
  102. package/dist/esm/api/resources/contacts/client/requests/CreateContactRequest.mjs +2 -0
  103. package/dist/esm/api/resources/contacts/client/requests/DeleteContactV1ContactsContactIdDeleteRequest.d.mts +9 -0
  104. package/dist/esm/api/resources/contacts/client/requests/DeleteContactV1ContactsContactIdDeleteRequest.mjs +2 -0
  105. package/dist/esm/api/resources/contacts/client/requests/GetContactV1ContactsContactIdGetRequest.d.mts +9 -0
  106. package/dist/esm/api/resources/contacts/client/requests/GetContactV1ContactsContactIdGetRequest.mjs +2 -0
  107. package/dist/esm/api/resources/contacts/client/requests/ListContactsV1ContactsGetRequest.d.mts +9 -0
  108. package/dist/esm/api/resources/contacts/client/requests/ListContactsV1ContactsGetRequest.mjs +2 -0
  109. package/dist/esm/api/resources/contacts/client/requests/UpdateContactRequest.d.mts +13 -0
  110. package/dist/esm/api/resources/contacts/client/requests/UpdateContactRequest.mjs +2 -0
  111. package/dist/esm/api/resources/contacts/client/requests/index.d.mts +5 -0
  112. package/dist/esm/api/resources/contacts/client/requests/index.mjs +1 -0
  113. package/dist/esm/api/resources/contacts/index.d.mts +1 -0
  114. package/dist/esm/api/resources/contacts/index.mjs +1 -0
  115. package/dist/esm/api/resources/conversations/client/Client.d.mts +1 -1
  116. package/dist/esm/api/resources/conversations/client/Client.mjs +1 -1
  117. package/dist/esm/api/resources/index.d.mts +4 -0
  118. package/dist/esm/api/resources/index.mjs +4 -0
  119. package/dist/esm/api/resources/messages/client/Client.d.mts +49 -0
  120. package/dist/esm/api/resources/messages/client/Client.mjs +146 -0
  121. package/dist/esm/api/resources/messages/client/index.d.mts +1 -0
  122. package/dist/esm/api/resources/messages/client/index.mjs +1 -0
  123. package/dist/esm/api/resources/messages/client/requests/SendMessageRequest.d.mts +15 -0
  124. package/dist/esm/api/resources/messages/client/requests/SendMessageRequest.mjs +2 -0
  125. package/dist/esm/api/resources/messages/client/requests/SendReactionRequest.d.mts +11 -0
  126. package/dist/esm/api/resources/messages/client/requests/SendReactionRequest.mjs +2 -0
  127. package/dist/esm/api/resources/messages/client/requests/index.d.mts +2 -0
  128. package/dist/esm/api/resources/messages/client/requests/index.mjs +1 -0
  129. package/dist/esm/api/resources/messages/index.d.mts +1 -0
  130. package/dist/esm/api/resources/messages/index.mjs +1 -0
  131. package/dist/esm/api/resources/numbers/client/Client.d.mts +1 -1
  132. package/dist/esm/api/resources/numbers/client/Client.mjs +1 -1
  133. package/dist/esm/api/resources/usage/client/Client.d.mts +1 -1
  134. package/dist/esm/api/resources/usage/client/Client.mjs +1 -1
  135. package/dist/esm/api/resources/webhooks/client/Client.d.mts +6 -6
  136. package/dist/esm/api/resources/webhooks/client/Client.mjs +6 -6
  137. package/dist/esm/api/types/AgentNumberResponse.d.mts +1 -0
  138. package/dist/esm/api/types/AgentResponse.d.mts +1 -0
  139. package/dist/esm/api/types/CallSummary.d.mts +1 -1
  140. package/dist/esm/api/types/ContactListResponse.d.mts +6 -0
  141. package/dist/esm/api/types/ContactListResponse.mjs +2 -0
  142. package/dist/esm/api/types/ContactResponse.d.mts +9 -0
  143. package/dist/esm/api/types/ContactResponse.mjs +2 -0
  144. package/dist/esm/api/types/MessageInConversation.d.mts +2 -0
  145. package/dist/esm/api/types/MessageResponse.d.mts +2 -0
  146. package/dist/esm/api/types/PhoneNumberResponse.d.mts +1 -0
  147. package/dist/esm/api/types/SendMessageResponse.d.mts +7 -0
  148. package/dist/esm/api/types/SendMessageResponse.mjs +2 -0
  149. package/dist/esm/api/types/SendReactionResponse.d.mts +6 -0
  150. package/dist/esm/api/types/SendReactionResponse.mjs +2 -0
  151. package/dist/esm/api/types/WebhookCreateRequest.d.mts +1 -0
  152. package/dist/esm/api/types/WebhookResponse.d.mts +1 -0
  153. package/dist/esm/api/types/index.d.mts +4 -0
  154. package/dist/esm/api/types/index.mjs +4 -0
  155. package/dist/esm/version.d.mts +1 -1
  156. package/dist/esm/version.mjs +1 -1
  157. package/package.json +1 -1
  158. package/reference.md +737 -126
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __rest = (this && this.__rest) || function (s, e) {
46
+ var t = {};
47
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
48
+ t[p] = s[p];
49
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
50
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
51
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
52
+ t[p[i]] = s[p[i]];
53
+ }
54
+ return t;
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.ContactsClient = void 0;
58
+ const BaseClient_js_1 = require("../../../../BaseClient.js");
59
+ const headers_js_1 = require("../../../../core/headers.js");
60
+ const core = __importStar(require("../../../../core/index.js"));
61
+ const environments = __importStar(require("../../../../environments.js"));
62
+ const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
63
+ const errors = __importStar(require("../../../../errors/index.js"));
64
+ const AgentPhone = __importStar(require("../../../index.js"));
65
+ class ContactsClient {
66
+ constructor(options) {
67
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
68
+ }
69
+ /**
70
+ * List all contacts for this account.
71
+ *
72
+ * Optional `search` query filters by name or phone number (case-insensitive contains).
73
+ *
74
+ * @param {AgentPhone.ListContactsV1ContactsGetRequest} request
75
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
76
+ *
77
+ * @throws {@link AgentPhone.UnprocessableEntityError}
78
+ *
79
+ * @example
80
+ * await client.contacts.listContacts()
81
+ */
82
+ listContacts(request = {}, requestOptions) {
83
+ return core.HttpResponsePromise.fromPromise(this.__listContacts(request, requestOptions));
84
+ }
85
+ __listContacts() {
86
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
87
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
88
+ const { search, limit, offset } = request;
89
+ const _queryParams = {
90
+ search,
91
+ limit,
92
+ offset,
93
+ };
94
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
95
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
96
+ const _response = yield core.fetcher({
97
+ 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.AgentPhoneEnvironment.Default, "v1/contacts"),
98
+ method: "GET",
99
+ headers: _headers,
100
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
101
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
102
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
103
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
104
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
105
+ logging: this._options.logging,
106
+ });
107
+ if (_response.ok) {
108
+ return { data: _response.body, rawResponse: _response.rawResponse };
109
+ }
110
+ if (_response.error.reason === "status-code") {
111
+ switch (_response.error.statusCode) {
112
+ case 422:
113
+ throw new AgentPhone.UnprocessableEntityError(_response.error.body, _response.rawResponse);
114
+ default:
115
+ throw new errors.AgentPhoneError({
116
+ statusCode: _response.error.statusCode,
117
+ body: _response.error.body,
118
+ rawResponse: _response.rawResponse,
119
+ });
120
+ }
121
+ }
122
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v1/contacts");
123
+ });
124
+ }
125
+ /**
126
+ * Create a new contact.
127
+ *
128
+ * Phone number is normalized to E.164 format. Returns 409 if a contact
129
+ * with this phone number already exists for the project.
130
+ *
131
+ * @param {AgentPhone.CreateContactRequest} request
132
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
133
+ *
134
+ * @throws {@link AgentPhone.UnprocessableEntityError}
135
+ *
136
+ * @example
137
+ * await client.contacts.createContact({
138
+ * phoneNumber: "phoneNumber",
139
+ * name: "name"
140
+ * })
141
+ */
142
+ createContact(request, requestOptions) {
143
+ return core.HttpResponsePromise.fromPromise(this.__createContact(request, requestOptions));
144
+ }
145
+ __createContact(request, requestOptions) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
148
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
149
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
150
+ const _response = yield core.fetcher({
151
+ 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.AgentPhoneEnvironment.Default, "v1/contacts"),
152
+ method: "POST",
153
+ headers: _headers,
154
+ contentType: "application/json",
155
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
156
+ requestType: "json",
157
+ body: request,
158
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
159
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
160
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
161
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
162
+ logging: this._options.logging,
163
+ });
164
+ if (_response.ok) {
165
+ return { data: _response.body, rawResponse: _response.rawResponse };
166
+ }
167
+ if (_response.error.reason === "status-code") {
168
+ switch (_response.error.statusCode) {
169
+ case 422:
170
+ throw new AgentPhone.UnprocessableEntityError(_response.error.body, _response.rawResponse);
171
+ default:
172
+ throw new errors.AgentPhoneError({
173
+ statusCode: _response.error.statusCode,
174
+ body: _response.error.body,
175
+ rawResponse: _response.rawResponse,
176
+ });
177
+ }
178
+ }
179
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v1/contacts");
180
+ });
181
+ }
182
+ /**
183
+ * Get a single contact by ID.
184
+ *
185
+ * @param {AgentPhone.GetContactV1ContactsContactIdGetRequest} request
186
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
187
+ *
188
+ * @throws {@link AgentPhone.UnprocessableEntityError}
189
+ *
190
+ * @example
191
+ * await client.contacts.getContact({
192
+ * contact_id: "contact_id"
193
+ * })
194
+ */
195
+ getContact(request, requestOptions) {
196
+ return core.HttpResponsePromise.fromPromise(this.__getContact(request, requestOptions));
197
+ }
198
+ __getContact(request, requestOptions) {
199
+ return __awaiter(this, void 0, void 0, function* () {
200
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
201
+ const { contact_id: contactId } = request;
202
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
203
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
204
+ const _response = yield core.fetcher({
205
+ 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.AgentPhoneEnvironment.Default, `v1/contacts/${core.url.encodePathParam(contactId)}`),
206
+ method: "GET",
207
+ headers: _headers,
208
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
209
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
210
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
211
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
212
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
213
+ logging: this._options.logging,
214
+ });
215
+ if (_response.ok) {
216
+ return { data: _response.body, rawResponse: _response.rawResponse };
217
+ }
218
+ if (_response.error.reason === "status-code") {
219
+ switch (_response.error.statusCode) {
220
+ case 422:
221
+ throw new AgentPhone.UnprocessableEntityError(_response.error.body, _response.rawResponse);
222
+ default:
223
+ throw new errors.AgentPhoneError({
224
+ statusCode: _response.error.statusCode,
225
+ body: _response.error.body,
226
+ rawResponse: _response.rawResponse,
227
+ });
228
+ }
229
+ }
230
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v1/contacts/{contact_id}");
231
+ });
232
+ }
233
+ /**
234
+ * Delete a contact.
235
+ *
236
+ * @param {AgentPhone.DeleteContactV1ContactsContactIdDeleteRequest} request
237
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
238
+ *
239
+ * @throws {@link AgentPhone.UnprocessableEntityError}
240
+ *
241
+ * @example
242
+ * await client.contacts.deleteContact({
243
+ * contact_id: "contact_id"
244
+ * })
245
+ */
246
+ deleteContact(request, requestOptions) {
247
+ return core.HttpResponsePromise.fromPromise(this.__deleteContact(request, requestOptions));
248
+ }
249
+ __deleteContact(request, requestOptions) {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
252
+ const { contact_id: contactId } = request;
253
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
254
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
255
+ const _response = yield core.fetcher({
256
+ 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.AgentPhoneEnvironment.Default, `v1/contacts/${core.url.encodePathParam(contactId)}`),
257
+ method: "DELETE",
258
+ headers: _headers,
259
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
260
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
261
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
262
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
263
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
264
+ logging: this._options.logging,
265
+ });
266
+ if (_response.ok) {
267
+ return { data: undefined, rawResponse: _response.rawResponse };
268
+ }
269
+ if (_response.error.reason === "status-code") {
270
+ switch (_response.error.statusCode) {
271
+ case 422:
272
+ throw new AgentPhone.UnprocessableEntityError(_response.error.body, _response.rawResponse);
273
+ default:
274
+ throw new errors.AgentPhoneError({
275
+ statusCode: _response.error.statusCode,
276
+ body: _response.error.body,
277
+ rawResponse: _response.rawResponse,
278
+ });
279
+ }
280
+ }
281
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/v1/contacts/{contact_id}");
282
+ });
283
+ }
284
+ /**
285
+ * Update a contact's fields.
286
+ *
287
+ * If phoneNumber is updated, it's re-normalized and checked for uniqueness (409 on conflict).
288
+ *
289
+ * @param {AgentPhone.UpdateContactRequest} request
290
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
291
+ *
292
+ * @throws {@link AgentPhone.UnprocessableEntityError}
293
+ *
294
+ * @example
295
+ * await client.contacts.updateContact({
296
+ * contact_id: "contact_id"
297
+ * })
298
+ */
299
+ updateContact(request, requestOptions) {
300
+ return core.HttpResponsePromise.fromPromise(this.__updateContact(request, requestOptions));
301
+ }
302
+ __updateContact(request, requestOptions) {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
305
+ const { contact_id: contactId } = request, _body = __rest(request, ["contact_id"]);
306
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
307
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
308
+ const _response = yield core.fetcher({
309
+ 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.AgentPhoneEnvironment.Default, `v1/contacts/${core.url.encodePathParam(contactId)}`),
310
+ method: "PATCH",
311
+ headers: _headers,
312
+ contentType: "application/json",
313
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
314
+ requestType: "json",
315
+ body: _body,
316
+ timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
317
+ maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
318
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
319
+ fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
320
+ logging: this._options.logging,
321
+ });
322
+ if (_response.ok) {
323
+ return { data: _response.body, rawResponse: _response.rawResponse };
324
+ }
325
+ if (_response.error.reason === "status-code") {
326
+ switch (_response.error.statusCode) {
327
+ case 422:
328
+ throw new AgentPhone.UnprocessableEntityError(_response.error.body, _response.rawResponse);
329
+ default:
330
+ throw new errors.AgentPhoneError({
331
+ statusCode: _response.error.statusCode,
332
+ body: _response.error.body,
333
+ rawResponse: _response.rawResponse,
334
+ });
335
+ }
336
+ }
337
+ return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/v1/contacts/{contact_id}");
338
+ });
339
+ }
340
+ }
341
+ exports.ContactsClient = ContactsClient;
@@ -0,0 +1 @@
1
+ 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,13 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * phoneNumber: "phoneNumber",
5
+ * name: "name"
6
+ * }
7
+ */
8
+ export interface CreateContactRequest {
9
+ phoneNumber: string;
10
+ name: string;
11
+ email?: string | null;
12
+ notes?: string | null;
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * contact_id: "contact_id"
5
+ * }
6
+ */
7
+ export interface DeleteContactV1ContactsContactIdDeleteRequest {
8
+ contact_id: string;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * contact_id: "contact_id"
5
+ * }
6
+ */
7
+ export interface GetContactV1ContactsContactIdGetRequest {
8
+ contact_id: string;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @example
3
+ * {}
4
+ */
5
+ export interface ListContactsV1ContactsGetRequest {
6
+ search?: string | null;
7
+ limit?: number;
8
+ offset?: number;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * contact_id: "contact_id"
5
+ * }
6
+ */
7
+ export interface UpdateContactRequest {
8
+ contact_id: string;
9
+ phoneNumber?: string | null;
10
+ name?: string | null;
11
+ email?: string | null;
12
+ notes?: string | null;
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export type { CreateContactRequest } from "./CreateContactRequest.js";
2
+ export type { DeleteContactV1ContactsContactIdDeleteRequest } from "./DeleteContactV1ContactsContactIdDeleteRequest.js";
3
+ export type { GetContactV1ContactsContactIdGetRequest } from "./GetContactV1ContactsContactIdGetRequest.js";
4
+ export type { ListContactsV1ContactsGetRequest } from "./ListContactsV1ContactsGetRequest.js";
5
+ export type { UpdateContactRequest } from "./UpdateContactRequest.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client/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("./client/index.js"), exports);
@@ -11,7 +11,7 @@ export declare class ConversationsClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<ConversationsClient.Options>;
12
12
  constructor(options: ConversationsClient.Options);
13
13
  /**
14
- * List all conversations for this project.
14
+ * List all conversations for this account.
15
15
  *
16
16
  * Sorted by most recent activity (lastMessageAt desc).
17
17
  *
@@ -67,7 +67,7 @@ class ConversationsClient {
67
67
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
68
68
  }
69
69
  /**
70
- * List all conversations for this project.
70
+ * List all conversations for this account.
71
71
  *
72
72
  * Sorted by most recent activity (lastMessageAt desc).
73
73
  *
@@ -4,8 +4,12 @@ export * from "./agentWebhooks/client/requests/index.js";
4
4
  export * as agentWebhooks from "./agentWebhooks/index.js";
5
5
  export * from "./calls/client/requests/index.js";
6
6
  export * as calls from "./calls/index.js";
7
+ export * from "./contacts/client/requests/index.js";
8
+ export * as contacts from "./contacts/index.js";
7
9
  export * from "./conversations/client/requests/index.js";
8
10
  export * as conversations from "./conversations/index.js";
11
+ export * from "./messages/client/requests/index.js";
12
+ export * as messages from "./messages/index.js";
9
13
  export * from "./numbers/client/requests/index.js";
10
14
  export * as numbers from "./numbers/index.js";
11
15
  export * from "./usage/client/requests/index.js";
@@ -36,15 +36,19 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.webhooks = exports.usage = exports.numbers = exports.conversations = exports.calls = exports.agentWebhooks = exports.agents = void 0;
39
+ exports.webhooks = exports.usage = exports.numbers = exports.messages = exports.conversations = exports.contacts = exports.calls = exports.agentWebhooks = exports.agents = void 0;
40
40
  __exportStar(require("./agents/client/requests/index.js"), exports);
41
41
  exports.agents = __importStar(require("./agents/index.js"));
42
42
  __exportStar(require("./agentWebhooks/client/requests/index.js"), exports);
43
43
  exports.agentWebhooks = __importStar(require("./agentWebhooks/index.js"));
44
44
  __exportStar(require("./calls/client/requests/index.js"), exports);
45
45
  exports.calls = __importStar(require("./calls/index.js"));
46
+ __exportStar(require("./contacts/client/requests/index.js"), exports);
47
+ exports.contacts = __importStar(require("./contacts/index.js"));
46
48
  __exportStar(require("./conversations/client/requests/index.js"), exports);
47
49
  exports.conversations = __importStar(require("./conversations/index.js"));
50
+ __exportStar(require("./messages/client/requests/index.js"), exports);
51
+ exports.messages = __importStar(require("./messages/index.js"));
48
52
  __exportStar(require("./numbers/client/requests/index.js"), exports);
49
53
  exports.numbers = __importStar(require("./numbers/index.js"));
50
54
  __exportStar(require("./usage/client/requests/index.js"), exports);
@@ -0,0 +1,49 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
3
+ import * as core from "../../../../core/index.js";
4
+ import * as AgentPhone from "../../../index.js";
5
+ export declare namespace MessagesClient {
6
+ type Options = BaseClientOptions;
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class MessagesClient {
11
+ protected readonly _options: NormalizedClientOptionsWithAuth<MessagesClient.Options>;
12
+ constructor(options: MessagesClient.Options);
13
+ /**
14
+ * Send an outbound message (SMS or iMessage) via the provider assigned to the number.
15
+ *
16
+ * @param {AgentPhone.SendMessageRequest} request
17
+ * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
18
+ *
19
+ * @throws {@link AgentPhone.UnprocessableEntityError}
20
+ *
21
+ * @example
22
+ * await client.messages.sendMessage({
23
+ * agent_id: "agent_id",
24
+ * to_number: "to_number",
25
+ * body: "body"
26
+ * })
27
+ */
28
+ sendMessage(request: AgentPhone.SendMessageRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentPhone.SendMessageResponse>;
29
+ private __sendMessage;
30
+ /**
31
+ * Send a tapback reaction to a message (iMessage only).
32
+ *
33
+ * Reactions are an iMessage feature. Attempting to react to a message
34
+ * sent via an SMS/Twilio number will return a clear error.
35
+ *
36
+ * @param {AgentPhone.SendReactionRequest} request
37
+ * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
38
+ *
39
+ * @throws {@link AgentPhone.UnprocessableEntityError}
40
+ *
41
+ * @example
42
+ * await client.messages.sendReaction({
43
+ * message_id: "message_id",
44
+ * reaction: "reaction"
45
+ * })
46
+ */
47
+ sendReaction(request: AgentPhone.SendReactionRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentPhone.SendReactionResponse>;
48
+ private __sendReaction;
49
+ }