Skip to content

Commit 5484b01

Browse files
committed
Fix screenshot apps payload shape
1 parent 95e09e6 commit 5484b01

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,33 @@ Create a screenshot submission for all default apps:
4848
```ruby
4949
submission = PreflightQA::Screenshots.create(
5050
subject: "My Test Email",
51-
html: "<html><body>Hello world</body></html>",
52-
webhook_url: "https://example.com/preflight/webhook"
51+
html: "<html><body>Hello world</body></html>"
5352
)
5453

5554
submission.uuid
5655
submission.status
5756
submission.code
5857
```
5958

59+
`webhook_url` is optional. If you want PreflightQA to notify your app when rendering is finished, pass it explicitly:
60+
61+
```ruby
62+
submission = PreflightQA::Screenshots.create(
63+
subject: "My Test Email",
64+
html: "<html><body>Hello world</body></html>",
65+
webhook_url: "https://example.com/preflight/webhook"
66+
)
67+
```
68+
6069
You can also limit the request to specific apps and modes:
6170

6271
```ruby
6372
submission = PreflightQA::Screenshots.create(
6473
subject: "My Test Email",
6574
html: "<html><body>Hello world</body></html>",
6675
apps: {
67-
apple_mail_mac: [:light, :dark],
68-
outlook_mac: [:light]
76+
apple_mail_mac: { modes: [:light, :dark] },
77+
outlook_mac: { modes: [:light] }
6978
}
7079
)
7180
```

lib/preflight_qa/screenshots.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def normalize_apps(apps)
5454
raise ArgumentError, "apps must be a hash of app keys to mode arrays" unless apps.is_a?(Hash)
5555

5656
apps.each_with_object({}) do |(app, modes), normalized|
57-
normalized[app.to_s] = normalize_modes(modes)
57+
normalized[app.to_s] = { modes: normalize_modes(modes) }
5858
end
5959
end
6060
private_class_method :normalize_apps

spec/preflight_qa/screenshots_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
body: {
4444
subject: "My Test Email",
4545
html: "<html>test</html>",
46-
apps: { "apple_mail_mac" => %w[light dark] },
46+
apps: { "apple_mail_mac" => { modes: %w[light dark] } },
4747
webhook_url: "https://example.test/webhook",
4848
locale: "en-GB"
4949
}

0 commit comments

Comments
 (0)