trycourier 6.10.0 → 6.11.0

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +1 -1
  4. data/lib/courier/client.rb +6 -0
  5. data/lib/courier/models/create_device_set_request.rb +27 -0
  6. data/lib/courier/models/device_set.rb +63 -0
  7. data/lib/courier/models/device_set_list_response.rb +18 -0
  8. data/lib/courier/models/notifications/previews/create_preview_run_request.rb +68 -0
  9. data/lib/courier/models/notifications/previews/preview_result.rb +67 -0
  10. data/lib/courier/models/notifications/previews/preview_result_failure_reason.rb +24 -0
  11. data/lib/courier/models/notifications/previews/preview_result_status.rb +29 -0
  12. data/lib/courier/models/notifications/previews/preview_run.rb +84 -0
  13. data/lib/courier/models/notifications/previews/preview_run_detail.rb +93 -0
  14. data/lib/courier/models/notifications/previews/preview_run_failure_reason.rb +28 -0
  15. data/lib/courier/models/notifications/previews/preview_run_list_response.rb +30 -0
  16. data/lib/courier/models/notifications/previews/preview_run_status.rb +28 -0
  17. data/lib/courier/models/notifications/previews/run_create_params.rb +36 -0
  18. data/lib/courier/models/notifications/previews/run_list_params.rb +41 -0
  19. data/lib/courier/models/notifications/previews/run_retrieve_params.rb +30 -0
  20. data/lib/courier/models/preview_archive_device_set_params.rb +20 -0
  21. data/lib/courier/models/preview_create_device_set_params.rb +14 -0
  22. data/lib/courier/models/preview_device.rb +125 -0
  23. data/lib/courier/models/preview_device_list_response.rb +18 -0
  24. data/lib/courier/models/preview_list_device_sets_params.rb +14 -0
  25. data/lib/courier/models/preview_list_devices_params.rb +14 -0
  26. data/lib/courier/models/preview_retrieve_device_set_params.rb +20 -0
  27. data/lib/courier/models/preview_update_device_set_params.rb +20 -0
  28. data/lib/courier/models.rb +22 -0
  29. data/lib/courier/resources/notifications/previews/runs.rb +148 -0
  30. data/lib/courier/resources/notifications/previews.rb +22 -0
  31. data/lib/courier/resources/notifications.rb +4 -0
  32. data/lib/courier/resources/previews.rb +153 -0
  33. data/lib/courier/version.rb +1 -1
  34. data/lib/courier.rb +26 -0
  35. data/rbi/courier/client.rbi +5 -0
  36. data/rbi/courier/models/create_device_set_request.rbi +39 -0
  37. data/rbi/courier/models/device_set.rbi +81 -0
  38. data/rbi/courier/models/device_set_list_response.rbi +28 -0
  39. data/rbi/courier/models/notifications/previews/create_preview_run_request.rbi +110 -0
  40. data/rbi/courier/models/notifications/previews/preview_result.rbi +117 -0
  41. data/rbi/courier/models/notifications/previews/preview_result_failure_reason.rbi +44 -0
  42. data/rbi/courier/models/notifications/previews/preview_result_status.rbi +69 -0
  43. data/rbi/courier/models/notifications/previews/preview_run.rbi +134 -0
  44. data/rbi/courier/models/notifications/previews/preview_run_detail.rbi +148 -0
  45. data/rbi/courier/models/notifications/previews/preview_run_failure_reason.rbi +64 -0
  46. data/rbi/courier/models/notifications/previews/preview_run_list_response.rbi +54 -0
  47. data/rbi/courier/models/notifications/previews/preview_run_status.rbi +61 -0
  48. data/rbi/courier/models/notifications/previews/run_create_params.rbi +66 -0
  49. data/rbi/courier/models/notifications/previews/run_list_params.rbi +67 -0
  50. data/rbi/courier/models/notifications/previews/run_retrieve_params.rbi +50 -0
  51. data/rbi/courier/models/preview_archive_device_set_params.rbi +38 -0
  52. data/rbi/courier/models/preview_create_device_set_params.rbi +30 -0
  53. data/rbi/courier/models/preview_device.rbi +168 -0
  54. data/rbi/courier/models/preview_device_list_response.rbi +28 -0
  55. data/rbi/courier/models/preview_list_device_sets_params.rbi +30 -0
  56. data/rbi/courier/models/preview_list_devices_params.rbi +27 -0
  57. data/rbi/courier/models/preview_retrieve_device_set_params.rbi +38 -0
  58. data/rbi/courier/models/preview_update_device_set_params.rbi +38 -0
  59. data/rbi/courier/models.rbi +23 -0
  60. data/rbi/courier/resources/notifications/previews/runs.rbi +136 -0
  61. data/rbi/courier/resources/notifications/previews.rbi +19 -0
  62. data/rbi/courier/resources/notifications.rbi +3 -0
  63. data/rbi/courier/resources/previews.rbi +106 -0
  64. data/sig/courier/client.rbs +2 -0
  65. data/sig/courier/models/create_device_set_request.rbs +16 -0
  66. data/sig/courier/models/device_set.rbs +47 -0
  67. data/sig/courier/models/device_set_list_response.rbs +13 -0
  68. data/sig/courier/models/notifications/previews/create_preview_run_request.rbs +54 -0
  69. data/sig/courier/models/notifications/previews/preview_result.rbs +50 -0
  70. data/sig/courier/models/notifications/previews/preview_result_failure_reason.rbs +19 -0
  71. data/sig/courier/models/notifications/previews/preview_result_status.rbs +30 -0
  72. data/sig/courier/models/notifications/previews/preview_run.rbs +62 -0
  73. data/sig/courier/models/notifications/previews/preview_run_detail.rbs +67 -0
  74. data/sig/courier/models/notifications/previews/preview_run_failure_reason.rbs +28 -0
  75. data/sig/courier/models/notifications/previews/preview_run_list_response.rbs +31 -0
  76. data/sig/courier/models/notifications/previews/preview_run_status.rbs +24 -0
  77. data/sig/courier/models/notifications/previews/run_create_params.rbs +46 -0
  78. data/sig/courier/models/notifications/previews/run_list_params.rbs +38 -0
  79. data/sig/courier/models/notifications/previews/run_retrieve_params.rbs +32 -0
  80. data/sig/courier/models/preview_archive_device_set_params.rbs +23 -0
  81. data/sig/courier/models/preview_create_device_set_params.rbs +15 -0
  82. data/sig/courier/models/preview_device.rbs +83 -0
  83. data/sig/courier/models/preview_device_list_response.rbs +14 -0
  84. data/sig/courier/models/preview_list_device_sets_params.rbs +15 -0
  85. data/sig/courier/models/preview_list_devices_params.rbs +15 -0
  86. data/sig/courier/models/preview_retrieve_device_set_params.rbs +23 -0
  87. data/sig/courier/models/preview_update_device_set_params.rbs +25 -0
  88. data/sig/courier/models.rbs +22 -0
  89. data/sig/courier/resources/notifications/previews/runs.rbs +36 -0
  90. data/sig/courier/resources/notifications/previews.rbs +11 -0
  91. data/sig/courier/resources/notifications.rbs +2 -0
  92. data/sig/courier/resources/previews.rbs +38 -0
  93. metadata +79 -1
@@ -0,0 +1,50 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ module Notifications
6
+ module Previews
7
+ class RunRetrieveParams < Courier::Internal::Type::BaseModel
8
+ extend Courier::Internal::Type::RequestParameters::Converter
9
+ include Courier::Internal::Type::RequestParameters
10
+
11
+ OrHash =
12
+ T.type_alias do
13
+ T.any(
14
+ Courier::Notifications::Previews::RunRetrieveParams,
15
+ Courier::Internal::AnyHash
16
+ )
17
+ end
18
+
19
+ sig { returns(String) }
20
+ attr_accessor :id
21
+
22
+ sig { returns(String) }
23
+ attr_accessor :preview_run_id
24
+
25
+ sig do
26
+ params(
27
+ id: String,
28
+ preview_run_id: String,
29
+ request_options: Courier::RequestOptions::OrHash
30
+ ).returns(T.attached_class)
31
+ end
32
+ def self.new(id:, preview_run_id:, request_options: {})
33
+ end
34
+
35
+ sig do
36
+ override.returns(
37
+ {
38
+ id: String,
39
+ preview_run_id: String,
40
+ request_options: Courier::RequestOptions
41
+ }
42
+ )
43
+ end
44
+ def to_hash
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,38 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewArchiveDeviceSetParams < Courier::Internal::Type::BaseModel
6
+ extend Courier::Internal::Type::RequestParameters::Converter
7
+ include Courier::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Courier::PreviewArchiveDeviceSetParams,
13
+ Courier::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(String) }
18
+ attr_accessor :device_set_id
19
+
20
+ sig do
21
+ params(
22
+ device_set_id: String,
23
+ request_options: Courier::RequestOptions::OrHash
24
+ ).returns(T.attached_class)
25
+ end
26
+ def self.new(device_set_id:, request_options: {})
27
+ end
28
+
29
+ sig do
30
+ override.returns(
31
+ { device_set_id: String, request_options: Courier::RequestOptions }
32
+ )
33
+ end
34
+ def to_hash
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewCreateDeviceSetParams < Courier::Models::CreateDeviceSetRequest
6
+ extend Courier::Internal::Type::RequestParameters::Converter
7
+ include Courier::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Courier::PreviewCreateDeviceSetParams,
13
+ Courier::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig do
18
+ params(request_options: Courier::RequestOptions::OrHash).returns(
19
+ T.attached_class
20
+ )
21
+ end
22
+ def self.new(request_options: {})
23
+ end
24
+
25
+ sig { override.returns({ request_options: Courier::RequestOptions }) }
26
+ def to_hash
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,168 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewDevice < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Courier::PreviewDevice, Courier::Internal::AnyHash)
9
+ end
10
+
11
+ # The device's identifier, used in `device_ids` when creating a device set or a
12
+ # run.
13
+ sig { returns(String) }
14
+ attr_accessor :id
15
+
16
+ # The mail app. For webmail it is the service (`outlook_com`, `gmail_com`); for
17
+ # mobile the app (`apple_mail`, `gmail`); for desktop the app together with the
18
+ # version it is sold under (`outlook_2019`, `outlook_microsoft_365`,
19
+ # `apple_mail_16`), because that version is what separates one desktop Outlook
20
+ # from another.
21
+ sig { returns(String) }
22
+ attr_accessor :app
23
+
24
+ # Where the app runs.
25
+ sig { returns(Courier::PreviewDevice::Category::TaggedSymbol) }
26
+ attr_accessor :category
27
+
28
+ # Display name. Render it as-is rather than parsing it. It is also what separates
29
+ # the two 120-dpi Outlook renders from their 100% siblings, which are otherwise
30
+ # identical field for field.
31
+ sig { returns(String) }
32
+ attr_accessor :name
33
+
34
+ # The operating system.
35
+ sig { returns(String) }
36
+ attr_accessor :os
37
+
38
+ # The operating system's version. Always set.
39
+ sig { returns(String) }
40
+ attr_accessor :os_version
41
+
42
+ # What the app runs on — the browser for webmail (`chrome`, `edge`, `firefox`),
43
+ # the phone for mobile (`iphone`, `pixel`). Null for desktop, where the app runs
44
+ # on nothing but the OS.
45
+ sig { returns(T.nilable(String)) }
46
+ attr_accessor :platform
47
+
48
+ # Which one of the platform — the phone model for mobile (`15_pro_max`, `10`).
49
+ # Null for webmail, which always renders in the current browser, and for desktop.
50
+ sig { returns(T.nilable(String)) }
51
+ attr_accessor :platform_version
52
+
53
+ # Whether the email is rendered in light or dark mode.
54
+ sig { returns(Courier::PreviewDevice::Theme::TaggedSymbol) }
55
+ attr_accessor :theme
56
+
57
+ # One mail app on one platform, operating system and theme that a preview can be
58
+ # rendered on. Reference data, identical for every workspace. Every field is
59
+ # always present; `platform` and `platform_version` are null where they do not
60
+ # apply.
61
+ sig do
62
+ params(
63
+ id: String,
64
+ app: String,
65
+ category: Courier::PreviewDevice::Category::OrSymbol,
66
+ name: String,
67
+ os: String,
68
+ os_version: String,
69
+ platform: T.nilable(String),
70
+ platform_version: T.nilable(String),
71
+ theme: Courier::PreviewDevice::Theme::OrSymbol
72
+ ).returns(T.attached_class)
73
+ end
74
+ def self.new(
75
+ # The device's identifier, used in `device_ids` when creating a device set or a
76
+ # run.
77
+ id:,
78
+ # The mail app. For webmail it is the service (`outlook_com`, `gmail_com`); for
79
+ # mobile the app (`apple_mail`, `gmail`); for desktop the app together with the
80
+ # version it is sold under (`outlook_2019`, `outlook_microsoft_365`,
81
+ # `apple_mail_16`), because that version is what separates one desktop Outlook
82
+ # from another.
83
+ app:,
84
+ # Where the app runs.
85
+ category:,
86
+ # Display name. Render it as-is rather than parsing it. It is also what separates
87
+ # the two 120-dpi Outlook renders from their 100% siblings, which are otherwise
88
+ # identical field for field.
89
+ name:,
90
+ # The operating system.
91
+ os:,
92
+ # The operating system's version. Always set.
93
+ os_version:,
94
+ # What the app runs on — the browser for webmail (`chrome`, `edge`, `firefox`),
95
+ # the phone for mobile (`iphone`, `pixel`). Null for desktop, where the app runs
96
+ # on nothing but the OS.
97
+ platform:,
98
+ # Which one of the platform — the phone model for mobile (`15_pro_max`, `10`).
99
+ # Null for webmail, which always renders in the current browser, and for desktop.
100
+ platform_version:,
101
+ # Whether the email is rendered in light or dark mode.
102
+ theme:
103
+ )
104
+ end
105
+
106
+ sig do
107
+ override.returns(
108
+ {
109
+ id: String,
110
+ app: String,
111
+ category: Courier::PreviewDevice::Category::TaggedSymbol,
112
+ name: String,
113
+ os: String,
114
+ os_version: String,
115
+ platform: T.nilable(String),
116
+ platform_version: T.nilable(String),
117
+ theme: Courier::PreviewDevice::Theme::TaggedSymbol
118
+ }
119
+ )
120
+ end
121
+ def to_hash
122
+ end
123
+
124
+ # Where the app runs.
125
+ module Category
126
+ extend Courier::Internal::Type::Enum
127
+
128
+ TaggedSymbol =
129
+ T.type_alias { T.all(Symbol, Courier::PreviewDevice::Category) }
130
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
131
+
132
+ WEBMAIL =
133
+ T.let(:webmail, Courier::PreviewDevice::Category::TaggedSymbol)
134
+ MOBILE = T.let(:mobile, Courier::PreviewDevice::Category::TaggedSymbol)
135
+ DESKTOP =
136
+ T.let(:desktop, Courier::PreviewDevice::Category::TaggedSymbol)
137
+
138
+ sig do
139
+ override.returns(
140
+ T::Array[Courier::PreviewDevice::Category::TaggedSymbol]
141
+ )
142
+ end
143
+ def self.values
144
+ end
145
+ end
146
+
147
+ # Whether the email is rendered in light or dark mode.
148
+ module Theme
149
+ extend Courier::Internal::Type::Enum
150
+
151
+ TaggedSymbol =
152
+ T.type_alias { T.all(Symbol, Courier::PreviewDevice::Theme) }
153
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
154
+
155
+ LIGHT = T.let(:light, Courier::PreviewDevice::Theme::TaggedSymbol)
156
+ DARK = T.let(:dark, Courier::PreviewDevice::Theme::TaggedSymbol)
157
+
158
+ sig do
159
+ override.returns(
160
+ T::Array[Courier::PreviewDevice::Theme::TaggedSymbol]
161
+ )
162
+ end
163
+ def self.values
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,28 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewDeviceListResponse < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Courier::PreviewDeviceListResponse, Courier::Internal::AnyHash)
9
+ end
10
+
11
+ sig { returns(T::Array[Courier::PreviewDevice]) }
12
+ attr_accessor :results
13
+
14
+ # The full catalog of renderable devices. Not paginated.
15
+ sig do
16
+ params(results: T::Array[Courier::PreviewDevice::OrHash]).returns(
17
+ T.attached_class
18
+ )
19
+ end
20
+ def self.new(results:)
21
+ end
22
+
23
+ sig { override.returns({ results: T::Array[Courier::PreviewDevice] }) }
24
+ def to_hash
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewListDeviceSetsParams < Courier::Internal::Type::BaseModel
6
+ extend Courier::Internal::Type::RequestParameters::Converter
7
+ include Courier::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Courier::PreviewListDeviceSetsParams,
13
+ Courier::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig do
18
+ params(request_options: Courier::RequestOptions::OrHash).returns(
19
+ T.attached_class
20
+ )
21
+ end
22
+ def self.new(request_options: {})
23
+ end
24
+
25
+ sig { override.returns({ request_options: Courier::RequestOptions }) }
26
+ def to_hash
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,27 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewListDevicesParams < Courier::Internal::Type::BaseModel
6
+ extend Courier::Internal::Type::RequestParameters::Converter
7
+ include Courier::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(Courier::PreviewListDevicesParams, Courier::Internal::AnyHash)
12
+ end
13
+
14
+ sig do
15
+ params(request_options: Courier::RequestOptions::OrHash).returns(
16
+ T.attached_class
17
+ )
18
+ end
19
+ def self.new(request_options: {})
20
+ end
21
+
22
+ sig { override.returns({ request_options: Courier::RequestOptions }) }
23
+ def to_hash
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewRetrieveDeviceSetParams < Courier::Internal::Type::BaseModel
6
+ extend Courier::Internal::Type::RequestParameters::Converter
7
+ include Courier::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Courier::PreviewRetrieveDeviceSetParams,
13
+ Courier::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(String) }
18
+ attr_accessor :device_set_id
19
+
20
+ sig do
21
+ params(
22
+ device_set_id: String,
23
+ request_options: Courier::RequestOptions::OrHash
24
+ ).returns(T.attached_class)
25
+ end
26
+ def self.new(device_set_id:, request_options: {})
27
+ end
28
+
29
+ sig do
30
+ override.returns(
31
+ { device_set_id: String, request_options: Courier::RequestOptions }
32
+ )
33
+ end
34
+ def to_hash
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewUpdateDeviceSetParams < Courier::Models::CreateDeviceSetRequest
6
+ extend Courier::Internal::Type::RequestParameters::Converter
7
+ include Courier::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Courier::PreviewUpdateDeviceSetParams,
13
+ Courier::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(String) }
18
+ attr_accessor :device_set_id
19
+
20
+ sig do
21
+ params(
22
+ device_set_id: String,
23
+ request_options: Courier::RequestOptions::OrHash
24
+ ).returns(T.attached_class)
25
+ end
26
+ def self.new(device_set_id:, request_options: {})
27
+ end
28
+
29
+ sig do
30
+ override.returns(
31
+ { device_set_id: String, request_options: Courier::RequestOptions }
32
+ )
33
+ end
34
+ def to_hash
35
+ end
36
+ end
37
+ end
38
+ end
@@ -144,10 +144,16 @@ module Courier
144
144
 
145
145
  CreateBroadcastRequest = Courier::Models::CreateBroadcastRequest
146
146
 
147
+ CreateDeviceSetRequest = Courier::Models::CreateDeviceSetRequest
148
+
147
149
  CreateJourneyRequest = Courier::Models::CreateJourneyRequest
148
150
 
149
151
  DefaultPreferences = Courier::Models::DefaultPreferences
150
152
 
153
+ DeviceSet = Courier::Models::DeviceSet
154
+
155
+ DeviceSetListResponse = Courier::Models::DeviceSetListResponse
156
+
151
157
  DeviceType = Courier::Models::DeviceType
152
158
 
153
159
  DigestCategory = Courier::Models::DigestCategory
@@ -503,6 +509,23 @@ module Courier
503
509
 
504
510
  PreferenceStatus = Courier::Models::PreferenceStatus
505
511
 
512
+ PreviewArchiveDeviceSetParams = Courier::Models::PreviewArchiveDeviceSetParams
513
+
514
+ PreviewCreateDeviceSetParams = Courier::Models::PreviewCreateDeviceSetParams
515
+
516
+ PreviewDevice = Courier::Models::PreviewDevice
517
+
518
+ PreviewDeviceListResponse = Courier::Models::PreviewDeviceListResponse
519
+
520
+ PreviewListDeviceSetsParams = Courier::Models::PreviewListDeviceSetsParams
521
+
522
+ PreviewListDevicesParams = Courier::Models::PreviewListDevicesParams
523
+
524
+ PreviewRetrieveDeviceSetParams =
525
+ Courier::Models::PreviewRetrieveDeviceSetParams
526
+
527
+ PreviewUpdateDeviceSetParams = Courier::Models::PreviewUpdateDeviceSetParams
528
+
506
529
  ProfileCreateParams = Courier::Models::ProfileCreateParams
507
530
 
508
531
  ProfileDeleteParams = Courier::Models::ProfileDeleteParams
@@ -0,0 +1,136 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Resources
5
+ class Notifications
6
+ class Previews
7
+ # Render a template's email content on real email clients and read back the
8
+ # screenshots, so you can check how it looks before you send it.
9
+ class Runs
10
+ # Render this template's email content on each of the requested devices.
11
+ #
12
+ # Returns as soon as the run exists and its render is queued — the screenshots are
13
+ # produced asynchronously. Poll
14
+ # `GET /notifications/{id}/previews/runs/{previewRunId}` until every result
15
+ # reaches a terminal status.
16
+ #
17
+ # Name the devices either with `device_set_id`, for a saved set, or with
18
+ # `device_ids`, for a one-off list. Exactly one of the two is required. Inline
19
+ # `device_ids` must be ids listed by `GET /previews/devices`; any other id is a
20
+ # 422, refused before the run exists or is billed.
21
+ #
22
+ # A template that does not exist is a 404. One that exists but cannot be previewed
23
+ # — not a Design Studio template, no email channel, or no such `template_version`
24
+ # — is a 422, also refused before the run exists or is billed.
25
+ #
26
+ # Preview runs are a metered add-on. A workspace without it, or with its billing
27
+ # suspended, receives a 402.
28
+ sig do
29
+ params(
30
+ id: String,
31
+ data: T::Hash[Symbol, T.anything],
32
+ device_ids: T::Array[String],
33
+ device_set_id: String,
34
+ locale: String,
35
+ template_version: String,
36
+ idempotency_key: String,
37
+ x_idempotency_expiration: String,
38
+ request_options: Courier::RequestOptions::OrHash
39
+ ).returns(Courier::Notifications::Previews::PreviewRun)
40
+ end
41
+ def create(
42
+ # Path param: Template ID (nt\_ prefix). Must be a Design Studio template.
43
+ id,
44
+ # Body param: Template variables to render with, the same shape as the `data`
45
+ # object on a send.
46
+ data: nil,
47
+ # Body param: The devices to render on, by `PreviewDevice.id`, for a one-off run.
48
+ # Mutually exclusive with `device_set_id`.
49
+ device_ids: nil,
50
+ # Body param: A saved device set naming the devices to render on. Mutually
51
+ # exclusive with `device_ids`.
52
+ device_set_id: nil,
53
+ # Body param: Render the template's content for this locale, e.g. "fr-FR".
54
+ locale: nil,
55
+ # Body param: Which version of the template to render. Omit for the latest saved
56
+ # draft, which always exists and is what the editor shows. `published` renders the
57
+ # live version; a zero-padded `v002` renders that specific publish. Versions are
58
+ # 1-based, so `v000` is not a version, and the unpadded `v2` is rejected — that
59
+ # spelling belongs to journeys' AutomationVersionId, a different scheme in which
60
+ # `v0` means published.
61
+ template_version: nil,
62
+ # Header param: A unique key that makes this request idempotent. If Courier
63
+ # receives another request with the same `Idempotency-Key`, it returns the stored
64
+ # response from the first request without performing the operation again
65
+ # (including the original status code and any error). Use it to safely retry
66
+ # `POST` requests after network failures without risking duplicate sends. The key
67
+ # is scoped to this endpoint.
68
+ idempotency_key: nil,
69
+ # Header param: How long the idempotency key remains valid, as a Unix epoch
70
+ # timestamp in seconds or an ISO 8601 date string. Only applies when
71
+ # `Idempotency-Key` is provided. If omitted, the key is retained for 25 hours; the
72
+ # maximum is 1 year.
73
+ x_idempotency_expiration: nil,
74
+ request_options: {}
75
+ )
76
+ end
77
+
78
+ # Retrieve one of this template's preview runs together with its per-device
79
+ # results.
80
+ #
81
+ # A run is only readable under the template it previewed: under any other template
82
+ # it is a 404, the same as a run that does not exist.
83
+ #
84
+ # `thumbnail_url` and `screenshot_url` are short-lived signed URLs, re-signed on
85
+ # every read. Fetch them now rather than storing them. Both are null until
86
+ # Courier's own copy of the image exists, which is what `status: COMPLETED` on a
87
+ # result means.
88
+ sig do
89
+ params(
90
+ preview_run_id: String,
91
+ id: String,
92
+ request_options: Courier::RequestOptions::OrHash
93
+ ).returns(Courier::Notifications::Previews::PreviewRunDetail)
94
+ end
95
+ def retrieve(
96
+ # The preview run to retrieve, identified by the `id` returned when it was
97
+ # created.
98
+ preview_run_id,
99
+ # Template ID (nt\_ prefix).
100
+ id:,
101
+ request_options: {}
102
+ )
103
+ end
104
+
105
+ # List this template's preview runs, newest first. Cursor-paginated.
106
+ #
107
+ # A template that does not exist is a 404, the same as every other
108
+ # `/notifications/{id}` route.
109
+ sig do
110
+ params(
111
+ id: String,
112
+ cursor: T.nilable(String),
113
+ limit: Integer,
114
+ request_options: Courier::RequestOptions::OrHash
115
+ ).returns(Courier::Notifications::Previews::PreviewRunListResponse)
116
+ end
117
+ def list(
118
+ # Template ID (nt\_ prefix).
119
+ id,
120
+ # Opaque pagination cursor from a previous response. Omit for the first page.
121
+ cursor: nil,
122
+ # Maximum number of results per page.
123
+ limit: nil,
124
+ request_options: {}
125
+ )
126
+ end
127
+
128
+ # @api private
129
+ sig { params(client: Courier::Client).returns(T.attached_class) }
130
+ def self.new(client:)
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,19 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Resources
5
+ class Notifications
6
+ class Previews
7
+ # Render a template's email content on real email clients and read back the
8
+ # screenshots, so you can check how it looks before you send it.
9
+ sig { returns(Courier::Resources::Notifications::Previews::Runs) }
10
+ attr_reader :runs
11
+
12
+ # @api private
13
+ sig { params(client: Courier::Client).returns(T.attached_class) }
14
+ def self.new(client:)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -10,6 +10,9 @@ module Courier
10
10
  sig { returns(Courier::Resources::Notifications::Checks) }
11
11
  attr_reader :checks
12
12
 
13
+ sig { returns(Courier::Resources::Notifications::Previews) }
14
+ attr_reader :previews
15
+
13
16
  # Create a notification template. Requires all fields in the notification object.
14
17
  # Templates are created in draft state by default.
15
18
  #