attlaz-client 1.9.0 → 1.9.2

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.
@@ -1,6 +1,7 @@
1
1
  export declare class CollectionResult<T> {
2
2
  private data;
3
+ hasMore: boolean;
3
4
  constructor();
4
- setData(data: T[]): void;
5
+ setData(data: T[], hasMore: boolean): void;
5
6
  getData(): T[];
6
7
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CollectionResult = void 0;
4
4
  class CollectionResult {
5
5
  constructor() {
6
+ this.hasMore = false;
6
7
  this.data = [];
7
8
  }
8
9
  // public static parse<T>(raw: any): DataResult<T> {
@@ -17,8 +18,9 @@ class CollectionResult {
17
18
  //
18
19
  // return result;
19
20
  // }
20
- setData(data) {
21
+ setData(data, hasMore) {
21
22
  this.data = data;
23
+ this.hasMore = hasMore;
22
24
  }
23
25
  getData() {
24
26
  return this.data;
@@ -2,7 +2,6 @@ import { Endpoint } from './Endpoint';
2
2
  import { Adapter } from '../Model/Adapter/Adapter';
3
3
  import { AdapterConnection } from '../Model/Adapter/AdapterConnection';
4
4
  import { AdapterConfiguration } from '../Model/Adapter/AdapterConfiguration';
5
- import { ObjectResult } from '../Model/Result/ObjectResult';
6
5
  import { CollectionResult } from '../Model/Result/CollectionResult';
7
6
  export declare class AdapterEndpoint extends Endpoint {
8
7
  getAdapters(): Promise<CollectionResult<Adapter>>;
@@ -10,5 +9,5 @@ export declare class AdapterEndpoint extends Endpoint {
10
9
  getAdapterConfiguration(adapterId: string): Promise<CollectionResult<AdapterConfiguration>>;
11
10
  getConnections(projectId: string): Promise<CollectionResult<AdapterConnection>>;
12
11
  getConnectionByKey(connectionKey: string): Promise<AdapterConnection | null>;
13
- saveConnection(projectId: string, adapter: AdapterConnection): Promise<ObjectResult<AdapterConnection>>;
12
+ saveConnection(projectId: string, adapter: AdapterConnection): Promise<AdapterConnection>;
14
13
  }
@@ -75,7 +75,11 @@ class AdapterEndpoint extends Endpoint_1.Endpoint {
75
75
  try {
76
76
  let url = '/projects/' + projectId + '/connections';
77
77
  const result = await this.requestObject(url, adapter, AdapterConnection_1.AdapterConnection.parse, 'POST');
78
- return result;
78
+ const updatedAdapterConnection = result.getData();
79
+ if (updatedAdapterConnection === null) {
80
+ throw new Error('AdapterConnection not updated');
81
+ }
82
+ return updatedAdapterConnection;
79
83
  }
80
84
  catch (error) {
81
85
  if (this.httpClient.isDebugEnabled()) {
@@ -7,6 +7,6 @@ export declare class ChannelEndpoint extends Endpoint {
7
7
  getByWorkspace(workspaceId: string): Promise<CollectionResult<Channel>>;
8
8
  getByOwner(): Promise<CollectionResult<Channel>>;
9
9
  getMessages(channelId: string): Promise<CollectionResult<ChannelHistory>>;
10
- save(subscriberChannel: Channel): Promise<Channel | null>;
10
+ save(subscriberChannel: Channel): Promise<Channel>;
11
11
  testChannel(subscriberChannel: Channel): Promise<any>;
12
12
  }
@@ -81,7 +81,11 @@ class ChannelEndpoint extends Endpoint_1.Endpoint {
81
81
  try {
82
82
  let url = '/channels/';
83
83
  const result = await this.requestObject(url, subscriberChannel, Channel_1.Channel.parse, 'POST');
84
- return result.getData();
84
+ const updatedChannel = result.getData();
85
+ if (updatedChannel === null) {
86
+ throw new Error('Channel not updated');
87
+ }
88
+ return updatedChannel;
85
89
  }
86
90
  catch (ex) {
87
91
  if (this.httpClient.isDebugEnabled()) {
@@ -5,6 +5,7 @@ const DataResult_1 = require("../Model/Result/DataResult");
5
5
  const CollectionResult_1 = require("../Model/Result/CollectionResult");
6
6
  const ObjectResult_1 = require("../Model/Result/ObjectResult");
7
7
  const HttpClient_1 = require("../Http/HttpClient");
8
+ const Utils_1 = require("../Utils");
8
9
  class Endpoint {
9
10
  constructor(httpClient) {
10
11
  this.httpClient = httpClient;
@@ -22,7 +23,11 @@ class Endpoint {
22
23
  if (!requestResponse.hasOwnProperty('data') || requestResponse.data === undefined) {
23
24
  throw new Error('Unable to parse collection: data is not defined');
24
25
  }
25
- result.setData(this.parseCollection(requestResponse.data, parser));
26
+ if (!requestResponse.hasOwnProperty('has_more') || requestResponse.has_more === undefined) {
27
+ throw new Error('Unable to parse collection: hasMore is not defined');
28
+ }
29
+ const hasMore = Utils_1.Utils.isTrue(requestResponse.has_more);
30
+ result.setData(this.parseCollection(requestResponse.data, parser), hasMore);
26
31
  return result;
27
32
  }
28
33
  async requestObject(action, parameters = null, parser, method = 'GET', signWithOauthToken = true) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.9.0";
1
+ export declare const VERSION = "1.9.2";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "1.9.0";
4
+ exports.VERSION = "1.9.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",