notifications-node-client 8.2.1 → 8.3.1

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 (35) hide show
  1. package/client/api_client.js +60 -67
  2. package/client/notification.js +289 -265
  3. package/package.json +13 -3
  4. package/tsconfig.json +18 -0
  5. package/.github/PULL_REQUEST_TEMPLATE.md +0 -18
  6. package/CHANGELOG.md +0 -292
  7. package/CONTRIBUTING.md +0 -59
  8. package/Dockerfile +0 -14
  9. package/Makefile +0 -41
  10. package/scripts/run_with_docker.sh +0 -21
  11. package/scripts/test_send.js +0 -57
  12. package/spec/api_client.js +0 -156
  13. package/spec/authentication.js +0 -32
  14. package/spec/integration/schemas/v1/GET_notifications_return.json +0 -37
  15. package/spec/integration/schemas/v1/POST_notification_return_email.json +0 -27
  16. package/spec/integration/schemas/v1/POST_notification_return_sms.json +0 -26
  17. package/spec/integration/schemas/v1/definitions.json +0 -12
  18. package/spec/integration/schemas/v1/email_notification.json +0 -106
  19. package/spec/integration/schemas/v1/sms_notification.json +0 -104
  20. package/spec/integration/schemas/v2/GET_notification_response.json +0 -50
  21. package/spec/integration/schemas/v2/GET_notifications_response.json +0 -29
  22. package/spec/integration/schemas/v2/GET_received_text_response.json +0 -23
  23. package/spec/integration/schemas/v2/GET_received_texts_response.json +0 -29
  24. package/spec/integration/schemas/v2/GET_template_by_id.json +0 -30
  25. package/spec/integration/schemas/v2/GET_templates_response.json +0 -15
  26. package/spec/integration/schemas/v2/POST_notification_email_response.json +0 -18
  27. package/spec/integration/schemas/v2/POST_notification_letter_response.json +0 -19
  28. package/spec/integration/schemas/v2/POST_notification_precompiled_letter_response.json +0 -19
  29. package/spec/integration/schemas/v2/POST_notification_sms_response.json +0 -18
  30. package/spec/integration/schemas/v2/POST_template_preview.json +0 -14
  31. package/spec/integration/schemas/v2/definitions.json +0 -51
  32. package/spec/integration/test.js +0 -415
  33. package/spec/integration/test_files/one_page_pdf.pdf +0 -0
  34. package/spec/notification.js +0 -633
  35. package/spec/test_files/simple.csv +0 -2
@@ -1,37 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "GET notification return schema - for sms notifications",
4
- "type" : "object",
5
- "properties": {
6
- "notifications": {
7
- "type": "array",
8
- "items": {
9
- "oneOf": [
10
- {"$ref": "sms_notification.json"},
11
- {"$ref": "email_notification.json"}
12
- ]
13
- }
14
- },
15
- "links": {
16
- "type": "object",
17
- "properties" : {
18
- "prev" : {
19
- "type" : "string"
20
- },
21
- "next" : {
22
- "type" : "string"
23
- },
24
- "last": {
25
- "type" : "string"
26
- }
27
- },
28
- "additionalProperties": false
29
- },
30
- "page_size": {"type": "number"},
31
- "total": {"type": "number"}
32
- },
33
- "additionalProperties": false,
34
- "required": [
35
- "notifications", "links", "page_size", "total"
36
- ]
37
- }
@@ -1,27 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "POST notification return schema - for email notifications",
4
- "type" : "object",
5
- "properties": {
6
- "data": {
7
- "type": "object",
8
- "properties": {
9
- "notification": {
10
- "type": "object",
11
- "properties": {
12
- "id": {"$ref": "definitions.json#/uuid"}
13
- },
14
- "additionalProperties": false,
15
- "required": ["id"]
16
- },
17
- "body": {"type": "string"},
18
- "template_version": {"type": "number"},
19
- "subject": {"type": "string"}
20
- },
21
- "additionalProperties": false,
22
- "required": ["notification", "body", "template_version", "subject"]
23
- }
24
- },
25
- "additionalProperties": false,
26
- "required": ["data"]
27
- }
@@ -1,26 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "POST notification return schema - for sms notifications",
4
- "type" : "object",
5
- "properties": {
6
- "data": {
7
- "type": "object",
8
- "properties": {
9
- "notification": {
10
- "type": "object",
11
- "properties": {
12
- "id": {"$ref": "definitions.json#/uuid"}
13
- },
14
- "additionalProperties": false,
15
- "required": ["id"]
16
- },
17
- "body": {"type": "string"},
18
- "template_version": {"type": "number"}
19
- },
20
- "additionalProperties": false,
21
- "required": ["notification", "body", "template_version"]
22
- }
23
- },
24
- "additionalProperties": false,
25
- "required": ["data"]
26
- }
@@ -1,12 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "Common definitions - usage example: {'$ref': 'definitions.json#/uuid'} (swap quotes for double quotes)",
4
- "uuid": {
5
- "type": "string",
6
- "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
7
- },
8
- "datetime": {
9
- "type": "string",
10
- "format": "date-time"
11
- }
12
- }
@@ -1,106 +0,0 @@
1
- {
2
- "description": "Single email notification schema - as returned by GET /notification and GET /notification/{}",
3
- "type": "object",
4
- "properties": {
5
- "id": {"$ref": "definitions.json#/uuid"},
6
- "to": {"type": "string", "format": "email"},
7
- "job_row_number": {"oneOf":[
8
- {"type": "number"},
9
- {"type": "null"}
10
- ]},
11
- "template_version": {"type": "number"},
12
- "billable_units": {"type": "number"},
13
- "notification_type": {
14
- "type": "string",
15
- "enum": ["email"]
16
- },
17
- "created_at": {"$ref": "definitions.json#/datetime"},
18
- "sent_at": {"oneOf":[
19
- {"$ref": "definitions.json#/datetime"},
20
- {"type": "null"}
21
- ]},
22
- "sent_by": {"oneOf":[
23
- {"type": "string"},
24
- {"type": "null"}
25
- ]},
26
- "updated_at": {"oneOf":[
27
- {"$ref": "definitions.json#/datetime"},
28
- {"type": "null"}
29
- ]},
30
- "status": {
31
- "type": "string",
32
- "enum": [
33
- "created",
34
- "sending",
35
- "delivered",
36
- "pending",
37
- "failed",
38
- "technical-failure",
39
- "temporary-failure",
40
- "permanent-failure"
41
- ]
42
- },
43
- "reference": {"oneOf":[
44
- {"type": "string"},
45
- {"type": "null"}
46
- ]},
47
- "template": {
48
- "type": "object",
49
- "properties": {
50
- "id": {"$ref": "definitions.json#/uuid"},
51
- "name": {"type": "string"},
52
- "template_type": {
53
- "type": "string",
54
- "enum": ["email"]
55
- },
56
- "version": {"type": "number"}
57
- },
58
- "additionalProperties": false,
59
- "required": ["id", "name", "template_type", "version"]
60
- },
61
- "service": {"$ref": "definitions.json#/uuid"},
62
- "job": {
63
- "oneOf": [
64
- {
65
- "type": "object",
66
- "properties": {
67
- "id": {"$ref": "definitions.json#/uuid"},
68
- "original_file_name": {"type": "string"}
69
- },
70
- "additionalProperties": false,
71
- "required": ["id", "original_file_name"]
72
- },
73
- {"type": "null"}
74
- ]
75
- },
76
- "api_key": {"oneOf":[
77
- {"$ref": "definitions.json#/uuid"},
78
- {"type": "null"}
79
- ]},
80
- "body": {"type": "string"},
81
- "content_char_count": {"type": "null"},
82
- "subject": {"type": "string"}
83
- },
84
- "additionalProperties": false,
85
- "required": [
86
- "id",
87
- "to",
88
- "job_row_number",
89
- "template_version",
90
- "billable_units",
91
- "notification_type",
92
- "created_at",
93
- "sent_at",
94
- "sent_by",
95
- "updated_at",
96
- "status",
97
- "reference",
98
- "template",
99
- "service",
100
- "job",
101
- "api_key",
102
- "body",
103
- "content_char_count",
104
- "subject"
105
- ]
106
- }
@@ -1,104 +0,0 @@
1
- {
2
- "description": "Single sms notification schema - as returned by GET /notification and GET /notification/{}",
3
- "type": "object",
4
- "properties": {
5
- "id": {"$ref": "definitions.json#/uuid"},
6
- "to": {"type": "string"},
7
- "job_row_number": {"oneOf":[
8
- {"type": "number"},
9
- {"type": "null"}
10
- ]},
11
- "template_version": {"type": "number"},
12
- "billable_units": {"type": "number"},
13
- "notification_type": {
14
- "type": "string",
15
- "enum": ["sms"]
16
- },
17
- "created_at": {"$ref": "definitions.json#/datetime"},
18
- "sent_at": {"oneOf":[
19
- {"$ref": "definitions.json#/datetime"},
20
- {"type": "null"}
21
- ]},
22
- "sent_by": {"oneOf":[
23
- {"type": "string"},
24
- {"type": "null"}
25
- ]},
26
- "updated_at": {"oneOf":[
27
- {"$ref": "definitions.json#/datetime"},
28
- {"type": "null"}
29
- ]},
30
- "status": {
31
- "type": "string",
32
- "enum": [
33
- "created",
34
- "sending",
35
- "delivered",
36
- "pending",
37
- "failed",
38
- "technical-failure",
39
- "temporary-failure",
40
- "permanent-failure"
41
- ]
42
- },
43
- "reference": {"oneOf":[
44
- {"type": "string"},
45
- {"type": "null"}
46
- ]},
47
- "template": {
48
- "type": "object",
49
- "properties": {
50
- "id": {"$ref": "definitions.json#/uuid"},
51
- "name": {"type": "string"},
52
- "template_type": {
53
- "type": "string",
54
- "enum": ["sms"]
55
- },
56
- "version": {"type": "number"}
57
- },
58
- "additionalProperties": false,
59
- "required": ["id", "name", "template_type", "version"]
60
- },
61
- "service": {"$ref": "definitions.json#/uuid"},
62
- "job": {
63
- "oneOf": [
64
- {
65
- "type": "object",
66
- "properties": {
67
- "id": {"$ref": "definitions.json#/uuid"},
68
- "original_file_name": {"type": "string"}
69
- },
70
- "additionalProperties": false,
71
- "required": ["id", "original_file_name"]
72
- },
73
- {"type": "null"}
74
- ]
75
- },
76
- "api_key": {"oneOf":[
77
- {"$ref": "definitions.json#/uuid"},
78
- {"type": "null"}
79
- ]},
80
- "body": {"type": "string"},
81
- "content_char_count": {"type": "number"}
82
- },
83
- "additionalProperties": false,
84
- "required": [
85
- "id",
86
- "to",
87
- "job_row_number",
88
- "template_version",
89
- "billable_units",
90
- "notification_type",
91
- "created_at",
92
- "sent_at",
93
- "sent_by",
94
- "updated_at",
95
- "status",
96
- "reference",
97
- "template",
98
- "service",
99
- "job",
100
- "api_key",
101
- "body",
102
- "content_char_count"
103
- ]
104
- }
@@ -1,50 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema#",
3
- "description": "GET notification response schema",
4
- "type": "object",
5
- "title": "response v2/notification",
6
- "properties": {
7
- "id": {"$ref": "definitions.json#/uuid"},
8
- "reference": {"type": ["string", "null"]},
9
- "email_address": {"type": ["string", "null"]},
10
- "phone_number": {"type": ["string", "null"]},
11
- "line_1": {"type": ["string", "null"]},
12
- "line_2": {"type": ["string", "null"]},
13
- "line_3": {"type": ["string", "null"]},
14
- "line_4": {"type": ["string", "null"]},
15
- "line_5": {"type": ["string", "null"]},
16
- "line_6": {"type": ["string", "null"]},
17
- "postcode": {"type": ["string", "null"]},
18
- "postage": {"type": ["string", "null"]},
19
- "type": {"enum": ["sms", "letter", "email"]},
20
- "status": {"type": "string"},
21
- "template": {"$ref": "definitions.json#/template"},
22
- "body": {"type": "string"},
23
- "subject": {"type": ["string", "null"]},
24
- "created_at": {"type": "string"},
25
- "created_by_name": {"type": ["string", "null"]},
26
- "sent_at": {"type": ["string", "null"]},
27
- "completed_at": {"type": ["string", "null"]},
28
- "scheduled_for": {"oneOf":[
29
- {"$ref": "definitions.json#/datetime"},
30
- {"type": "null"}
31
- ]},
32
- "cost_in_pounds": {"type": ["number", "null"]},
33
- "is_cost_data_ready": {"type": "boolean"},
34
- "cost_details": {
35
- "type": "object",
36
- "properties": {
37
- "billable_sms_fragments": {"type": ["integer", "null"]},
38
- "international_rate_multiplier": {"type": ["number", "null"]},
39
- "sms_rate": {"type": ["number", "null"]},
40
- "billable_sheets_of_paper": {"type": ["integer", "null"]},
41
- "postage": {"type": ["string", "null"]}
42
- }
43
- }
44
- },
45
- "required": [
46
- "id", "reference", "email_address", "phone_number",
47
- "line_1", "line_2", "line_3", "line_4", "line_5", "line_6", "postcode",
48
- "type", "status", "template", "created_at", "created_by_name", "sent_at", "completed_at"
49
- ]
50
- }
@@ -1,29 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema#",
3
- "description": "GET list of notifications response schema",
4
- "type": "object",
5
- "properties": {
6
- "notifications": {
7
- "type": "array",
8
- "items": {
9
- "type": "object",
10
- "$ref": "notification.json"
11
- }
12
- },
13
- "links": {
14
- "type": "object",
15
- "properties": {
16
- "current": {
17
- "type": "string"
18
- },
19
- "next": {
20
- "type": "string"
21
- }
22
- },
23
- "additionalProperties": false,
24
- "required": ["current"]
25
- }
26
- },
27
- "additionalProperties": false,
28
- "required": ["notifications", "links"]
29
- }
@@ -1,23 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "GET inbound sms schema response",
4
- "type": "object",
5
- "title": "GET response v2/inbound_sms",
6
- "properties": {
7
- "user_number": {"type": "string"},
8
- "created_at": {
9
- "format": "date-time",
10
- "type": "string",
11
- "description": "Date+time created at"
12
- },
13
- "service_id": {"$ref": "definitions.json#/uuid"},
14
- "id": {"$ref": "definitions.json#/uuid"},
15
- "notify_number": {"type": "string"},
16
- "content": {"type": "string"}
17
- },
18
- "required": [
19
- "id", "user_number", "created_at", "service_id",
20
- "notify_number", "content"
21
- ],
22
- "additionalProperties": false
23
- }
@@ -1,29 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "GET list of inbound sms response schema",
4
- "type": "object",
5
- "properties": {
6
- "received_text_messages": {
7
- "type": "array",
8
- "items": {
9
- "type": "object",
10
- "$ref": "receivedText.json"
11
- }
12
- },
13
- "links": {
14
- "type": "object",
15
- "properties": {
16
- "current": {
17
- "type": "string"
18
- },
19
- "next": {
20
- "type": "string"
21
- }
22
- },
23
- "additionalProperties": false,
24
- "required": ["current"]
25
- }
26
- },
27
- "required": ["received_text_messages", "links"],
28
- "additionalProperties": false
29
- }
@@ -1,30 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "GET template by id schema response",
4
- "type": "object",
5
- "title": "reponse v2/template",
6
- "properties": {
7
- "id": {"$ref": "definitions.json#/uuid"},
8
- "name": {"type": "string"},
9
- "type": {"enum": ["sms", "email", "letter"] },
10
- "created_at": {
11
- "format": "date-time",
12
- "type": "string",
13
- "description": "Date+time created"
14
- },
15
- "updated_at": {
16
- "format": "date-time",
17
- "type": ["string", "null"],
18
- "description": "Date+time updated"
19
- },
20
- "created_by": {"type": "string"},
21
- "version": {"type": "integer"},
22
- "body": {"type": "string"},
23
- "subject": {"type": ["string", "null"]},
24
- "letter_contact_block": {"type": ["string", "null"]}
25
- },
26
- "required": [
27
- "id", "name", "type", "created_at", "updated_at", "version", "created_by",
28
- "body", "letter_contact_block"
29
- ]
30
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "GET response schema when getting all templates",
4
- "type": "object",
5
- "properties": {
6
- "templates": {
7
- "type": "array",
8
- "items": {
9
- "type": "object",
10
- "$ref": "definitions.json#/template"
11
- }
12
- }
13
- },
14
- "required": ["templates"]
15
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema#",
3
- "description": "POST notification email response schema",
4
- "type" : "object",
5
- "properties": {
6
- "id": {"$ref": "definitions.json#/uuid"},
7
- "reference": {"type": ["string", "null"]},
8
- "content": {"$ref": "definitions.json#/email_content"},
9
- "uri": {"type": "string"},
10
- "template": {"$ref": "definitions.json#/template"},
11
- "scheduled_for": {"oneOf":[
12
- {"$ref": "definitions.json#/datetime"},
13
- {"type": "null"}
14
- ]}
15
- },
16
- "additionalProperties": false,
17
- "required": ["id", "content", "uri", "template"]
18
- }
@@ -1,19 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema#",
3
- "description": "POST notification letter response schema",
4
- "type" : "object",
5
- "properties": {
6
- "id": {"$ref": "definitions.json#/uuid"},
7
- "reference": {"type": ["string", "null"]},
8
- "postage": {"type": "string"},
9
- "content": {"$ref": "definitions.json#/letter_content"},
10
- "uri": {"type": "string"},
11
- "template": {"$ref": "definitions.json#/template"},
12
- "scheduled_for": {"oneOf":[
13
- {"$ref": "definitions.json#/datetime"},
14
- {"type": "null"}
15
- ]}
16
- },
17
- "additionalProperties": false,
18
- "required": ["id", "content", "uri", "template"]
19
- }
@@ -1,19 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema#",
3
- "description": "POST notification precompiled letter response schema",
4
- "type" : "object",
5
- "properties": {
6
- "id": {"$ref": "definitions.json#/uuid"},
7
- "reference": {"type": ["string", "null"]},
8
- "postage": {"type": "string"},
9
- "content": {"$ref": "definitions.json#/letter_content"},
10
- "uri": {"type": "string"},
11
- "template": {"$ref": "definitions.json#/template"},
12
- "scheduled_for": {"oneOf":[
13
- {"$ref": "definitions.json#/datetime"},
14
- {"type": "null"}
15
- ]}
16
- },
17
- "additionalProperties": false,
18
- "required": ["id", "postage"]
19
- }
@@ -1,18 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema#",
3
- "description": "POST notification sms response schema",
4
- "type" : "object",
5
- "properties": {
6
- "id": {"$ref": "definitions.json#/uuid"},
7
- "reference": {"type": ["string", "null"]},
8
- "content": {"$ref": "definitions.json#/sms_content"},
9
- "uri": {"type": "string"},
10
- "template": {"$ref": "definitions.json#/template"},
11
- "scheduled_for": {"oneOf":[
12
- {"$ref": "definitions.json#/datetime"},
13
- {"type": "null"}
14
- ]}
15
- },
16
- "additionalProperties": false,
17
- "required": ["id", "content", "uri", "template"]
18
- }
@@ -1,14 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "description": "POST template preview schema response",
4
- "type": "object",
5
- "title": "reponse v2/template/{id}/preview",
6
- "properties": {
7
- "id": {"$ref": "definitions.json#/uuid"},
8
- "type": {"enum": ["sms", "email", "letter"] },
9
- "version": {"type": "integer"},
10
- "body": {"type": "string"},
11
- "subject": {"type": ["string", "null"]}
12
- },
13
- "required": ["id", "type", "version", "body"]
14
- }
@@ -1,51 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema#",
3
- "description": "Common definitions - usage example: {'$ref': 'definitions.json#/uuid'} (swap quotes for double quotes)",
4
- "uuid": {
5
- "type": "string",
6
- "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
7
- },
8
- "datetime": {
9
- "type": "string",
10
- "format": "date-time"
11
- },
12
- "template": {
13
- "type": "object",
14
- "title": "notification content",
15
- "properties": {
16
- "id": {"$ref": "#/uuid"},
17
- "version": {"type": "integer"},
18
- "uri": {"type": "string"}
19
- },
20
- "required": ["id", "version"]
21
- },
22
- "email_content": {
23
- "type": "object",
24
- "title": "notification email content",
25
- "properties": {
26
- "body": {"type": "string"},
27
- "from_email": {"type": "string", "format": "email_address"},
28
- "subject": {"type": "string"},
29
- "one_click_unsubscribe_url": {"type": ["string", "null"], "format": "uri"}
30
- },
31
- "required": ["body", "from_email", "subject"]
32
- },
33
- "sms_content": {
34
- "type": "object",
35
- "title": "notification sms content",
36
- "properties": {
37
- "body": {"type": "string"},
38
- "from_number": {"type": "string"}
39
- },
40
- "required": ["body", "from_number"]
41
- },
42
- "letter_content": {
43
- "type": "object",
44
- "title": "notification letter content",
45
- "properties": {
46
- "body": {"type": "string"},
47
- "subject": {"type": "string"}
48
- },
49
- "required": ["body", "subject"]
50
- }
51
- }