pingram 1.0.3 → 1.0.4

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.
@@ -138,7 +138,8 @@ export interface GetLogsResponseMessagesInner {
138
138
  export declare enum GetLogsResponseMessagesInnerResolutionTypeEnum {
139
139
  REPLY = "reply",
140
140
  BUILTIN = "builtin",
141
- CUSTOM = "custom"
141
+ CUSTOM = "custom",
142
+ INBOUND = "inbound"
142
143
  }
143
144
  /**
144
145
  * Check if a given object implements the GetLogsResponseMessagesInner interface.
@@ -29,6 +29,7 @@ var GetLogsResponseMessagesInnerResolutionTypeEnum;
29
29
  GetLogsResponseMessagesInnerResolutionTypeEnum["REPLY"] = "reply";
30
30
  GetLogsResponseMessagesInnerResolutionTypeEnum["BUILTIN"] = "builtin";
31
31
  GetLogsResponseMessagesInnerResolutionTypeEnum["CUSTOM"] = "custom";
32
+ GetLogsResponseMessagesInnerResolutionTypeEnum["INBOUND"] = "inbound";
32
33
  })(GetLogsResponseMessagesInnerResolutionTypeEnum || (exports.GetLogsResponseMessagesInnerResolutionTypeEnum = GetLogsResponseMessagesInnerResolutionTypeEnum = {}));
33
34
  /**
34
35
  * Check if a given object implements the GetLogsResponseMessagesInner interface.
@@ -107,7 +107,9 @@ class BaseAPI {
107
107
  }
108
108
  if (response === undefined) {
109
109
  if (e instanceof Error) {
110
- throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
110
+ const msg = e.message ||
111
+ 'The request failed and the interceptors did not return an alternative response';
112
+ throw new FetchError(e, msg);
111
113
  }
112
114
  else {
113
115
  throw e;
@@ -164,7 +166,27 @@ class BaseAPI {
164
166
  if (response && response.status >= 200 && response.status < 300) {
165
167
  return response;
166
168
  }
167
- throw new ResponseError(response, 'Response returned an error code');
169
+ let errorMessage = 'Response returned an error code';
170
+ if (response) {
171
+ try {
172
+ const body = (await response.clone().json());
173
+ if (body?.message) {
174
+ errorMessage = body.message;
175
+ }
176
+ else if (Array.isArray(body?.messages) && body.messages.length > 0) {
177
+ errorMessage = body.messages[0];
178
+ }
179
+ else {
180
+ errorMessage =
181
+ response.statusText || `Request failed (${response.status})`;
182
+ }
183
+ }
184
+ catch {
185
+ errorMessage =
186
+ response.statusText || `Request failed (${response.status})`;
187
+ }
188
+ }
189
+ throw new ResponseError(response, errorMessage);
168
190
  }
169
191
  async createFetchParams(context, initOverrides) {
170
192
  let url = this.configuration.basePath + context.path;
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.Pingram = void 0;
9
9
  const src_1 = require("../generated/src");
10
10
  // SDK version for User-Agent header (injected at codegen time)
11
- const SDK_VERSION = '1.0.3';
11
+ const SDK_VERSION = '1.0.4';
12
12
  const USER_AGENT = `pingram-node/${SDK_VERSION}`;
13
13
  const src_2 = require("../generated/src");
14
14
  const src_3 = require("../generated/src");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pingram",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Official Node.js SDK for Pingram - Send notifications via Email, SMS, Push, In-App, and more",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",