htmlcsstoimage-api 0.3.0 → 1.0.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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +119 -0
- data/htmlcsstoimage.gemspec +1 -1
- data/lib/htmlcsstoimage/client.rb +1 -1
- data/lib/htmlcsstoimage/images.rb +23 -3
- data/lib/htmlcsstoimage/recordings.rb +108 -0
- data/lib/htmlcsstoimage/request_override_resource_type.rb +33 -0
- data/lib/htmlcsstoimage/signed_urls.rb +1 -1
- data/lib/htmlcsstoimage/templates.rb +2 -1
- data/lib/htmlcsstoimage/version.rb +1 -1
- data/lib/htmlcsstoimage.rb +2 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe88de5675da52a0325a6b46c0d223487bd6ff47d86df11c6bb26706ec1058ab
|
|
4
|
+
data.tar.gz: '069102c0a4c9bb0434567df163d2e9daf246ab1c410e384ec54418564fb9c557'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f39ad806edc68e1f47ab9e2edc3b04d02dca1a6dfa94d3f9ee88abb08fb9eae23fa914038c95bd0fa6b5f82f884700bcced11eeca24847eabbcdf7c6c8c70537
|
|
7
|
+
data.tar.gz: c4d476e92f6ef02bac29152e8452d755cdc099ace8d4e34412abe60adac67e759d315f3cae24c0cbe770213a5d828129807cb3c0a9515ca548ea9ed8522a27c6
|
data/.github/workflows/ruby.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -112,6 +112,107 @@ images = client.create_image_batch(
|
|
|
112
112
|
)
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
+
## Recordings
|
|
116
|
+
|
|
117
|
+
Record HTML/CSS or a public webpage as MP4, WebM, or GIF. Use
|
|
118
|
+
`create_html_css_recording` for HTML/CSS and `create_url_recording` for a webpage:
|
|
119
|
+
|
|
120
|
+
```ruby
|
|
121
|
+
recording = client.create_url_recording(
|
|
122
|
+
"https://example.com",
|
|
123
|
+
duration_ms: 10000,
|
|
124
|
+
viewport_width: 1280,
|
|
125
|
+
viewport_height: 720,
|
|
126
|
+
actions: [{ type: "simple_scroll" }],
|
|
127
|
+
output: { format: "mp4" }
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
recording.id
|
|
131
|
+
recording.status_url
|
|
132
|
+
recording.recording_url
|
|
133
|
+
|
|
134
|
+
animation = client.create_html_css_recording(
|
|
135
|
+
"<h1>Hello</h1>",
|
|
136
|
+
css: "@keyframes fade { from { opacity: 0; } to { opacity: 1; } } h1 { animation: fade 2s; font-family: Roboto; }",
|
|
137
|
+
google_fonts: "Roboto",
|
|
138
|
+
duration_ms: 3000,
|
|
139
|
+
duration_mode: "fixed",
|
|
140
|
+
output: { format: "gif", scale: 0.5 }
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Both methods accept browser, timeline, and output options as hashes, following
|
|
145
|
+
the image methods. Options pass through to the API without local validation.
|
|
146
|
+
Omitted settings use API defaults. Recordings do not include audio.
|
|
147
|
+
|
|
148
|
+
Triggers and actions use a `type` discriminator. For example, wait until an
|
|
149
|
+
element is visible, click a button, and hold the result:
|
|
150
|
+
|
|
151
|
+
```ruby
|
|
152
|
+
demo = client.create_url_recording(
|
|
153
|
+
"https://example.com/demo",
|
|
154
|
+
duration_ms: 5000,
|
|
155
|
+
duration_mode: "fixed",
|
|
156
|
+
trigger: { type: "element_visible", selector: "#demo", timeout_ms: 2000 },
|
|
157
|
+
actions: [
|
|
158
|
+
{ type: "click", selector: "#start", if_not_found: [{ type: "error" }] },
|
|
159
|
+
{ type: "stall", duration_ms: 1000 }
|
|
160
|
+
]
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Nested branches run on the API. For JavaScript actions, omitting `if_error` or
|
|
165
|
+
setting it to `nil` fails on a script error; `if_error: []` ignores errors.
|
|
166
|
+
Empty arrays, explicit `nil`, `false`, and zero values are preserved in JSON.
|
|
167
|
+
|
|
168
|
+
A `scroll` action moves through ordered `steps`. Each step's `duration_ms` is
|
|
169
|
+
required and must be at least 1:
|
|
170
|
+
|
|
171
|
+
```ruby
|
|
172
|
+
client.create_url_recording(
|
|
173
|
+
"https://example.com",
|
|
174
|
+
duration_ms: 6000,
|
|
175
|
+
actions: [
|
|
176
|
+
{ type: "scroll", steps: [
|
|
177
|
+
{ to: { type: "selector", selector: "#pricing" }, duration_ms: 1200, easing: "ease_in_out_cubic" },
|
|
178
|
+
{ to: { type: "position", position: "bottom" }, duration_ms: 1500 }
|
|
179
|
+
] }
|
|
180
|
+
]
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Embed or request `recording_url` directly; the request waits until the
|
|
185
|
+
recording is ready, so checking status is optional. To inspect progress, fetch
|
|
186
|
+
the current status once with:
|
|
187
|
+
|
|
188
|
+
```ruby
|
|
189
|
+
status = client.fetch_recording_status(recording.id)
|
|
190
|
+
puts status.status
|
|
191
|
+
puts status.attempt_count
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
HTTP 200 and 202 both return status information. The states `ready`, `failed`,
|
|
195
|
+
and `cancelled` are terminal. A successful status fetch can report a failed
|
|
196
|
+
recording, and `status.error` can describe an earlier, retryable attempt.
|
|
197
|
+
`status.status` is the raw API string. Treat values not listed here, which
|
|
198
|
+
newer API versions may add, as unknown; the client passes them through as-is.
|
|
199
|
+
API errors and transport failures follow the existing image-method behavior.
|
|
200
|
+
|
|
201
|
+
Delete recordings individually or in a batch:
|
|
202
|
+
|
|
203
|
+
```ruby
|
|
204
|
+
client.delete_recording("recording-id")
|
|
205
|
+
client.delete_recording_batch(["first-id", "second-id"])
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Deletion returns `true` when accepted, or the API response on failure. Empty
|
|
209
|
+
batch lists succeed without an API request, matching `delete_image_batch`.
|
|
210
|
+
|
|
211
|
+
See the [recording guide](https://docs.htmlcsstoimage.com/getting-started/recordings/),
|
|
212
|
+
[actions reference](https://docs.htmlcsstoimage.com/parameters/actions/), and
|
|
213
|
+
[trigger reference](https://docs.htmlcsstoimage.com/parameters/trigger/) for
|
|
214
|
+
options and examples.
|
|
215
|
+
|
|
115
216
|
## Signed URLs
|
|
116
217
|
|
|
117
218
|
Signed URLs let another application, browser, or service render an image on
|
|
@@ -285,3 +386,21 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
285
386
|
## Code of Conduct
|
|
286
387
|
|
|
287
388
|
Everyone interacting in the project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/htmlcsstoimage/ruby-client/blob/main/CODE_OF_CONDUCT.md).
|
|
389
|
+
|
|
390
|
+
## Templated image batches
|
|
391
|
+
|
|
392
|
+
Create images from one or more templates with shared defaults and ordered variations:
|
|
393
|
+
|
|
394
|
+
```ruby
|
|
395
|
+
result = client.create_templated_image_batch(
|
|
396
|
+
[
|
|
397
|
+
{ template_values: { title: "First" } },
|
|
398
|
+
{ template_id: "t-other", template_values: { title: "Second" } }
|
|
399
|
+
],
|
|
400
|
+
{ template_id: "t-card", template_version: 3, format: "webp" }
|
|
401
|
+
)
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Omitted fields inherit defaults. Supplying a template ID resets the inherited version; omit its version to use latest. Template value objects merge recursively on the API; arrays, scalars, and explicit null values replace defaults. Results preserve input order and identical images reuse existing assets. Each merged values object must be nonempty and satisfy its template's required variables.
|
|
405
|
+
|
|
406
|
+
See the [API reference](https://docs.htmlcsstoimage.com/getting-started/using-the-api/#batch-templated-image-creation) for plan limits and examples.
|
data/htmlcsstoimage.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ["support@htmlcsstoimage.com"]
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{Ruby client for the HTML/CSS to Image API.}
|
|
13
|
-
spec.description = %q{Ruby client for the HTML/CSS to Image API. Generate PNG, JPG, WebP, or PDF
|
|
13
|
+
spec.description = %q{Ruby client for the HTML/CSS to Image API. Generate PNG, JPG, WebP, or PDF images and MP4, WebM, or GIF recordings with Ruby. Renders exactly like Google Chrome. }
|
|
14
14
|
spec.homepage = "https://docs.htmlcsstoimage.com/example-code/ruby"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
spec.required_ruby_version = ">= 2.7.0"
|
|
@@ -16,7 +16,7 @@ class HTMLCSSToImage
|
|
|
16
16
|
# @option params [Integer] :viewport_height The Chrome viewport height. Both viewport dimensions must be set if using either.
|
|
17
17
|
# @option params [Integer] :viewport_width The Chrome viewport width. Both viewport dimensions must be set if using either.
|
|
18
18
|
# @option params [Hash] :pdf_options Options for generating a PDF, including page size, margins, scale, and background printing.
|
|
19
|
-
# @option params [Boolean] :disable_twemoji
|
|
19
|
+
# @option params [Boolean] :disable_twemoji For HTML/CSS, true disables default Twemoji replacement. For URLs, only explicit false injects Twemoji; omitted or true leaves the page unchanged.
|
|
20
20
|
# @option params [Boolean] :max_render_once Ensure the image is only rendered and saved once.
|
|
21
21
|
# @option params [Integer] :dedupe_duration_s Reuse an identical image created within this many seconds. Only supported for single-image POST requests.
|
|
22
22
|
# @option params [String] :color_scheme Render using the `light` or `dark` browser color scheme.
|
|
@@ -26,6 +26,7 @@ class HTMLCSSToImage
|
|
|
26
26
|
# @option params [Boolean] :viewport_touch Whether the viewport supports touch events.
|
|
27
27
|
# @option params [String] :media_type Render using `print` or `screen` media.
|
|
28
28
|
# @option params [String] :proxy_id The ID of an organization proxy to use for the render.
|
|
29
|
+
# @option params [Array<Hash>] :request_overrides Browser request block rules, such as `{ action: "block", resource_types: [RequestOverrideResourceType::Script] }`. Requires a paid plan.
|
|
29
30
|
# @option params [String] :storage_destination_id The ID of an organization storage destination for the rendered image.
|
|
30
31
|
# @option params [Integer] :jumbo_max_height Maximum output height in jumbo mode. Requires `jumbo_max_width`.
|
|
31
32
|
# @option params [Integer] :jumbo_max_width Maximum output width in jumbo mode. Requires `jumbo_max_height`.
|
|
@@ -55,7 +56,7 @@ class HTMLCSSToImage
|
|
|
55
56
|
# @option params [Integer] :viewport_height The Chrome viewport height. Both viewport dimensions must be set if using either.
|
|
56
57
|
# @option params [Integer] :viewport_width The Chrome viewport width. Both viewport dimensions must be set if using either.
|
|
57
58
|
# @option params [Hash] :pdf_options Options for generating a PDF, including page size, margins, scale, and background printing.
|
|
58
|
-
# @option params [Boolean] :disable_twemoji
|
|
59
|
+
# @option params [Boolean] :disable_twemoji For HTML/CSS, true disables default Twemoji replacement. For URLs, only explicit false injects Twemoji; omitted or true leaves the page unchanged.
|
|
59
60
|
# @option params [Boolean] :max_render_once Ensure the image is only rendered and saved once.
|
|
60
61
|
# @option params [Integer] :dedupe_duration_s Reuse an identical image created within this many seconds. Only supported for single-image POST requests.
|
|
61
62
|
# @option params [String] :color_scheme Render using the `light` or `dark` browser color scheme.
|
|
@@ -70,6 +71,7 @@ class HTMLCSSToImage
|
|
|
70
71
|
# @option params [Boolean] :viewport_touch Whether the viewport supports touch events.
|
|
71
72
|
# @option params [String] :media_type Render using `print` or `screen` media.
|
|
72
73
|
# @option params [String] :proxy_id The ID of an organization proxy to use for the render.
|
|
74
|
+
# @option params [Array<Hash>] :request_overrides Browser request block rules, such as `{ action: "block", resource_types: [RequestOverrideResourceType::Script] }`. Requires a paid plan.
|
|
73
75
|
# @option params [String] :storage_destination_id The ID of an organization storage destination for the rendered image.
|
|
74
76
|
# @option params [Integer] :jumbo_max_height Maximum output height in jumbo mode. Requires `jumbo_max_width`.
|
|
75
77
|
# @option params [Integer] :jumbo_max_width Maximum output width in jumbo mode. Requires `jumbo_max_height`.
|
|
@@ -117,7 +119,7 @@ class HTMLCSSToImage
|
|
|
117
119
|
|
|
118
120
|
# Creates several HTML/CSS or URL images in one API request.
|
|
119
121
|
#
|
|
120
|
-
#
|
|
122
|
+
# For template batches, use #create_templated_image_batch.
|
|
121
123
|
#
|
|
122
124
|
# @see https://docs.htmlcsstoimage.com/getting-started/using-the-api
|
|
123
125
|
#
|
|
@@ -137,6 +139,24 @@ class HTMLCSSToImage
|
|
|
137
139
|
)
|
|
138
140
|
end
|
|
139
141
|
|
|
142
|
+
# Creates images from one or more templates in a single request.
|
|
143
|
+
# Objects in template_values merge recursively; arrays, scalars and null replace defaults.
|
|
144
|
+
# Supplying template_id resets the inherited version; omit a version to use latest.
|
|
145
|
+
# @param variations [Array<Hash>] per-image template options; results preserve this order
|
|
146
|
+
# @param default_options [Hash, nil] shared template_id, template_version, template_values and format
|
|
147
|
+
# @return [HTMLCSSToImage::ApiResponse] batch response with results at `.images`
|
|
148
|
+
def create_templated_image_batch(variations, default_options = nil)
|
|
149
|
+
return ApiResponse.new(images: []) if variations.empty?
|
|
150
|
+
|
|
151
|
+
body = { variations: variations }
|
|
152
|
+
body[:default_options] = default_options unless default_options.nil?
|
|
153
|
+
self.class.post(
|
|
154
|
+
"/v1/image/batch/templated",
|
|
155
|
+
basic_auth: @auth,
|
|
156
|
+
body: body.to_json
|
|
157
|
+
)
|
|
158
|
+
end
|
|
159
|
+
|
|
140
160
|
# Deletes an image.
|
|
141
161
|
#
|
|
142
162
|
# @see https://docs.htmlcsstoimage.com/getting-started/using-the-api
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
class HTMLCSSToImage
|
|
2
|
+
# Records an HTML document or fragment with optional CSS and Google Fonts.
|
|
3
|
+
# Returns the recording ID, status URL, and media URL. The `recording_url` can
|
|
4
|
+
# be embedded or requested directly; a request waits until the recording is
|
|
5
|
+
# ready, so checking status is optional. Optional settings use the API defaults.
|
|
6
|
+
#
|
|
7
|
+
# @see https://docs.htmlcsstoimage.com/getting-started/recordings/
|
|
8
|
+
# @see https://docs.htmlcsstoimage.com/parameters/actions/
|
|
9
|
+
# @see https://docs.htmlcsstoimage.com/parameters/trigger/
|
|
10
|
+
# @see https://docs.htmlcsstoimage.com/parameters/output/
|
|
11
|
+
#
|
|
12
|
+
# @param html [String] HTML to record, as a fragment or a complete document
|
|
13
|
+
# @param params [Hash] browser, timeline, and output options passed to the API
|
|
14
|
+
# @option params [Integer] :duration_ms Required recording duration in milliseconds: 500–30000, or up to 90000 in target mode.
|
|
15
|
+
# @option params [String] :css CSS used to style the recording.
|
|
16
|
+
# @option params [String] :google_fonts Google Fonts to load, separated by `|`. Set font-family in the CSS to use them.
|
|
17
|
+
# @option params [Numeric] :device_scale Capture pixel density. HTML/CSS defaults to 2; URL recordings default to 1.
|
|
18
|
+
# @option params [Integer] :viewport_height Chrome viewport height in CSS pixels. Supply both viewport dimensions to set the recording size.
|
|
19
|
+
# @option params [Integer] :viewport_width Chrome viewport width in CSS pixels. Supply both viewport dimensions to set the recording size.
|
|
20
|
+
# @option params [Boolean] :disable_twemoji True disables Twemoji for HTML/CSS. URL recordings inject Twemoji only when explicitly false.
|
|
21
|
+
# @option params [Integer] :dedupe_duration_s Reuse an identical recent recording for this many seconds. Set to 0 to disable deduplication.
|
|
22
|
+
# @option params [String] :color_scheme Chrome's preferred color scheme: `light` or `dark`.
|
|
23
|
+
# @option params [String] :timezone Browser timezone as an IANA identifier, such as `America/New_York`.
|
|
24
|
+
# @option params [Boolean] :viewport_mobile Enable mobile viewport behavior, including the page's viewport meta tag.
|
|
25
|
+
# @option params [Boolean] :viewport_landscape Emulate landscape orientation.
|
|
26
|
+
# @option params [Boolean] :viewport_touch Emulate touch support.
|
|
27
|
+
# @option params [String] :media_type CSS media type used while recording: `print` or `screen`.
|
|
28
|
+
# @option params [String] :proxy_id Configured organization proxy to use while recording.
|
|
29
|
+
# @option params [String] :storage_destination_id Configured storage destination to receive the recording.
|
|
30
|
+
# @option params [Array<Hash>] :request_overrides Browser request block rules. Requires a paid plan.
|
|
31
|
+
# @option params [Hash] :trigger Start condition: `type: "immediate"` (default), `"element_visible"` with a `selector`, or `"function_call"` to wait for `window.RecordingReady()`. Waiting triggers accept `timeout_ms`.
|
|
32
|
+
# @option params [Array<Hash>] :actions Ordered timeline interactions: `simple_scroll`, `scroll`, `stall`, `click`, `locate_selector`, `execute_javascript`, or `error`. Each action has a `type` discriminator. Each `scroll` action step requires `duration_ms` of at least 1. Omit or use an empty array to record without interactions.
|
|
33
|
+
# @option params [Hash] :output Media `format` (`mp4`, `webm`, or `gif`), `fps`, and pixel `scale`. Defaults to MP4 at 30 fps; GIF defaults to 15 fps. Recordings have no audio.
|
|
34
|
+
# @option params [String] :duration_mode `at_most` (default) stops when actions finish or the duration is reached. `fixed` pads or cuts off at that duration. `at_least` lets actions finish up to 90 seconds. `target` adjusts playback speed to fit the duration.
|
|
35
|
+
# @option params [Boolean] :defer_render Wait to render until media or storage is requested. Defaults to false; does not reset deduplicated recordings.
|
|
36
|
+
# @option params [Boolean] :skip_scroll_preload Skip the preparation scroll that loads lazy content. Scrolling actions still run. Defaults to false.
|
|
37
|
+
# @return [HTMLCSSToImage::ApiResponse] recording details at `.id`, `.status_url`, and `.recording_url`
|
|
38
|
+
def create_html_css_recording(html, params = {})
|
|
39
|
+
body = { html: html }.merge(params).to_json
|
|
40
|
+
|
|
41
|
+
self.class.post("/v1/recording", basic_auth: @auth, body: body)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Records a public HTTP or HTTPS webpage.
|
|
45
|
+
#
|
|
46
|
+
# Accepts the browser, timeline, and output options documented on
|
|
47
|
+
# {#create_html_css_recording}. CSS is injected into the page after it loads.
|
|
48
|
+
#
|
|
49
|
+
# @see #create_html_css_recording
|
|
50
|
+
# @see https://docs.htmlcsstoimage.com/guides/recordings/scrolling-video/
|
|
51
|
+
#
|
|
52
|
+
# @param url [String] public HTTP or HTTPS URL to record
|
|
53
|
+
# @param params [Hash] recording options, including the required `duration_ms`
|
|
54
|
+
# @option params [Boolean] :block_consent_banners Attempt to hide cookie and consent banners before recording.
|
|
55
|
+
# @option params [Boolean] :identify_as_hcti Add `X-HCTI-SCREENSHOT: 1` to the top-level navigation.
|
|
56
|
+
# @option params [Hash{String => String}] :headers Custom HTTP headers for top-level navigations to the URL's origin and additional_header_origins.
|
|
57
|
+
# @option params [Array<String>] :additional_header_origins Additional exact HTTP or HTTPS origins allowed to receive custom headers.
|
|
58
|
+
# @option params [Boolean] :include_headers_on_subrequests Also send custom headers with subrequests to allowed origins. Defaults to false.
|
|
59
|
+
# @return [HTMLCSSToImage::ApiResponse] recording details at `.id`, `.status_url`, and `.recording_url`
|
|
60
|
+
def create_url_recording(url, params = {})
|
|
61
|
+
body = { url: url }.merge(params).to_json
|
|
62
|
+
|
|
63
|
+
self.class.post("/v1/recording", basic_auth: @auth, body: body)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Fetches a recording's current lifecycle state once. Checking status is
|
|
67
|
+
# optional: requesting the `recording_url` directly waits until it is ready.
|
|
68
|
+
# HTTP 200 and 202 both return status information. The states `ready`,
|
|
69
|
+
# `failed`, and `cancelled` are terminal; an error can also describe an
|
|
70
|
+
# earlier, retryable attempt. `.status` is the raw API string: treat values
|
|
71
|
+
# not listed here, which newer API versions may add, as unknown; the client
|
|
72
|
+
# passes them through as-is.
|
|
73
|
+
#
|
|
74
|
+
# @see https://docs.htmlcsstoimage.com/management-api/recordings/
|
|
75
|
+
#
|
|
76
|
+
# @param recording_id [String] the recording ID returned by creation
|
|
77
|
+
# @return [HTMLCSSToImage::ApiResponse] `.id`, `.status`, `.attempt_count`, `.status_entered_at`, `.stored_duration_ms`, `.storage_destination_hcti_storage_disabled`, `.recording_url`, and optional `.error`
|
|
78
|
+
def fetch_recording_status(recording_id)
|
|
79
|
+
self.class.get("/v1/recordings/#{recording_id}/status", basic_auth: @auth)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Deletes a recording and clears its media from the CDN.
|
|
83
|
+
#
|
|
84
|
+
# @param recording_id [String] the recording ID to delete
|
|
85
|
+
# @return [true, HTTParty::Response] true when accepted, or the API response on failure
|
|
86
|
+
def delete_recording(recording_id)
|
|
87
|
+
response = self.class.delete("/v1/recordings/#{recording_id}", basic_auth: @auth)
|
|
88
|
+
|
|
89
|
+
response.success? ? true : response
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Deletes several recordings in one API request.
|
|
93
|
+
# Empty lists succeed without calling the API, as with {#delete_image_batch}.
|
|
94
|
+
#
|
|
95
|
+
# @param recording_ids [Array<String>] the recording IDs to delete
|
|
96
|
+
# @return [true, HTTParty::Response] true when accepted, or the API response on failure
|
|
97
|
+
def delete_recording_batch(recording_ids)
|
|
98
|
+
return true if recording_ids.empty?
|
|
99
|
+
|
|
100
|
+
response = self.class.delete(
|
|
101
|
+
"/v1/recordings/batch",
|
|
102
|
+
basic_auth: @auth,
|
|
103
|
+
body: { ids: recording_ids }.to_json
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
response.success? ? true : response
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Named browser resource types for request_overrides rules.
|
|
2
|
+
class HTMLCSSToImage
|
|
3
|
+
class RequestOverrideResourceType
|
|
4
|
+
attr_reader :value
|
|
5
|
+
|
|
6
|
+
def initialize(value)
|
|
7
|
+
@value = value.freeze
|
|
8
|
+
freeze
|
|
9
|
+
end
|
|
10
|
+
private_class_method :new
|
|
11
|
+
|
|
12
|
+
def to_json(*args)
|
|
13
|
+
@value.to_json(*args)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Beacon = new("beacon")
|
|
17
|
+
Document = new("document")
|
|
18
|
+
Stylesheet = new("stylesheet")
|
|
19
|
+
Image = new("image")
|
|
20
|
+
ImageSet = new("image_set")
|
|
21
|
+
Media = new("media")
|
|
22
|
+
Font = new("font")
|
|
23
|
+
Script = new("script")
|
|
24
|
+
TextTrack = new("text_track")
|
|
25
|
+
Xhr = new("xhr")
|
|
26
|
+
Fetch = new("fetch")
|
|
27
|
+
EventSource = new("event_source")
|
|
28
|
+
Manifest = new("manifest")
|
|
29
|
+
Ping = new("ping")
|
|
30
|
+
Img = new("img")
|
|
31
|
+
Other = new("other")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -92,7 +92,7 @@ class HTMLCSSToImage
|
|
|
92
92
|
|
|
93
93
|
params
|
|
94
94
|
.reject do |key, _value|
|
|
95
|
-
%w[url format pdf_options dedupe_duration_s].include?(key.to_s)
|
|
95
|
+
%w[url format pdf_options dedupe_duration_s request_overrides].include?(key.to_s)
|
|
96
96
|
end
|
|
97
97
|
.sort_by { |key, _value| key.to_s }
|
|
98
98
|
.each do |key, value|
|
|
@@ -58,7 +58,7 @@ class HTMLCSSToImage
|
|
|
58
58
|
# @option params [String] :selector A CSS selector for the element to capture.
|
|
59
59
|
# @option params [Integer] :viewport_height The Chrome viewport height. Both viewport dimensions must be set if using either.
|
|
60
60
|
# @option params [Integer] :viewport_width The Chrome viewport width. Both viewport dimensions must be set if using either.
|
|
61
|
-
# @option params [Boolean] :disable_twemoji
|
|
61
|
+
# @option params [Boolean] :disable_twemoji Templates use Twemoji by default; true uses supplied or native emoji fonts instead.
|
|
62
62
|
# @option params [String] :color_scheme Render using the `light` or `dark` browser color scheme.
|
|
63
63
|
# @option params [String] :timezone The browser timezone as an IANA timezone identifier, such as `America/New_York`.
|
|
64
64
|
# @option params [Boolean] :viewport_mobile Whether to honor the page's mobile viewport behavior.
|
|
@@ -68,6 +68,7 @@ class HTMLCSSToImage
|
|
|
68
68
|
# @option params [Integer] :jumbo_max_height Maximum output height in jumbo mode. Requires `jumbo_max_width`.
|
|
69
69
|
# @option params [Integer] :jumbo_max_width Maximum output width in jumbo mode. Requires `jumbo_max_height`.
|
|
70
70
|
# @option params [String] :proxy_id The ID of an organization proxy to use for the render.
|
|
71
|
+
# @option params [Array<Hash>] :request_overrides Browser request block rules. Use `RequestOverrideResourceType` values in `resource_types`.
|
|
71
72
|
# @option params [String] :storage_destination_id The ID of an organization storage destination inherited by images created from the template.
|
|
72
73
|
# @option params [Boolean] :transparent_background Whether images created from the template should use a transparent background.
|
|
73
74
|
# @return [HTMLCSSToImage::ApiResponse] created template details
|
data/lib/htmlcsstoimage.rb
CHANGED
|
@@ -6,6 +6,8 @@ require "addressable/uri"
|
|
|
6
6
|
require "ostruct"
|
|
7
7
|
|
|
8
8
|
require "htmlcsstoimage/client"
|
|
9
|
+
require "htmlcsstoimage/request_override_resource_type"
|
|
9
10
|
require "htmlcsstoimage/images"
|
|
11
|
+
require "htmlcsstoimage/recordings"
|
|
10
12
|
require "htmlcsstoimage/signed_urls"
|
|
11
13
|
require "htmlcsstoimage/templates"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: htmlcsstoimage-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Coutermarsh
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-11-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: httparty
|
|
@@ -152,7 +152,8 @@ dependencies:
|
|
|
152
152
|
- !ruby/object:Gem::Version
|
|
153
153
|
version: '0.9'
|
|
154
154
|
description: 'Ruby client for the HTML/CSS to Image API. Generate PNG, JPG, WebP,
|
|
155
|
-
or PDF
|
|
155
|
+
or PDF images and MP4, WebM, or GIF recordings with Ruby. Renders exactly like Google
|
|
156
|
+
Chrome. '
|
|
156
157
|
email:
|
|
157
158
|
- support@htmlcsstoimage.com
|
|
158
159
|
executables: []
|
|
@@ -176,6 +177,8 @@ files:
|
|
|
176
177
|
- lib/htmlcsstoimage.rb
|
|
177
178
|
- lib/htmlcsstoimage/client.rb
|
|
178
179
|
- lib/htmlcsstoimage/images.rb
|
|
180
|
+
- lib/htmlcsstoimage/recordings.rb
|
|
181
|
+
- lib/htmlcsstoimage/request_override_resource_type.rb
|
|
179
182
|
- lib/htmlcsstoimage/signed_urls.rb
|
|
180
183
|
- lib/htmlcsstoimage/templates.rb
|
|
181
184
|
- lib/htmlcsstoimage/version.rb
|