Skip to content

Commit 6a305c8

Browse files
feat: add client token notification events and related mocks (#172)
1 parent ca59e04 commit 6a305c8

File tree

19 files changed

+312
-2
lines changed

19 files changed

+312
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
import { IClientTokenNotificationResponse } from '../../../notifications/index.js';
8+
import { IEventsResponse } from '../../../types/index.js';
9+
10+
export const ClientTokenCreatedMock: IEventsResponse<IClientTokenNotificationResponse> = {
11+
event_id: 'evt_01jkdr0rc527wcjdg1txsdxhtf',
12+
event_type: 'client_token.created',
13+
occurred_at: '2025-06-26T14:36:14.695521Z',
14+
notification_id: 'ntf_01jkdr1mgbe62eqkh3p0fq8b0h',
15+
data: {
16+
id: 'ctkn_01ghbkd0frb9k95cnhwd1bxpvk',
17+
token: 'live_7d279f61a3499fed520f7cd8c08',
18+
name: 'Pricing page integration',
19+
description: 'Used to display prices and open checkout within our pricing page on our marketing domain.',
20+
status: 'active',
21+
created_at: '2025-06-26T14:36:14.695521Z',
22+
updated_at: '2025-06-26T14:36:14.695521Z',
23+
revoked_at: null,
24+
},
25+
};
26+
27+
export const ClientTokenCreatedMockExpectation = {
28+
data: {
29+
id: 'ctkn_01ghbkd0frb9k95cnhwd1bxpvk',
30+
token: 'live_7d279f61a3499fed520f7cd8c08',
31+
name: 'Pricing page integration',
32+
description: 'Used to display prices and open checkout within our pricing page on our marketing domain.',
33+
status: 'active',
34+
createdAt: '2025-06-26T14:36:14.695521Z',
35+
updatedAt: '2025-06-26T14:36:14.695521Z',
36+
revokedAt: null,
37+
},
38+
eventId: 'evt_01jkdr0rc527wcjdg1txsdxhtf',
39+
eventType: 'client_token.created',
40+
occurredAt: '2025-06-26T14:36:14.695521Z',
41+
notificationId: 'ntf_01jkdr1mgbe62eqkh3p0fq8b0h',
42+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
import { IClientTokenNotificationResponse } from '../../../notifications/index.js';
8+
import { IEventsResponse } from '../../../types/index.js';
9+
10+
export const ClientTokenRevokedMock: IEventsResponse<IClientTokenNotificationResponse> = {
11+
event_id: 'evt_01jkdr0rc527wcjdg1txsdxhtf',
12+
event_type: 'client_token.revoked',
13+
occurred_at: '2025-06-27T11:26:10.253482Z',
14+
notification_id: 'ntf_01jkb92mpl7v4rfg8x3q5wz7bn',
15+
data: {
16+
id: 'ctkn_01ghbkd0frb9k95cnhwd1bxpvk',
17+
token: 'live_7d279f61a3499fed520f7cd8c08',
18+
name: 'Pricing page integration',
19+
description: 'Used to display prices and open checkout within our pricing page on our marketing domain.',
20+
status: 'revoked',
21+
created_at: '2025-06-26T14:36:14.695521Z',
22+
updated_at: '2025-06-27T11:26:10.253482Z',
23+
revoked_at: '2025-06-27T11:26:10.253482Z',
24+
},
25+
};
26+
27+
export const ClientTokenRevokedMockExpectation = {
28+
data: {
29+
id: 'ctkn_01ghbkd0frb9k95cnhwd1bxpvk',
30+
token: 'live_7d279f61a3499fed520f7cd8c08',
31+
name: 'Pricing page integration',
32+
description: 'Used to display prices and open checkout within our pricing page on our marketing domain.',
33+
status: 'revoked',
34+
createdAt: '2025-06-26T14:36:14.695521Z',
35+
updatedAt: '2025-06-27T11:26:10.253482Z',
36+
revokedAt: '2025-06-27T11:26:10.253482Z',
37+
},
38+
eventId: 'evt_01jkdr0rc527wcjdg1txsdxhtf',
39+
eventType: 'client_token.revoked',
40+
occurredAt: '2025-06-27T11:26:10.253482Z',
41+
notificationId: 'ntf_01jkb92mpl7v4rfg8x3q5wz7bn',
42+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
import { IClientTokenNotificationResponse } from '../../../notifications/index.js';
8+
import { IEventsResponse } from '../../../types/index.js';
9+
10+
export const ClientTokenUpdatedMock: IEventsResponse<IClientTokenNotificationResponse> = {
11+
event_id: 'evt_01jkdr0rc527wcjdg1txsdxhtf',
12+
event_type: 'client_token.updated',
13+
occurred_at: '2025-06-27T11:26:10.253482Z',
14+
notification_id: 'ntf_01jkr4d5s6f7g8h9j1k2l3q4rs',
15+
data: {
16+
id: 'ctkn_01ghbkd0frb9k95cnhwd1bxpvk',
17+
token: 'live_7d279f61a3499fed520f7cd8c08',
18+
name: 'Pricing page integration',
19+
description: 'Used to display prices and open checkout within our pricing page on our marketing domain.',
20+
status: 'revoked',
21+
created_at: '2025-06-26T14:36:14.695521Z',
22+
updated_at: '2025-06-27T11:26:10.253482Z',
23+
revoked_at: '2025-06-27T11:26:10.253482Z',
24+
},
25+
};
26+
27+
export const ClientTokenUpdatedMockExpectation = {
28+
data: {
29+
id: 'ctkn_01ghbkd0frb9k95cnhwd1bxpvk',
30+
token: 'live_7d279f61a3499fed520f7cd8c08',
31+
name: 'Pricing page integration',
32+
description: 'Used to display prices and open checkout within our pricing page on our marketing domain.',
33+
status: 'revoked',
34+
createdAt: '2025-06-26T14:36:14.695521Z',
35+
updatedAt: '2025-06-27T11:26:10.253482Z',
36+
revokedAt: '2025-06-27T11:26:10.253482Z',
37+
},
38+
eventId: 'evt_01jkdr0rc527wcjdg1txsdxhtf',
39+
eventType: 'client_token.updated',
40+
occurredAt: '2025-06-27T11:26:10.253482Z',
41+
notificationId: 'ntf_01jkr4d5s6f7g8h9j1k2l3q4rs',
42+
};

src/__tests__/notifications/notifications-parser.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,18 @@ import {
134134
DiscountGroupUpdatedMock,
135135
DiscountGroupUpdatedMockExpectation,
136136
} from '../mocks/notifications/discount-group-updated.mock.js';
137+
import {
138+
ClientTokenCreatedMock,
139+
ClientTokenCreatedMockExpectation,
140+
} from '../mocks/notifications/client-token-created.mock.js';
141+
import {
142+
ClientTokenUpdatedMock,
143+
ClientTokenUpdatedMockExpectation,
144+
} from '../mocks/notifications/client-token-updated.mock.js';
145+
import {
146+
ClientTokenRevokedMock,
147+
ClientTokenRevokedMockExpectation,
148+
} from '../mocks/notifications/client-token-revoked.mock.js';
137149

138150
describe('Notifications Parser', () => {
139151
test.each([
@@ -150,6 +162,9 @@ describe('Notifications Parser', () => {
150162
[BusinessCreatedMock.event_type, BusinessCreatedMock, BusinessCreatedMockExpectation],
151163
[BusinessUpdatedMock.event_type, BusinessUpdatedMock, BusinessUpdatedMockExpectation],
152164
[BusinessImportedMock.event_type, BusinessImportedMock, BusinessImportedMockExpectation],
165+
[ClientTokenCreatedMock.event_type, ClientTokenCreatedMock, ClientTokenCreatedMockExpectation],
166+
[ClientTokenUpdatedMock.event_type, ClientTokenUpdatedMock, ClientTokenUpdatedMockExpectation],
167+
[ClientTokenRevokedMock.event_type, ClientTokenRevokedMock, ClientTokenRevokedMockExpectation],
153168
[CustomerCreatedMock.event_type, CustomerCreatedMock, CustomerCreatedMockExpectation],
154169
[CustomerUpdatedMock.event_type, CustomerUpdatedMock, CustomerUpdatedMockExpectation],
155170
[CustomerImportedMock.event_type, CustomerImportedMock, CustomerImportedMockExpectation],
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
import { ClientTokenStatus } from '../../../enums/index.js';
7+
import { IClientTokenNotificationResponse } from '../../types/index.js';
8+
9+
export class ClientTokenNotification {
10+
public readonly id: string;
11+
public readonly token: string;
12+
public readonly name: string;
13+
public readonly description: string | null;
14+
public readonly status: ClientTokenStatus;
15+
public readonly createdAt: string;
16+
public readonly updatedAt: string;
17+
public readonly revokedAt: string | null;
18+
19+
constructor(clientToken: IClientTokenNotificationResponse) {
20+
this.id = clientToken.id;
21+
this.token = clientToken.token;
22+
this.name = clientToken.name;
23+
this.description = clientToken.description ?? null;
24+
this.status = clientToken.status;
25+
this.createdAt = clientToken.created_at;
26+
this.updatedAt = clientToken.updated_at;
27+
this.revokedAt = clientToken.revoked_at ?? null;
28+
}
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
export * from './client-token-notification.js';

src/notifications/entities/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ export * from './payout/index.js';
1919
export * from './report/index.js';
2020
export * from './shared/index.js';
2121
export * from './api-key/index.js';
22+
export * from './client-token/index.js';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
import { Event } from '../../../entities/events/event.js';
8+
import { EventName } from '../../helpers/index.js';
9+
import { ClientTokenNotification } from '../../entities/index.js';
10+
import { type IEventsResponse } from '../../../types/index.js';
11+
import { IClientTokenNotificationResponse } from '../../types/index.js';
12+
13+
export class ClientTokenCreatedEvent extends Event {
14+
public override readonly eventType = EventName.ClientTokenCreated;
15+
public override readonly data: ClientTokenNotification;
16+
17+
constructor(response: IEventsResponse<IClientTokenNotificationResponse>) {
18+
super(response);
19+
this.data = new ClientTokenNotification(response.data);
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
import { Event } from '../../../entities/events/event.js';
8+
import { EventName } from '../../helpers/index.js';
9+
import { ClientTokenNotification } from '../../entities/index.js';
10+
import { type IEventsResponse } from '../../../types/index.js';
11+
import { IClientTokenNotificationResponse } from '../../types/index.js';
12+
13+
export class ClientTokenRevokedEvent extends Event {
14+
public override readonly eventType = EventName.ClientTokenRevoked;
15+
public override readonly data: ClientTokenNotification;
16+
17+
constructor(response: IEventsResponse<IClientTokenNotificationResponse>) {
18+
super(response);
19+
this.data = new ClientTokenNotification(response.data);
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
import { Event } from '../../../entities/events/event.js';
8+
import { EventName } from '../../helpers/index.js';
9+
import { ClientTokenNotification } from '../../entities/index.js';
10+
import { type IEventsResponse } from '../../../types/index.js';
11+
import { IClientTokenNotificationResponse } from '../../types/index.js';
12+
13+
export class ClientTokenUpdatedEvent extends Event {
14+
public override readonly eventType = EventName.ClientTokenUpdated;
15+
public override readonly data: ClientTokenNotification;
16+
17+
constructor(response: IEventsResponse<IClientTokenNotificationResponse>) {
18+
super(response);
19+
this.data = new ClientTokenNotification(response.data);
20+
}
21+
}

0 commit comments

Comments
 (0)