@surgeapi/node 0.25.5 → 0.25.7

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 (75) hide show
  1. package/README.md +14 -1
  2. package/api/errors/ConflictError.d.ts +2 -1
  3. package/api/errors/ConflictError.js +2 -1
  4. package/api/errors/UnprocessableEntityError.d.ts +2 -1
  5. package/api/errors/UnprocessableEntityError.js +2 -1
  6. package/api/resources/accounts/client/Client.d.ts +4 -2
  7. package/api/resources/accounts/client/Client.js +17 -5
  8. package/api/resources/blasts/client/Client.d.ts +4 -4
  9. package/api/resources/blasts/client/Client.js +11 -6
  10. package/api/resources/blasts/client/requests/BlastRequest.d.ts +6 -5
  11. package/api/resources/contacts/client/Client.d.ts +6 -3
  12. package/api/resources/contacts/client/Client.js +24 -6
  13. package/api/resources/messages/client/Client.d.ts +2 -1
  14. package/api/resources/messages/client/Client.js +8 -2
  15. package/api/resources/phoneNumbers/client/Client.d.ts +2 -1
  16. package/api/resources/phoneNumbers/client/Client.js +8 -2
  17. package/api/resources/users/client/Client.d.ts +4 -2
  18. package/api/resources/users/client/Client.js +16 -4
  19. package/api/resources/verifications/client/Client.d.ts +4 -2
  20. package/api/resources/verifications/client/Client.js +18 -6
  21. package/api/types/MessageConversationParams.d.ts +1 -1
  22. package/core/fetcher/APIResponse.d.ts +10 -0
  23. package/core/fetcher/Fetcher.js +7 -0
  24. package/core/fetcher/Headers.d.ts +2 -0
  25. package/core/fetcher/Headers.js +84 -0
  26. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  27. package/core/fetcher/HttpResponsePromise.js +103 -0
  28. package/core/fetcher/RawResponse.d.ts +29 -0
  29. package/core/fetcher/RawResponse.js +44 -0
  30. package/core/fetcher/index.d.ts +3 -0
  31. package/core/fetcher/index.js +7 -1
  32. package/core/index.d.ts +1 -1
  33. package/core/index.js +1 -1
  34. package/dist/api/errors/ConflictError.d.ts +2 -1
  35. package/dist/api/errors/ConflictError.js +2 -1
  36. package/dist/api/errors/UnprocessableEntityError.d.ts +2 -1
  37. package/dist/api/errors/UnprocessableEntityError.js +2 -1
  38. package/dist/api/resources/accounts/client/Client.d.ts +4 -2
  39. package/dist/api/resources/accounts/client/Client.js +17 -5
  40. package/dist/api/resources/blasts/client/Client.d.ts +4 -4
  41. package/dist/api/resources/blasts/client/Client.js +11 -6
  42. package/dist/api/resources/blasts/client/requests/BlastRequest.d.ts +6 -5
  43. package/dist/api/resources/contacts/client/Client.d.ts +6 -3
  44. package/dist/api/resources/contacts/client/Client.js +24 -6
  45. package/dist/api/resources/messages/client/Client.d.ts +2 -1
  46. package/dist/api/resources/messages/client/Client.js +8 -2
  47. package/dist/api/resources/phoneNumbers/client/Client.d.ts +2 -1
  48. package/dist/api/resources/phoneNumbers/client/Client.js +8 -2
  49. package/dist/api/resources/users/client/Client.d.ts +4 -2
  50. package/dist/api/resources/users/client/Client.js +16 -4
  51. package/dist/api/resources/verifications/client/Client.d.ts +4 -2
  52. package/dist/api/resources/verifications/client/Client.js +18 -6
  53. package/dist/api/types/MessageConversationParams.d.ts +1 -1
  54. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  55. package/dist/core/fetcher/Fetcher.js +7 -0
  56. package/dist/core/fetcher/Headers.d.ts +2 -0
  57. package/dist/core/fetcher/Headers.js +84 -0
  58. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  59. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  60. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  61. package/dist/core/fetcher/RawResponse.js +44 -0
  62. package/dist/core/fetcher/index.d.ts +3 -0
  63. package/dist/core/fetcher/index.js +7 -1
  64. package/dist/core/index.d.ts +1 -1
  65. package/dist/core/index.js +1 -1
  66. package/dist/errors/SurgeError.d.ts +4 -1
  67. package/dist/errors/SurgeError.js +4 -7
  68. package/dist/version.d.ts +1 -1
  69. package/dist/version.js +1 -1
  70. package/errors/SurgeError.d.ts +4 -1
  71. package/errors/SurgeError.js +4 -7
  72. package/package.json +3 -2
  73. package/reference.md +1 -2
  74. package/version.d.ts +1 -1
  75. package/version.js +1 -1
package/core/index.js CHANGED
@@ -15,5 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./fetcher"), exports);
18
- __exportStar(require("./auth"), exports);
19
18
  __exportStar(require("./runtime"), exports);
19
+ __exportStar(require("./auth"), exports);
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
5
  import * as Surge from "../index";
6
+ import * as core from "../../core";
6
7
  export declare class ConflictError extends errors.SurgeError {
7
- constructor(body: Surge.VerificationCheckAlreadyVerifiedResponse);
8
+ constructor(body: Surge.VerificationCheckAlreadyVerifiedResponse, rawResponse?: core.RawResponse);
8
9
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ConflictError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class ConflictError extends errors.SurgeError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "ConflictError",
45
45
  statusCode: 409,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, ConflictError.prototype);
49
50
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
5
  import * as Surge from "../index";
6
+ import * as core from "../../core";
6
7
  export declare class UnprocessableEntityError extends errors.SurgeError {
7
- constructor(body: Surge.VerificationCheckIncorrectResponse);
8
+ constructor(body: Surge.VerificationCheckIncorrectResponse, rawResponse?: core.RawResponse);
8
9
  }
@@ -39,11 +39,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.UnprocessableEntityError = void 0;
40
40
  const errors = __importStar(require("../../errors/index"));
41
41
  class UnprocessableEntityError extends errors.SurgeError {
42
- constructor(body) {
42
+ constructor(body, rawResponse) {
43
43
  super({
44
44
  message: "UnprocessableEntityError",
45
45
  statusCode: 422,
46
46
  body: body,
47
+ rawResponse: rawResponse,
47
48
  });
48
49
  Object.setPrototypeOf(this, UnprocessableEntityError.prototype);
49
50
  }
@@ -38,7 +38,8 @@ export declare class Accounts {
38
38
  * time_zone: "America/Los_Angeles"
39
39
  * })
40
40
  */
41
- create(request: Surge.CreateAccountRequest, requestOptions?: Accounts.RequestOptions): Promise<Surge.AccountResponse>;
41
+ create(request: Surge.CreateAccountRequest, requestOptions?: Accounts.RequestOptions): core.HttpResponsePromise<Surge.AccountResponse>;
42
+ private __create;
42
43
  /**
43
44
  * Updates an Account
44
45
  *
@@ -52,6 +53,7 @@ export declare class Accounts {
52
53
  * time_zone: "America/Los_Angeles"
53
54
  * })
54
55
  */
55
- update(id: string, request?: Surge.UpdateAccountRequest, requestOptions?: Accounts.RequestOptions): Promise<Surge.AccountResponse>;
56
+ update(id: string, request?: Surge.UpdateAccountRequest, requestOptions?: Accounts.RequestOptions): core.HttpResponsePromise<Surge.AccountResponse>;
57
+ private __update;
56
58
  protected _getAuthorizationHeader(): Promise<string>;
57
59
  }
@@ -70,12 +70,15 @@ class Accounts {
70
70
  * })
71
71
  */
72
72
  create(request, requestOptions) {
73
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
74
+ }
75
+ __create(request, requestOptions) {
73
76
  return __awaiter(this, void 0, void 0, function* () {
74
77
  var _a, _b, _c;
75
78
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
76
79
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, "accounts"),
77
80
  method: "POST",
78
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
81
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
79
82
  contentType: "application/json",
80
83
  requestType: "json",
81
84
  body: request,
@@ -84,12 +87,13 @@ class Accounts {
84
87
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
85
88
  });
86
89
  if (_response.ok) {
87
- return _response.body;
90
+ return { data: _response.body, rawResponse: _response.rawResponse };
88
91
  }
89
92
  if (_response.error.reason === "status-code") {
90
93
  throw new errors.SurgeError({
91
94
  statusCode: _response.error.statusCode,
92
95
  body: _response.error.body,
96
+ rawResponse: _response.rawResponse,
93
97
  });
94
98
  }
95
99
  switch (_response.error.reason) {
@@ -97,12 +101,14 @@ class Accounts {
97
101
  throw new errors.SurgeError({
98
102
  statusCode: _response.error.statusCode,
99
103
  body: _response.error.rawBody,
104
+ rawResponse: _response.rawResponse,
100
105
  });
101
106
  case "timeout":
102
107
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts.");
103
108
  case "unknown":
104
109
  throw new errors.SurgeError({
105
110
  message: _response.error.errorMessage,
111
+ rawResponse: _response.rawResponse,
106
112
  });
107
113
  }
108
114
  });
@@ -120,13 +126,16 @@ class Accounts {
120
126
  * time_zone: "America/Los_Angeles"
121
127
  * })
122
128
  */
123
- update(id_1) {
129
+ update(id, request = {}, requestOptions) {
130
+ return core.HttpResponsePromise.fromPromise(this.__update(id, request, requestOptions));
131
+ }
132
+ __update(id_1) {
124
133
  return __awaiter(this, arguments, void 0, function* (id, request = {}, requestOptions) {
125
134
  var _a, _b, _c;
126
135
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
127
136
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `accounts/${encodeURIComponent(id)}`),
128
137
  method: "PATCH",
129
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
138
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
130
139
  contentType: "application/json",
131
140
  requestType: "json",
132
141
  body: request,
@@ -135,12 +144,13 @@ class Accounts {
135
144
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
136
145
  });
137
146
  if (_response.ok) {
138
- return _response.body;
147
+ return { data: _response.body, rawResponse: _response.rawResponse };
139
148
  }
140
149
  if (_response.error.reason === "status-code") {
141
150
  throw new errors.SurgeError({
142
151
  statusCode: _response.error.statusCode,
143
152
  body: _response.error.body,
153
+ rawResponse: _response.rawResponse,
144
154
  });
145
155
  }
146
156
  switch (_response.error.reason) {
@@ -148,12 +158,14 @@ class Accounts {
148
158
  throw new errors.SurgeError({
149
159
  statusCode: _response.error.statusCode,
150
160
  body: _response.error.rawBody,
161
+ rawResponse: _response.rawResponse,
151
162
  });
152
163
  case "timeout":
153
164
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling PATCH /accounts/{id}.");
154
165
  case "unknown":
155
166
  throw new errors.SurgeError({
156
167
  message: _response.error.errorMessage,
168
+ rawResponse: _response.rawResponse,
157
169
  });
158
170
  }
159
171
  });
@@ -39,12 +39,12 @@ export declare class Blasts {
39
39
  * url: "https://example.com/image.jpg"
40
40
  * }],
41
41
  * body: "Join us for our grand opening!",
42
- * contacts: ["ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"],
43
42
  * name: "Grand Opening Announcement",
44
- * segments: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf"],
45
- * send_at: "2024-02-01T15:00:00Z"
43
+ * send_at: "2024-02-01T15:00:00Z",
44
+ * to: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf", "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf", "+18015551234", "+18015555678"]
46
45
  * })
47
46
  */
48
- send(accountId: string, request?: Surge.BlastRequest, requestOptions?: Blasts.RequestOptions): Promise<Surge.BlastResponse>;
47
+ send(accountId: string, request?: Surge.BlastRequest, requestOptions?: Blasts.RequestOptions): core.HttpResponsePromise<Surge.BlastResponse>;
48
+ private __send;
49
49
  protected _getAuthorizationHeader(): Promise<string>;
50
50
  }
@@ -70,19 +70,21 @@ class Blasts {
70
70
  * url: "https://example.com/image.jpg"
71
71
  * }],
72
72
  * body: "Join us for our grand opening!",
73
- * contacts: ["ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"],
74
73
  * name: "Grand Opening Announcement",
75
- * segments: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf"],
76
- * send_at: "2024-02-01T15:00:00Z"
74
+ * send_at: "2024-02-01T15:00:00Z",
75
+ * to: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf", "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf", "+18015551234", "+18015555678"]
77
76
  * })
78
77
  */
79
- send(accountId_1) {
78
+ send(accountId, request = {}, requestOptions) {
79
+ return core.HttpResponsePromise.fromPromise(this.__send(accountId, request, requestOptions));
80
+ }
81
+ __send(accountId_1) {
80
82
  return __awaiter(this, arguments, void 0, function* (accountId, request = {}, requestOptions) {
81
83
  var _a, _b, _c;
82
84
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
83
85
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `accounts/${encodeURIComponent(accountId)}/blasts`),
84
86
  method: "POST",
85
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
87
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
86
88
  contentType: "application/json",
87
89
  requestType: "json",
88
90
  body: request,
@@ -91,12 +93,13 @@ class Blasts {
91
93
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
92
94
  });
93
95
  if (_response.ok) {
94
- return _response.body;
96
+ return { data: _response.body, rawResponse: _response.rawResponse };
95
97
  }
96
98
  if (_response.error.reason === "status-code") {
97
99
  throw new errors.SurgeError({
98
100
  statusCode: _response.error.statusCode,
99
101
  body: _response.error.body,
102
+ rawResponse: _response.rawResponse,
100
103
  });
101
104
  }
102
105
  switch (_response.error.reason) {
@@ -104,12 +107,14 @@ class Blasts {
104
107
  throw new errors.SurgeError({
105
108
  statusCode: _response.error.statusCode,
106
109
  body: _response.error.rawBody,
110
+ rawResponse: _response.rawResponse,
107
111
  });
108
112
  case "timeout":
109
113
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts/{account_id}/blasts.");
110
114
  case "unknown":
111
115
  throw new errors.SurgeError({
112
116
  message: _response.error.errorMessage,
117
+ rawResponse: _response.rawResponse,
113
118
  });
114
119
  }
115
120
  });
@@ -9,22 +9,23 @@ import * as Surge from "../../../../index";
9
9
  * url: "https://example.com/image.jpg"
10
10
  * }],
11
11
  * body: "Join us for our grand opening!",
12
- * contacts: ["ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"],
13
12
  * name: "Grand Opening Announcement",
14
- * segments: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf"],
15
- * send_at: "2024-02-01T15:00:00Z"
13
+ * send_at: "2024-02-01T15:00:00Z",
14
+ * to: ["seg_01j9dy8mdzfn3r0e8x1tbdrdrf", "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf", "+18015551234", "+18015555678"]
16
15
  * }
17
16
  */
18
17
  export interface BlastRequest {
19
18
  attachments?: Surge.AttachmentParams[];
20
19
  /** The message body. */
21
20
  body?: string;
22
- /** List of contact IDs to send the blast to. */
21
+ /** Deprecated. Use `to` instead. */
23
22
  contacts?: string[];
24
23
  /** Optional name for the blast. */
25
24
  name?: string;
26
- /** List of segment IDs to send the blast to. */
25
+ /** Deprecated. Use `to` instead. */
27
26
  segments?: string[];
28
27
  /** When to send the blast. If not provided, sends immediately. */
29
28
  send_at?: string;
29
+ /** List of recipients to whom the blast should be sent. This can be a combination of contact IDs, segment IDs, and phone numbers. */
30
+ to?: string[];
30
31
  }
@@ -44,7 +44,8 @@ export declare class Contacts {
44
44
  * phone_number: "+18015551234"
45
45
  * })
46
46
  */
47
- create(accountId: string, request: Surge.ContactRequest, requestOptions?: Contacts.RequestOptions): Promise<Surge.ContactResponse>;
47
+ create(accountId: string, request: Surge.ContactRequest, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Surge.ContactResponse>;
48
+ private __create;
48
49
  /**
49
50
  * Retrieves a Contact object.
50
51
  *
@@ -54,7 +55,8 @@ export declare class Contacts {
54
55
  * @example
55
56
  * await client.contacts.getContact("ctc_01j9dy8mdzfn3r0e8x1tbdrdrf")
56
57
  */
57
- getContact(id: string, requestOptions?: Contacts.RequestOptions): Promise<Surge.ContactResponse>;
58
+ getContact(id: string, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Surge.ContactResponse>;
59
+ private __getContact;
58
60
  /**
59
61
  * Updates the specified contact by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
60
62
  *
@@ -73,6 +75,7 @@ export declare class Contacts {
73
75
  * phone_number: "+18015551234"
74
76
  * })
75
77
  */
76
- update(id: string, request: Surge.ContactRequest, requestOptions?: Contacts.RequestOptions): Promise<Surge.ContactResponse>;
78
+ update(id: string, request: Surge.ContactRequest, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Surge.ContactResponse>;
79
+ private __update;
77
80
  protected _getAuthorizationHeader(): Promise<string>;
78
81
  }
@@ -76,12 +76,15 @@ class Contacts {
76
76
  * })
77
77
  */
78
78
  create(accountId, request, requestOptions) {
79
+ return core.HttpResponsePromise.fromPromise(this.__create(accountId, request, requestOptions));
80
+ }
81
+ __create(accountId, request, requestOptions) {
79
82
  return __awaiter(this, void 0, void 0, function* () {
80
83
  var _a, _b, _c;
81
84
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
82
85
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `accounts/${encodeURIComponent(accountId)}/contacts`),
83
86
  method: "POST",
84
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
87
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
85
88
  contentType: "application/json",
86
89
  requestType: "json",
87
90
  body: request,
@@ -90,12 +93,13 @@ class Contacts {
90
93
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
91
94
  });
92
95
  if (_response.ok) {
93
- return _response.body;
96
+ return { data: _response.body, rawResponse: _response.rawResponse };
94
97
  }
95
98
  if (_response.error.reason === "status-code") {
96
99
  throw new errors.SurgeError({
97
100
  statusCode: _response.error.statusCode,
98
101
  body: _response.error.body,
102
+ rawResponse: _response.rawResponse,
99
103
  });
100
104
  }
101
105
  switch (_response.error.reason) {
@@ -103,12 +107,14 @@ class Contacts {
103
107
  throw new errors.SurgeError({
104
108
  statusCode: _response.error.statusCode,
105
109
  body: _response.error.rawBody,
110
+ rawResponse: _response.rawResponse,
106
111
  });
107
112
  case "timeout":
108
113
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts/{account_id}/contacts.");
109
114
  case "unknown":
110
115
  throw new errors.SurgeError({
111
116
  message: _response.error.errorMessage,
117
+ rawResponse: _response.rawResponse,
112
118
  });
113
119
  }
114
120
  });
@@ -123,12 +129,15 @@ class Contacts {
123
129
  * await client.contacts.getContact("ctc_01j9dy8mdzfn3r0e8x1tbdrdrf")
124
130
  */
125
131
  getContact(id, requestOptions) {
132
+ return core.HttpResponsePromise.fromPromise(this.__getContact(id, requestOptions));
133
+ }
134
+ __getContact(id, requestOptions) {
126
135
  return __awaiter(this, void 0, void 0, function* () {
127
136
  var _a, _b, _c;
128
137
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
129
138
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `contacts/${encodeURIComponent(id)}`),
130
139
  method: "GET",
131
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
140
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
132
141
  contentType: "application/json",
133
142
  requestType: "json",
134
143
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -136,12 +145,13 @@ class Contacts {
136
145
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
137
146
  });
138
147
  if (_response.ok) {
139
- return _response.body;
148
+ return { data: _response.body, rawResponse: _response.rawResponse };
140
149
  }
141
150
  if (_response.error.reason === "status-code") {
142
151
  throw new errors.SurgeError({
143
152
  statusCode: _response.error.statusCode,
144
153
  body: _response.error.body,
154
+ rawResponse: _response.rawResponse,
145
155
  });
146
156
  }
147
157
  switch (_response.error.reason) {
@@ -149,12 +159,14 @@ class Contacts {
149
159
  throw new errors.SurgeError({
150
160
  statusCode: _response.error.statusCode,
151
161
  body: _response.error.rawBody,
162
+ rawResponse: _response.rawResponse,
152
163
  });
153
164
  case "timeout":
154
165
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling GET /contacts/{id}.");
155
166
  case "unknown":
156
167
  throw new errors.SurgeError({
157
168
  message: _response.error.errorMessage,
169
+ rawResponse: _response.rawResponse,
158
170
  });
159
171
  }
160
172
  });
@@ -178,12 +190,15 @@ class Contacts {
178
190
  * })
179
191
  */
180
192
  update(id, request, requestOptions) {
193
+ return core.HttpResponsePromise.fromPromise(this.__update(id, request, requestOptions));
194
+ }
195
+ __update(id, request, requestOptions) {
181
196
  return __awaiter(this, void 0, void 0, function* () {
182
197
  var _a, _b, _c;
183
198
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
184
199
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `contacts/${encodeURIComponent(id)}`),
185
200
  method: "PATCH",
186
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
201
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
187
202
  contentType: "application/json",
188
203
  requestType: "json",
189
204
  body: request,
@@ -192,12 +207,13 @@ class Contacts {
192
207
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
193
208
  });
194
209
  if (_response.ok) {
195
- return _response.body;
210
+ return { data: _response.body, rawResponse: _response.rawResponse };
196
211
  }
197
212
  if (_response.error.reason === "status-code") {
198
213
  throw new errors.SurgeError({
199
214
  statusCode: _response.error.statusCode,
200
215
  body: _response.error.body,
216
+ rawResponse: _response.rawResponse,
201
217
  });
202
218
  }
203
219
  switch (_response.error.reason) {
@@ -205,12 +221,14 @@ class Contacts {
205
221
  throw new errors.SurgeError({
206
222
  statusCode: _response.error.statusCode,
207
223
  body: _response.error.rawBody,
224
+ rawResponse: _response.rawResponse,
208
225
  });
209
226
  case "timeout":
210
227
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling PATCH /contacts/{id}.");
211
228
  case "unknown":
212
229
  throw new errors.SurgeError({
213
230
  message: _response.error.errorMessage,
231
+ rawResponse: _response.rawResponse,
214
232
  });
215
233
  }
216
234
  });
@@ -48,6 +48,7 @@ export declare class Messages {
48
48
  * }
49
49
  * })
50
50
  */
51
- send(accountId: string, request: Surge.MessageRequest, requestOptions?: Messages.RequestOptions): Promise<Surge.MessageResponse>;
51
+ send(accountId: string, request: Surge.MessageRequest, requestOptions?: Messages.RequestOptions): core.HttpResponsePromise<Surge.MessageResponse>;
52
+ private __send;
52
53
  protected _getAuthorizationHeader(): Promise<string>;
53
54
  }
@@ -80,12 +80,15 @@ class Messages {
80
80
  * })
81
81
  */
82
82
  send(accountId, request, requestOptions) {
83
+ return core.HttpResponsePromise.fromPromise(this.__send(accountId, request, requestOptions));
84
+ }
85
+ __send(accountId, request, requestOptions) {
83
86
  return __awaiter(this, void 0, void 0, function* () {
84
87
  var _a, _b, _c;
85
88
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
86
89
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `accounts/${encodeURIComponent(accountId)}/messages`),
87
90
  method: "POST",
88
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
91
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
89
92
  contentType: "application/json",
90
93
  requestType: "json",
91
94
  body: request,
@@ -94,12 +97,13 @@ class Messages {
94
97
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
95
98
  });
96
99
  if (_response.ok) {
97
- return _response.body;
100
+ return { data: _response.body, rawResponse: _response.rawResponse };
98
101
  }
99
102
  if (_response.error.reason === "status-code") {
100
103
  throw new errors.SurgeError({
101
104
  statusCode: _response.error.statusCode,
102
105
  body: _response.error.body,
106
+ rawResponse: _response.rawResponse,
103
107
  });
104
108
  }
105
109
  switch (_response.error.reason) {
@@ -107,12 +111,14 @@ class Messages {
107
111
  throw new errors.SurgeError({
108
112
  statusCode: _response.error.statusCode,
109
113
  body: _response.error.rawBody,
114
+ rawResponse: _response.rawResponse,
110
115
  });
111
116
  case "timeout":
112
117
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts/{account_id}/messages.");
113
118
  case "unknown":
114
119
  throw new errors.SurgeError({
115
120
  message: _response.error.errorMessage,
121
+ rawResponse: _response.rawResponse,
116
122
  });
117
123
  }
118
124
  });
@@ -39,6 +39,7 @@ export declare class PhoneNumbers {
39
39
  * type: "local"
40
40
  * })
41
41
  */
42
- create(accountId: string, request: Surge.CreatePhoneNumberRequest, requestOptions?: PhoneNumbers.RequestOptions): Promise<Surge.PhoneNumber>;
42
+ create(accountId: string, request: Surge.CreatePhoneNumberRequest, requestOptions?: PhoneNumbers.RequestOptions): core.HttpResponsePromise<Surge.PhoneNumber>;
43
+ private __create;
43
44
  protected _getAuthorizationHeader(): Promise<string>;
44
45
  }
@@ -71,12 +71,15 @@ class PhoneNumbers {
71
71
  * })
72
72
  */
73
73
  create(accountId, request, requestOptions) {
74
+ return core.HttpResponsePromise.fromPromise(this.__create(accountId, request, requestOptions));
75
+ }
76
+ __create(accountId, request, requestOptions) {
74
77
  return __awaiter(this, void 0, void 0, function* () {
75
78
  var _a, _b, _c;
76
79
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
77
80
  url: (0, url_join_1.default)((_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.SurgeEnvironment.Default, `accounts/${encodeURIComponent(accountId)}/phone_numbers`),
78
81
  method: "POST",
79
- headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.5", "User-Agent": "@surgeapi/node/0.25.5", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
82
+ headers: Object.assign({ Authorization: yield this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@surgeapi/node", "X-Fern-SDK-Version": "0.25.7", "User-Agent": "@surgeapi/node/0.25.7", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
80
83
  contentType: "application/json",
81
84
  requestType: "json",
82
85
  body: request,
@@ -85,12 +88,13 @@ class PhoneNumbers {
85
88
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
86
89
  });
87
90
  if (_response.ok) {
88
- return _response.body;
91
+ return { data: _response.body, rawResponse: _response.rawResponse };
89
92
  }
90
93
  if (_response.error.reason === "status-code") {
91
94
  throw new errors.SurgeError({
92
95
  statusCode: _response.error.statusCode,
93
96
  body: _response.error.body,
97
+ rawResponse: _response.rawResponse,
94
98
  });
95
99
  }
96
100
  switch (_response.error.reason) {
@@ -98,12 +102,14 @@ class PhoneNumbers {
98
102
  throw new errors.SurgeError({
99
103
  statusCode: _response.error.statusCode,
100
104
  body: _response.error.rawBody,
105
+ rawResponse: _response.rawResponse,
101
106
  });
102
107
  case "timeout":
103
108
  throw new errors.SurgeTimeoutError("Timeout exceeded when calling POST /accounts/{account_id}/phone_numbers.");
104
109
  case "unknown":
105
110
  throw new errors.SurgeError({
106
111
  message: _response.error.errorMessage,
112
+ rawResponse: _response.rawResponse,
107
113
  });
108
114
  }
109
115
  });
@@ -44,7 +44,8 @@ export declare class Users {
44
44
  * photo_url: "https://toretti.family/people/brian.jpg"
45
45
  * })
46
46
  */
47
- create(accountId: string, request: Surge.UserRequest, requestOptions?: Users.RequestOptions): Promise<Surge.UserResponse>;
47
+ create(accountId: string, request: Surge.UserRequest, requestOptions?: Users.RequestOptions): core.HttpResponsePromise<Surge.UserResponse>;
48
+ private __create;
48
49
  /**
49
50
  * Retrieves a User object.
50
51
  *
@@ -54,6 +55,7 @@ export declare class Users {
54
55
  * @example
55
56
  * await client.users.getUser("usr_01j9dwavghe1ttppewekjjkfrx")
56
57
  */
57
- getUser(id: string, requestOptions?: Users.RequestOptions): Promise<Surge.UserResponse>;
58
+ getUser(id: string, requestOptions?: Users.RequestOptions): core.HttpResponsePromise<Surge.UserResponse>;
59
+ private __getUser;
58
60
  protected _getAuthorizationHeader(): Promise<string>;
59
61
  }