attlaz-client 1.31.0 → 1.32.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.
@@ -109,31 +109,27 @@ export class Endpoint {
109
109
  if (action instanceof QueryString) {
110
110
  action = action.build();
111
111
  }
112
- const result = new ObjectResult();
112
+ let requestResponse;
113
113
  try {
114
- let requestResponse = await this.httpClient.request(action, parameters, method, signWithOauthToken);
115
- // TODO: add errors
116
- /**
117
- * Parse errors
118
- */
119
- // TODO: temporary check until we know the API is fully upgraded
120
- if (requestResponse === null || requestResponse === undefined) {
121
- throw new Error('Unable to parse object: response is empty for action `[' + method + '] ' + action + '`');
122
- }
123
- if ((Object.prototype.hasOwnProperty.call(requestResponse, 'data') && !Object.prototype.hasOwnProperty.call(requestResponse, 'id')) && requestResponse.data !== undefined) {
124
- console.error('Response for object "' + action + '" seem to still use old "data" property (this property is only used for collection requests)', { requestResponse });
125
- requestResponse = requestResponse.data;
126
- }
127
- result.setData(this.parseObject(requestResponse, parser));
114
+ requestResponse = await this.httpClient.request(action, parameters, method, signWithOauthToken);
128
115
  }
129
116
  catch (error) {
130
- if (error.httpStatus === HttpStatus.HTTP_NOTFOUND) {
131
- result.setData(null);
132
- }
133
- else {
134
- throw this.toApiError(error);
135
- }
117
+ throw this.toApiError(error);
118
+ }
119
+ const result = new ObjectResult();
120
+ // TODO: add errors
121
+ /**
122
+ * Parse errors
123
+ */
124
+ // TODO: temporary check until we know the API is fully upgraded
125
+ if (requestResponse === null || requestResponse === undefined) {
126
+ throw new ApiError('Unable to parse object: response is empty for action `[' + method + '] ' + action + '`', HttpStatus.HTTP_INTERNAL_SERVER_ERROR);
127
+ }
128
+ if ((Object.prototype.hasOwnProperty.call(requestResponse, 'data') && !Object.prototype.hasOwnProperty.call(requestResponse, 'id')) && requestResponse.data !== undefined) {
129
+ console.error('Response for object "' + action + '" seem to still use old "data" property (this property is only used for collection requests)', { requestResponse });
130
+ requestResponse = requestResponse.data;
136
131
  }
132
+ result.setData(this.parseObject(requestResponse, parser));
137
133
  return result;
138
134
  }
139
135
  toApiError(error) {
@@ -159,6 +155,8 @@ export class Endpoint {
159
155
  }
160
156
  return apiError;
161
157
  }
158
+ // TODO: remove this
159
+ console.log('Not client error', { error });
162
160
  return new ApiError('Unknown Error', HttpStatus.HTTP_INTERNAL_SERVER_ERROR);
163
161
  }
164
162
  // public async request<T>(action: string, parameters: any | null = null, method: string = 'GET', signWithOauthToken: boolean = true): Promise<DataResult<T>> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",