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,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ module Notifications
6
+ module Previews
7
+ # @see Courier::Resources::Notifications::Previews::Runs#list
8
+ class RunListParams < Courier::Internal::Type::BaseModel
9
+ extend Courier::Internal::Type::RequestParameters::Converter
10
+ include Courier::Internal::Type::RequestParameters
11
+
12
+ # @!attribute id
13
+ #
14
+ # @return [String]
15
+ required :id, String
16
+
17
+ # @!attribute cursor
18
+ # Opaque pagination cursor from a previous response. Omit for the first page.
19
+ #
20
+ # @return [String, nil]
21
+ optional :cursor, String, nil?: true
22
+
23
+ # @!attribute limit
24
+ # Maximum number of results per page.
25
+ #
26
+ # @return [Integer, nil]
27
+ optional :limit, Integer
28
+
29
+ # @!method initialize(id:, cursor: nil, limit: nil, request_options: {})
30
+ # @param id [String]
31
+ #
32
+ # @param cursor [String, nil] Opaque pagination cursor from a previous response. Omit for the first page.
33
+ #
34
+ # @param limit [Integer] Maximum number of results per page.
35
+ #
36
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ module Notifications
6
+ module Previews
7
+ # @see Courier::Resources::Notifications::Previews::Runs#retrieve
8
+ class RunRetrieveParams < Courier::Internal::Type::BaseModel
9
+ extend Courier::Internal::Type::RequestParameters::Converter
10
+ include Courier::Internal::Type::RequestParameters
11
+
12
+ # @!attribute id
13
+ #
14
+ # @return [String]
15
+ required :id, String
16
+
17
+ # @!attribute preview_run_id
18
+ #
19
+ # @return [String]
20
+ required :preview_run_id, String
21
+
22
+ # @!method initialize(id:, preview_run_id:, request_options: {})
23
+ # @param id [String]
24
+ # @param preview_run_id [String]
25
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::Previews#archive_device_set
6
+ class PreviewArchiveDeviceSetParams < Courier::Internal::Type::BaseModel
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ # @!attribute device_set_id
11
+ #
12
+ # @return [String]
13
+ required :device_set_id, String
14
+
15
+ # @!method initialize(device_set_id:, request_options: {})
16
+ # @param device_set_id [String]
17
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::Previews#create_device_set
6
+ class PreviewCreateDeviceSetParams < Courier::Models::CreateDeviceSetRequest
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ # @!method initialize(request_options: {})
11
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ class PreviewDevice < Courier::Internal::Type::BaseModel
6
+ # @!attribute id
7
+ # The device's identifier, used in `device_ids` when creating a device set or a
8
+ # run.
9
+ #
10
+ # @return [String]
11
+ required :id, String
12
+
13
+ # @!attribute app
14
+ # The mail app. For webmail it is the service (`outlook_com`, `gmail_com`); for
15
+ # mobile the app (`apple_mail`, `gmail`); for desktop the app together with the
16
+ # version it is sold under (`outlook_2019`, `outlook_microsoft_365`,
17
+ # `apple_mail_16`), because that version is what separates one desktop Outlook
18
+ # from another.
19
+ #
20
+ # @return [String]
21
+ required :app, String
22
+
23
+ # @!attribute category
24
+ # Where the app runs.
25
+ #
26
+ # @return [Symbol, Courier::Models::PreviewDevice::Category]
27
+ required :category, enum: -> { Courier::PreviewDevice::Category }
28
+
29
+ # @!attribute name
30
+ # Display name. Render it as-is rather than parsing it. It is also what separates
31
+ # the two 120-dpi Outlook renders from their 100% siblings, which are otherwise
32
+ # identical field for field.
33
+ #
34
+ # @return [String]
35
+ required :name, String
36
+
37
+ # @!attribute os
38
+ # The operating system.
39
+ #
40
+ # @return [String]
41
+ required :os, String
42
+
43
+ # @!attribute os_version
44
+ # The operating system's version. Always set.
45
+ #
46
+ # @return [String]
47
+ required :os_version, String
48
+
49
+ # @!attribute platform
50
+ # What the app runs on — the browser for webmail (`chrome`, `edge`, `firefox`),
51
+ # the phone for mobile (`iphone`, `pixel`). Null for desktop, where the app runs
52
+ # on nothing but the OS.
53
+ #
54
+ # @return [String, nil]
55
+ required :platform, String, nil?: true
56
+
57
+ # @!attribute platform_version
58
+ # Which one of the platform — the phone model for mobile (`15_pro_max`, `10`).
59
+ # Null for webmail, which always renders in the current browser, and for desktop.
60
+ #
61
+ # @return [String, nil]
62
+ required :platform_version, String, nil?: true
63
+
64
+ # @!attribute theme
65
+ # Whether the email is rendered in light or dark mode.
66
+ #
67
+ # @return [Symbol, Courier::Models::PreviewDevice::Theme]
68
+ required :theme, enum: -> { Courier::PreviewDevice::Theme }
69
+
70
+ # @!method initialize(id:, app:, category:, name:, os:, os_version:, platform:, platform_version:, theme:)
71
+ # Some parameter documentations has been truncated, see
72
+ # {Courier::Models::PreviewDevice} for more details.
73
+ #
74
+ # One mail app on one platform, operating system and theme that a preview can be
75
+ # rendered on. Reference data, identical for every workspace. Every field is
76
+ # always present; `platform` and `platform_version` are null where they do not
77
+ # apply.
78
+ #
79
+ # @param id [String] The device's identifier, used in `device_ids` when creating a device set or a ru
80
+ #
81
+ # @param app [String] The mail app. For webmail it is the service (`outlook_com`, `gmail_com`); for mo
82
+ #
83
+ # @param category [Symbol, Courier::Models::PreviewDevice::Category] Where the app runs.
84
+ #
85
+ # @param name [String] Display name. Render it as-is rather than parsing it. It is also what separates
86
+ #
87
+ # @param os [String] The operating system.
88
+ #
89
+ # @param os_version [String] The operating system's version. Always set.
90
+ #
91
+ # @param platform [String, nil] What the app runs on — the browser for webmail (`chrome`, `edge`, `firefox`), th
92
+ #
93
+ # @param platform_version [String, nil] Which one of the platform — the phone model for mobile (`15_pro_max`, `10`). Nul
94
+ #
95
+ # @param theme [Symbol, Courier::Models::PreviewDevice::Theme] Whether the email is rendered in light or dark mode.
96
+
97
+ # Where the app runs.
98
+ #
99
+ # @see Courier::Models::PreviewDevice#category
100
+ module Category
101
+ extend Courier::Internal::Type::Enum
102
+
103
+ WEBMAIL = :webmail
104
+ MOBILE = :mobile
105
+ DESKTOP = :desktop
106
+
107
+ # @!method self.values
108
+ # @return [Array<Symbol>]
109
+ end
110
+
111
+ # Whether the email is rendered in light or dark mode.
112
+ #
113
+ # @see Courier::Models::PreviewDevice#theme
114
+ module Theme
115
+ extend Courier::Internal::Type::Enum
116
+
117
+ LIGHT = :light
118
+ DARK = :dark
119
+
120
+ # @!method self.values
121
+ # @return [Array<Symbol>]
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::Previews#list_devices
6
+ class PreviewDeviceListResponse < Courier::Internal::Type::BaseModel
7
+ # @!attribute results
8
+ #
9
+ # @return [Array<Courier::Models::PreviewDevice>]
10
+ required :results, -> { Courier::Internal::Type::ArrayOf[Courier::PreviewDevice] }
11
+
12
+ # @!method initialize(results:)
13
+ # The full catalog of renderable devices. Not paginated.
14
+ #
15
+ # @param results [Array<Courier::Models::PreviewDevice>]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::Previews#list_device_sets
6
+ class PreviewListDeviceSetsParams < Courier::Internal::Type::BaseModel
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ # @!method initialize(request_options: {})
11
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::Previews#list_devices
6
+ class PreviewListDevicesParams < Courier::Internal::Type::BaseModel
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ # @!method initialize(request_options: {})
11
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::Previews#retrieve_device_set
6
+ class PreviewRetrieveDeviceSetParams < Courier::Internal::Type::BaseModel
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ # @!attribute device_set_id
11
+ #
12
+ # @return [String]
13
+ required :device_set_id, String
14
+
15
+ # @!method initialize(device_set_id:, request_options: {})
16
+ # @param device_set_id [String]
17
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courier
4
+ module Models
5
+ # @see Courier::Resources::Previews#update_device_set
6
+ class PreviewUpdateDeviceSetParams < Courier::Models::CreateDeviceSetRequest
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ # @!attribute device_set_id
11
+ #
12
+ # @return [String]
13
+ required :device_set_id, String
14
+
15
+ # @!method initialize(device_set_id:, request_options: {})
16
+ # @param device_set_id [String]
17
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}]
18
+ end
19
+ end
20
+ end
@@ -179,10 +179,16 @@ module Courier
179
179
 
180
180
  CreateBroadcastRequest = Courier::Models::CreateBroadcastRequest
181
181
 
182
+ CreateDeviceSetRequest = Courier::Models::CreateDeviceSetRequest
183
+
182
184
  CreateJourneyRequest = Courier::Models::CreateJourneyRequest
183
185
 
184
186
  DefaultPreferences = Courier::Models::DefaultPreferences
185
187
 
188
+ DeviceSet = Courier::Models::DeviceSet
189
+
190
+ DeviceSetListResponse = Courier::Models::DeviceSetListResponse
191
+
186
192
  DeviceType = Courier::Models::DeviceType
187
193
 
188
194
  DigestCategory = Courier::Models::DigestCategory
@@ -525,6 +531,22 @@ module Courier
525
531
 
526
532
  PreferenceStatus = Courier::Models::PreferenceStatus
527
533
 
534
+ PreviewArchiveDeviceSetParams = Courier::Models::PreviewArchiveDeviceSetParams
535
+
536
+ PreviewCreateDeviceSetParams = Courier::Models::PreviewCreateDeviceSetParams
537
+
538
+ PreviewDevice = Courier::Models::PreviewDevice
539
+
540
+ PreviewDeviceListResponse = Courier::Models::PreviewDeviceListResponse
541
+
542
+ PreviewListDeviceSetsParams = Courier::Models::PreviewListDeviceSetsParams
543
+
544
+ PreviewListDevicesParams = Courier::Models::PreviewListDevicesParams
545
+
546
+ PreviewRetrieveDeviceSetParams = Courier::Models::PreviewRetrieveDeviceSetParams
547
+
548
+ PreviewUpdateDeviceSetParams = Courier::Models::PreviewUpdateDeviceSetParams
549
+
528
550
  ProfileCreateParams = Courier::Models::ProfileCreateParams
529
551
 
530
552
  ProfileDeleteParams = Courier::Models::ProfileDeleteParams
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
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
+ # Some parameter documentations has been truncated, see
11
+ # {Courier::Models::Notifications::Previews::RunCreateParams} for more details.
12
+ #
13
+ # Render this template's email content on each of the requested devices.
14
+ #
15
+ # Returns as soon as the run exists and its render is queued — the screenshots are
16
+ # produced asynchronously. Poll
17
+ # `GET /notifications/{id}/previews/runs/{previewRunId}` until every result
18
+ # reaches a terminal status.
19
+ #
20
+ # Name the devices either with `device_set_id`, for a saved set, or with
21
+ # `device_ids`, for a one-off list. Exactly one of the two is required. Inline
22
+ # `device_ids` must be ids listed by `GET /previews/devices`; any other id is a
23
+ # 422, refused before the run exists or is billed.
24
+ #
25
+ # A template that does not exist is a 404. One that exists but cannot be previewed
26
+ # — not a Design Studio template, no email channel, or no such `template_version`
27
+ # — is a 422, also refused before the run exists or is billed.
28
+ #
29
+ # Preview runs are a metered add-on. A workspace without it, or with its billing
30
+ # suspended, receives a 402.
31
+ #
32
+ # @overload create(id, data: nil, device_ids: nil, device_set_id: nil, locale: nil, template_version: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {})
33
+ #
34
+ # @param id [String] Path param: Template ID (nt\_ prefix). Must be a Design Studio template.
35
+ #
36
+ # @param data [Hash{Symbol=>Object}] Body param: Template variables to render with, the same shape as the `data` obje
37
+ #
38
+ # @param device_ids [Array<String>] Body param: The devices to render on, by `PreviewDevice.id`, for a one-off run.
39
+ #
40
+ # @param device_set_id [String] Body param: A saved device set naming the devices to render on. Mutually exclusi
41
+ #
42
+ # @param locale [String] Body param: Render the template's content for this locale, e.g. "fr-FR".
43
+ #
44
+ # @param template_version [String] Body param: Which version of the template to render. Omit for the latest saved d
45
+ #
46
+ # @param idempotency_key [String] Header param: A unique key that makes this request idempotent. If Courier receiv
47
+ #
48
+ # @param x_idempotency_expiration [String] Header param: How long the idempotency key remains valid, as a Unix epoch timest
49
+ #
50
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
51
+ #
52
+ # @return [Courier::Models::Notifications::Previews::PreviewRun]
53
+ #
54
+ # @see Courier::Models::Notifications::Previews::RunCreateParams
55
+ def create(id, params = {})
56
+ parsed, options = Courier::Notifications::Previews::RunCreateParams.dump_request(params)
57
+ header_params =
58
+ {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"}
59
+ @client.request(
60
+ method: :post,
61
+ path: ["notifications/%1$s/previews/runs", id],
62
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
63
+ body: parsed.except(*header_params.keys),
64
+ model: Courier::Notifications::Previews::PreviewRun,
65
+ options: options
66
+ )
67
+ end
68
+
69
+ # Some parameter documentations has been truncated, see
70
+ # {Courier::Models::Notifications::Previews::RunRetrieveParams} for more details.
71
+ #
72
+ # Retrieve one of this template's preview runs together with its per-device
73
+ # results.
74
+ #
75
+ # A run is only readable under the template it previewed: under any other template
76
+ # it is a 404, the same as a run that does not exist.
77
+ #
78
+ # `thumbnail_url` and `screenshot_url` are short-lived signed URLs, re-signed on
79
+ # every read. Fetch them now rather than storing them. Both are null until
80
+ # Courier's own copy of the image exists, which is what `status: COMPLETED` on a
81
+ # result means.
82
+ #
83
+ # @overload retrieve(preview_run_id, id:, request_options: {})
84
+ #
85
+ # @param preview_run_id [String] The preview run to retrieve, identified by the `id` returned when it was created
86
+ #
87
+ # @param id [String] Template ID (nt\_ prefix).
88
+ #
89
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
90
+ #
91
+ # @return [Courier::Models::Notifications::Previews::PreviewRunDetail]
92
+ #
93
+ # @see Courier::Models::Notifications::Previews::RunRetrieveParams
94
+ def retrieve(preview_run_id, params)
95
+ parsed, options = Courier::Notifications::Previews::RunRetrieveParams.dump_request(params)
96
+ id =
97
+ parsed.delete(:id) do
98
+ raise ArgumentError.new("missing required path argument #{_1}")
99
+ end
100
+ @client.request(
101
+ method: :get,
102
+ path: ["notifications/%1$s/previews/runs/%2$s", id, preview_run_id],
103
+ model: Courier::Notifications::Previews::PreviewRunDetail,
104
+ options: options
105
+ )
106
+ end
107
+
108
+ # List this template's preview runs, newest first. Cursor-paginated.
109
+ #
110
+ # A template that does not exist is a 404, the same as every other
111
+ # `/notifications/{id}` route.
112
+ #
113
+ # @overload list(id, cursor: nil, limit: nil, request_options: {})
114
+ #
115
+ # @param id [String] Template ID (nt\_ prefix).
116
+ #
117
+ # @param cursor [String, nil] Opaque pagination cursor from a previous response. Omit for the first page.
118
+ #
119
+ # @param limit [Integer] Maximum number of results per page.
120
+ #
121
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
122
+ #
123
+ # @return [Courier::Models::Notifications::Previews::PreviewRunListResponse]
124
+ #
125
+ # @see Courier::Models::Notifications::Previews::RunListParams
126
+ def list(id, params = {})
127
+ parsed, options = Courier::Notifications::Previews::RunListParams.dump_request(params)
128
+ query = Courier::Internal::Util.encode_query_params(parsed)
129
+ @client.request(
130
+ method: :get,
131
+ path: ["notifications/%1$s/previews/runs", id],
132
+ query: query,
133
+ model: Courier::Notifications::Previews::PreviewRunListResponse,
134
+ options: options
135
+ )
136
+ end
137
+
138
+ # @api private
139
+ #
140
+ # @param client [Courier::Client]
141
+ def initialize(client:)
142
+ @client = client
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
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
+ # @return [Courier::Resources::Notifications::Previews::Runs]
10
+ attr_reader :runs
11
+
12
+ # @api private
13
+ #
14
+ # @param client [Courier::Client]
15
+ def initialize(client:)
16
+ @client = client
17
+ @runs = Courier::Resources::Notifications::Previews::Runs.new(client: client)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -10,6 +10,9 @@ module Courier
10
10
  # @return [Courier::Resources::Notifications::Checks]
11
11
  attr_reader :checks
12
12
 
13
+ # @return [Courier::Resources::Notifications::Previews]
14
+ attr_reader :previews
15
+
13
16
  # Some parameter documentations has been truncated, see
14
17
  # {Courier::Models::NotificationCreateParams} for more details.
15
18
  #
@@ -422,6 +425,7 @@ module Courier
422
425
  def initialize(client:)
423
426
  @client = client
424
427
  @checks = Courier::Resources::Notifications::Checks.new(client: client)
428
+ @previews = Courier::Resources::Notifications::Previews.new(client: client)
425
429
  end
426
430
  end
427
431
  end