notifications-node-client 8.3.0 → 8.3.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.
Files changed (38) hide show
  1. package/package.json +7 -2
  2. package/types/client/api_client.d.ts +44 -0
  3. package/types/client/authentication.d.ts +2 -0
  4. package/types/client/notification.d.ts +365 -0
  5. package/types/index.d.ts +3 -0
  6. package/.dockerignore +0 -1
  7. package/.github/PULL_REQUEST_TEMPLATE.md +0 -18
  8. package/CHANGELOG.md +0 -297
  9. package/CONTRIBUTING.md +0 -59
  10. package/Dockerfile +0 -17
  11. package/Makefile +0 -42
  12. package/scripts/run_with_docker.sh +0 -21
  13. package/scripts/test_send.js +0 -57
  14. package/spec/api_client.js +0 -156
  15. package/spec/authentication.js +0 -32
  16. package/spec/integration/schemas/v1/GET_notifications_return.json +0 -37
  17. package/spec/integration/schemas/v1/POST_notification_return_email.json +0 -27
  18. package/spec/integration/schemas/v1/POST_notification_return_sms.json +0 -26
  19. package/spec/integration/schemas/v1/definitions.json +0 -12
  20. package/spec/integration/schemas/v1/email_notification.json +0 -106
  21. package/spec/integration/schemas/v1/sms_notification.json +0 -104
  22. package/spec/integration/schemas/v2/GET_notification_response.json +0 -50
  23. package/spec/integration/schemas/v2/GET_notifications_response.json +0 -29
  24. package/spec/integration/schemas/v2/GET_received_text_response.json +0 -23
  25. package/spec/integration/schemas/v2/GET_received_texts_response.json +0 -29
  26. package/spec/integration/schemas/v2/GET_template_by_id.json +0 -30
  27. package/spec/integration/schemas/v2/GET_templates_response.json +0 -15
  28. package/spec/integration/schemas/v2/POST_notification_email_response.json +0 -18
  29. package/spec/integration/schemas/v2/POST_notification_letter_response.json +0 -19
  30. package/spec/integration/schemas/v2/POST_notification_precompiled_letter_response.json +0 -19
  31. package/spec/integration/schemas/v2/POST_notification_sms_response.json +0 -18
  32. package/spec/integration/schemas/v2/POST_template_preview.json +0 -14
  33. package/spec/integration/schemas/v2/definitions.json +0 -51
  34. package/spec/integration/test.js +0 -415
  35. package/spec/integration/test_files/one_page_pdf.pdf +0 -0
  36. package/spec/notification.js +0 -633
  37. package/spec/test_files/simple.csv +0 -2
  38. package/spec/types-test.ts +0 -153
@@ -1,153 +0,0 @@
1
- // This file is compiled with tsc --noEmit to verify the generated types work correctly.
2
- // It is NOT run as a test - it only needs to type-check.
3
-
4
- import { NotifyClient } from '..';
5
-
6
- // Constructor overloads
7
- const client1 = new NotifyClient('apiKeyId');
8
- const client2 = new NotifyClient('https://example.com', 'apiKeyId');
9
- const client3 = new NotifyClient('https://example.com', 'serviceId', 'apiKeyId');
10
-
11
- // sendEmail
12
- async function testSendEmail() {
13
- const response = await client1.sendEmail('template-id', 'test@example.com', {
14
- personalisation: { name: 'Test' },
15
- reference: 'ref-123',
16
- emailReplyToId: 'reply-to-id',
17
- oneClickUnsubscribeURL: 'https://example.com/unsub',
18
- });
19
- const id: string = response.data.id;
20
- const subject: string = response.data.content.subject;
21
- const fromEmail: string = response.data.content.from_email;
22
- const unsubUrl: string | undefined = response.data.content.one_click_unsubscribe_url;
23
- const templateId: string = response.data.template.id;
24
- const templateVersion: number = response.data.template.version;
25
- const templateUri: string = response.data.template.uri;
26
- }
27
-
28
- // sendSms
29
- async function testSendSms() {
30
- const response = await client1.sendSms('template-id', '07123456789', {
31
- personalisation: { code: '1234' },
32
- reference: 'ref-123',
33
- smsSenderId: 'sender-id',
34
- });
35
- const id: string = response.data.id;
36
- const body: string = response.data.content.body;
37
- const fromNumber: string = response.data.content.from_number;
38
- }
39
-
40
- // sendLetter
41
- async function testSendLetter() {
42
- const response = await client1.sendLetter('template-id', {
43
- personalisation: { address_line_1: 'Mr Test', address_line_2: '1 Test St', postcode: 'SW1A 1AA' },
44
- reference: 'ref-123',
45
- });
46
- const id: string = response.data.id;
47
- const scheduledFor: string | null = response.data.scheduled_for;
48
- }
49
-
50
- // sendPrecompiledLetter
51
- async function testSendPrecompiledLetter() {
52
- const response = await client1.sendPrecompiledLetter('ref', Buffer.from('pdf'), 'first');
53
- const id: string = response.data.id;
54
- const postage: string = response.data.postage;
55
- }
56
-
57
- // getNotificationById
58
- async function testGetNotificationById() {
59
- const response = await client1.getNotificationById('notification-id');
60
- const id: string = response.data.id;
61
- const type: "sms" | "letter" | "email" = response.data.type;
62
- const status: string = response.data.status;
63
- const body: string = response.data.body;
64
- const createdAt: string = response.data.created_at;
65
- const isCostDataReady: boolean = response.data.is_cost_data_ready;
66
- const emailAddress: string | undefined = response.data.email_address;
67
- const phoneNumber: string | undefined = response.data.phone_number;
68
- const subject: string | undefined = response.data.subject;
69
- const createdByName: string | undefined = response.data.created_by_name;
70
- const sentAt: string | undefined = response.data.sent_at;
71
- const completedAt: string | undefined = response.data.completed_at;
72
- const scheduledFor: string | undefined = response.data.scheduled_for;
73
- const oneClickUnsubscribe: string | undefined = response.data.one_click_unsubscribe;
74
- const costInPounds: number | undefined = response.data.cost_in_pounds;
75
- const line1: string | undefined = response.data.line_1;
76
- }
77
-
78
- // getNotifications
79
- async function testGetNotifications() {
80
- const response = await client1.getNotifications('sms', 'delivered', 'ref', 'older-than-id');
81
- const notifications = response.data.notifications;
82
- const firstNotification = notifications[0];
83
- const type: "sms" | "letter" | "email" = firstNotification.type;
84
- const links = response.data.links;
85
- const current: string = links.current;
86
- const next: string = links.next;
87
- }
88
-
89
- // getPdfForLetterNotification
90
- async function testGetPdf() {
91
- const pdf: Buffer = await client1.getPdfForLetterNotification('notification-id');
92
- }
93
-
94
- // getTemplateById
95
- async function testGetTemplateById() {
96
- const response = await client1.getTemplateById('template-id');
97
- const id: string = response.data.id;
98
- const name: string = response.data.name;
99
- const type: "sms" | "letter" | "email" = response.data.type;
100
- const createdAt: string = response.data.created_at;
101
- const version: number = response.data.version;
102
- const body: string = response.data.body;
103
- const letterContactBlock: string | undefined = response.data.letter_contact_block;
104
- const postage: string | undefined = response.data.postage;
105
- }
106
-
107
- // getTemplateByIdAndVersion
108
- async function testGetTemplateByIdAndVersion() {
109
- const response = await client1.getTemplateByIdAndVersion('template-id', 3);
110
- const id: string = response.data.id;
111
- }
112
-
113
- // getAllTemplates
114
- async function testGetAllTemplates() {
115
- const response = await client1.getAllTemplates('email');
116
- const templates = response.data.templates;
117
- const first = templates[0];
118
- const type: "sms" | "letter" | "email" = first.type;
119
- }
120
-
121
- // previewTemplateById
122
- async function testPreviewTemplateById() {
123
- const response = await client1.previewTemplateById('template-id', { name: 'Test' });
124
- const id: string = response.data.id;
125
- const type: "sms" | "letter" | "email" = response.data.type;
126
- const body: string = response.data.body;
127
- const html: string | undefined = response.data.html;
128
- const postage: "first" | "second" | "economy" | "europe" | "rest-of-world" | undefined = response.data.postage;
129
- }
130
-
131
- // getReceivedTexts
132
- async function testGetReceivedTexts() {
133
- const response = await client1.getReceivedTexts('older-than-id');
134
- const messages = response.data.received_text_messages;
135
- const first = messages[0];
136
- const userNumber: string = first.user_number;
137
- const serviceId: string = first.service_id;
138
- }
139
-
140
- // prepareUpload
141
- function testPrepareUpload() {
142
- const result = client1.prepareUpload(Buffer.from('data'), {
143
- filename: 'test.csv',
144
- confirmEmailBeforeDownload: true,
145
- retentionPeriod: '52 weeks',
146
- });
147
- const file: string = result.file;
148
- }
149
-
150
- // setProxy
151
- client1.setProxy({ host: 'proxy.example.com', port: 8080 });
152
-
153
- // setClient - accepts axios instance