attlaz-client 1.18.0 → 1.18.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.
@@ -155,15 +155,15 @@ export class OAuthClient {
155
155
  return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
156
156
  }
157
157
  tokenToOauthClientToken(oauthToken) {
158
- // console.log('Auth token', oauthToken);
159
- // let scopes: string = '';
160
- // if (Object.prototype.hasOwnProperty.call(oauthToken.data, 'scopes')) {
161
- // scopes = oauthToken.data.scopes;
162
- // } else if (Object.prototype.hasOwnProperty.call(oauthToken.data, 'scope')) {
163
- // scopes = oauthToken.data.scope;
164
- // }
158
+ let scopes = '';
159
+ if (Object.prototype.hasOwnProperty.call(oauthToken, 'scopes') && oauthToken.scopes !== undefined) {
160
+ scopes = oauthToken.scopes;
161
+ }
162
+ else if (Object.prototype.hasOwnProperty.call(oauthToken, 'scope') && oauthToken.scope !== undefined) {
163
+ scopes = oauthToken.scope;
164
+ }
165
165
  const refreshToken = oauthToken.refresh_token === undefined || oauthToken.refresh_token === null ? null : oauthToken.refresh_token;
166
- const token = new OAuthClientToken(oauthToken.access_token, oauthToken.token_type, refreshToken, oauthToken.scope);
166
+ const token = new OAuthClientToken(oauthToken.access_token, oauthToken.token_type, refreshToken, scopes);
167
167
  const t = new Date();
168
168
  t.setSeconds(t.getSeconds() + oauthToken.expires_in);
169
169
  token.expires = t;
@@ -1,8 +1,9 @@
1
1
  import { Endpoint } from './Endpoint.js';
2
2
  import { Subscriber } from '../Model/Messaging/Subscriber.js';
3
3
  import { CollectionResult } from '../Model/Result/CollectionResult.js';
4
+ import { CursorPagination } from '../Model/Pagination/CursorPagination.js';
4
5
  export declare class SubscriberEndpoint extends Endpoint {
5
- getSubscribersByFlow(flowId: string, projectEnvironmentId?: string | null): Promise<CollectionResult<Subscriber>>;
6
- getSubscribersByChannel(channelId: string): Promise<CollectionResult<Subscriber>>;
6
+ getSubscribersByFlow(flowId: string, projectEnvironmentId?: string | null, pagination?: CursorPagination | null): Promise<CollectionResult<Subscriber>>;
7
+ getSubscribersByChannel(channelId: string, pagination?: CursorPagination | null): Promise<CollectionResult<Subscriber>>;
7
8
  save(subscriber: Subscriber): Promise<Subscriber>;
8
9
  }
@@ -1,17 +1,20 @@
1
1
  import { Endpoint } from './Endpoint.js';
2
2
  import { Subscriber } from '../Model/Messaging/Subscriber.js';
3
- import { Utils } from '../Utils.js';
3
+ import { QueryString } from '../Http/Data/QueryString.js';
4
4
  export class SubscriberEndpoint extends Endpoint {
5
- async getSubscribersByFlow(flowId, projectEnvironmentId = null) {
6
- let parameters = null;
7
- if (!Utils.isNullOrUndefined(projectEnvironmentId)) {
8
- parameters = { environment: projectEnvironmentId };
5
+ async getSubscribersByFlow(flowId, projectEnvironmentId = null, pagination = null) {
6
+ const qu = new QueryString('/flows/' + flowId + '/subscribers');
7
+ if (projectEnvironmentId !== null && projectEnvironmentId !== undefined) {
8
+ qu.set('environment', projectEnvironmentId);
9
9
  }
10
- const result = await this.requestCollection('/flows/' + flowId + '/subscribers', Subscriber.parseRaw, parameters);
10
+ qu.addPagination(pagination);
11
+ const result = await this.requestCollection(qu, Subscriber.parseRaw);
11
12
  return result;
12
13
  }
13
- async getSubscribersByChannel(channelId) {
14
- const result = await this.requestCollection('/channels/' + channelId + '/subscribers', Subscriber.parseRaw);
14
+ async getSubscribersByChannel(channelId, pagination = null) {
15
+ const qu = new QueryString('/channels/' + channelId + '/subscribers');
16
+ qu.addPagination(pagination);
17
+ const result = await this.requestCollection(qu, Subscriber.parseRaw);
15
18
  return result;
16
19
  }
17
20
  async save(subscriber) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.18.0",
3
+ "version": "1.18.2",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -47,15 +47,16 @@
47
47
  "devDependencies": {
48
48
  "@types/jest": "^29.5.2",
49
49
  "@types/node": "^22.1.0",
50
- "@typescript-eslint/eslint-plugin": "^8.12.2",
51
- "@typescript-eslint/parser": "^8.12.2",
52
50
  "dotenv": "^16.3.1",
53
- "eslint": "^8.42.0",
54
- "eslint-config-airbnb-base": "^15.0.0",
51
+ "eslint-config-attlaz-base": "^1.0.17",
52
+ "eslint": "^9.14.0",
53
+ "eslint-import-resolver-typescript": "^3.6.1",
55
54
  "eslint-plugin-import": "^2.27.5",
56
- "eslint-plugin-jsdoc": "^50.4.3",
55
+ "eslint-plugin-jsdoc": "^50.1.0",
57
56
  "eslint-plugin-prefer-arrow": "^1.2.3",
58
- "eslint-plugin-promise": "^7.0.0",
57
+ "eslint-plugin-promise": "^7.1.0",
58
+ "@typescript-eslint/eslint-plugin": "^8.1.0",
59
+ "@typescript-eslint/parser": "^8.1.0",
59
60
  "jest": "^29.5.0",
60
61
  "rimraf": "^6.0.1",
61
62
  "rollup-plugin-commonjs": "^10.1.0",