htmlcsstoimage-api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e31f5dd0bf4da3319b38ffc93f91859b65345b424b08bf750aed94a99f35fac3
4
- data.tar.gz: 18fb9f5a694c1f35d1b4d502c94f0ae61df5d199fffdab3defb11c216bd46156
3
+ metadata.gz: '048ac5012c53eb720767833ea51fa8f41884cc830cbb2b16a6efe61ddc61273c'
4
+ data.tar.gz: 2c32f384c2ec979a06df6d419e1496413600f918e75cccc41017d4293a80d4ca
5
5
  SHA512:
6
- metadata.gz: 66237da8da333169cac3bdb38c1dbd722fe66012a9d280f318a0c1c2cd4835f1905fb6cc2fa5cfe86974c38bfb9699bf0119e2c006144eb70c0c79f462f6e57c
7
- data.tar.gz: 21b6b6d5006672aa27f55425eb6f91cee86c3ecaafa303d5a35e19ad8d3cd01466ad857c1bdb68af683d464bb00fcb3593185f56d9d31360b58c0297bbeb3df6
6
+ metadata.gz: b6ea23f1bc285eafa767f2f2f2ca4470815c32307f25320b1265343162b1d4cf187c5f1c475472750fe50ea935d9fdc0bde408b638a190e163bebce6286f9d75
7
+ data.tar.gz: 4de98fdadc6afd13d1e17a0b13098b9faa30f8a3934a7e50d4bd9017ae3d00188ede6af8c545334a2d024ed695e68195318afd4b8911975169c2b8842582a41f
@@ -0,0 +1,23 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.6
20
+ - name: Install dependencies
21
+ run: bundle install
22
+ - name: Run tests
23
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -2,7 +2,6 @@
2
2
  /.yardoc
3
3
  /_yardoc/
4
4
  /coverage/
5
- /doc/
6
5
  /pkg/
7
6
  /spec/reports/
8
7
  /tmp/
@@ -0,0 +1,3 @@
1
+ source_branch: 'main'
2
+ source_directory: 'docs'
3
+ destination_branch: 'gh-pages'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- htmlcsstoimage-api (0.1.0)
4
+ htmlcsstoimage-api (0.1.1)
5
5
  httparty (> 0.10)
6
6
 
7
7
  GEM
@@ -30,7 +30,7 @@ GEM
30
30
  byebug (~> 11.0)
31
31
  pry (~> 0.13.0)
32
32
  public_suffix (4.0.5)
33
- rake (10.5.0)
33
+ rake (13.0.1)
34
34
  rspec (3.9.0)
35
35
  rspec-core (~> 3.9.0)
36
36
  rspec-expectations (~> 3.9.0)
@@ -59,7 +59,7 @@ DEPENDENCIES
59
59
  htmlcsstoimage-api!
60
60
  pry
61
61
  pry-byebug
62
- rake (~> 10.0)
62
+ rake (~> 13.0)
63
63
  rspec (~> 3.0)
64
64
  vcr
65
65
  webmock
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # HTML/CSS to Image - Ruby
2
2
 
3
+ ![Test](https://github.com/htmlcsstoimage/ruby-client/workflows/Test/badge.svg?branch=main) [![Gem Version](https://badge.fury.io/rb/htmlcsstoimage-api.svg)](https://badge.fury.io/rb/htmlcsstoimage-api)
4
+
3
5
  Ruby client for the [HTML/CSS to Image API](https://htmlcsstoimage.com).
4
6
 
5
7
  Generate a png, jpg or webp images with Ruby. Renders exactly like Google Chrome.
@@ -29,6 +31,8 @@ Create a new instance of the API client.
29
31
  client = HTMLCSSToImage.new(user_id: "user-id", api_key: "api-key")
30
32
  ```
31
33
 
34
+ **Using Environment variables**
35
+
32
36
  Alternatively, you can set `ENV["HCTI_USER_ID"]` and `ENV["HCTI_API_KEY"]`. These will be loaded automatically.
33
37
 
34
38
  ```ruby
@@ -36,6 +40,7 @@ client = HTMLCSSToImage.new
36
40
  ```
37
41
 
38
42
  ### Create an image
43
+ Generate an image from HTML/CSS. Returns a URL to the image.
39
44
 
40
45
  ```ruby
41
46
  image = client.create_image("<div>Hello, world</div>",
@@ -49,15 +54,40 @@ image.url
49
54
  ```
50
55
 
51
56
  ### Delete an image
52
- ```Ruby
57
+ Delete an existing image. Removes the image from HCTI servers and clears the CDN.
58
+
59
+ ```ruby
53
60
  client.delete_image("254b444c-dd82-4cc1-94ef-aa4b3a6870a6")
54
61
  ```
55
62
 
56
63
  ### URL to image
64
+ Generate a screenshot of any public URL.
65
+
57
66
  ```ruby
58
67
  image = client.url_to_image("https://github.com", viewport_width: 800, viewport_height: 1200)
59
68
  ```
60
69
 
70
+ ## Templates
71
+ A template allows you to define HTML that includes variables to be substituted at the time of image creation. [Learn more about templates](https://docs.htmlcsstoimage.com/getting-started/templates/).
72
+
73
+ ```ruby
74
+ template = client.create_template("<div>{{title}}</div>")
75
+ # => #<HTMLCSSToImage::ApiResponse template_id="t-56c64be5-5861-4148-acec-aaaca452027f", template_version=1596829374001>
76
+
77
+ # Get templates
78
+ all_templates = client.templates
79
+
80
+ # Create a signed URL for a templated image
81
+ image = client.create_image_from_template(template.template_id, { title: "Hello, world!" })
82
+ # => #<HTMLCSSToImage::ApiResponse url="https://hcti.io/v1/image/t-56c64be5-5861-4148-acec-aaaca452027f/3aaa814dd998b302cc62b3550ddb35e8b9117c5ecea286da904eced0a3f44d9e?title=Hello%2C%20world%21">
83
+
84
+ image.url
85
+ # => "https://hcti.io/v1/image/t-56c64be5-5861-4148-acec-aaaca452027f/3aaa814dd998b302cc62b3550ddb35e8b9117c5ecea286da904eced0a3f44d9e?title=Hello%2C%20world%21"
86
+ ```
87
+
88
+ ### Additional methods
89
+ See the [ruby-client docs for all of the available methods](https://htmlcsstoimage.github.io/ruby-client/HTMLCSSToImage.html).
90
+
61
91
  ## Available parameters
62
92
  For detailed information on all the available parameters, visit the docs: https://docs.htmlcsstoimage.com/getting-started/using-the-api/
63
93
 
@@ -67,12 +97,14 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
67
97
 
68
98
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
99
 
100
+ To generate the Yard docs, run `yard doc -o docs` and commit the changes.
101
+
70
102
  ## Support
71
103
  For help with the API, you can also contact `support@htmlcsstoimage.com`.
72
104
 
73
105
  ## Contributing
74
106
 
75
- Bug reports and pull requests are welcome on GitHub at https://github.com/htmlcsstoimage/ruby-client/contributor-covenant.org) code of conduct.
107
+ Bug reports and pull requests are welcome on GitHub at https://github.com/htmlcsstoimage/ruby-client.
76
108
 
77
109
  ## License
78
110
 
@@ -7,8 +7,5 @@ require "htmlcsstoimage"
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
10
+ require "pry"
11
+ Pry.start
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://hcti.io/v1/template
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"html":"<div>{{title}}</div>"}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - Ruby
18
+ Authorization:
19
+ - Basic authentication-header
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 07 Aug 2020 19:36:19 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Connection:
32
+ - keep-alive
33
+ Set-Cookie:
34
+ - AWSALB=8NnODxuzAe4Nb8xeygtwkJHJHF3lssQ/enmnhpDWIEnVBlUCGsJx7oOuPNoHhhnOmfAuosIx+goxLrCc65Bj5aHNLx2OQfAT2+s30zwTqYe68r9E92BliiwyFa5u;
35
+ Expires=Fri, 14 Aug 2020 19:36:19 GMT; Path=/
36
+ - AWSALBCORS=8NnODxuzAe4Nb8xeygtwkJHJHF3lssQ/enmnhpDWIEnVBlUCGsJx7oOuPNoHhhnOmfAuosIx+goxLrCc65Bj5aHNLx2OQfAT2+s30zwTqYe68r9E92BliiwyFa5u;
37
+ Expires=Fri, 14 Aug 2020 19:36:19 GMT; Path=/; SameSite=None
38
+ - __cfduid=d711e0d3ad7d037601f11d9cf3adf2b781596828978; expires=Sun, 06-Sep-20
39
+ 19:36:18 GMT; path=/; domain=.hcti.io; HttpOnly; SameSite=Lax
40
+ - __cflb=0H28vWzHFPHZw4TS8VrB813a2Y9bcaGDgdxkfUiw3uN; SameSite=Lax; path=/;
41
+ expires=Sat, 08-Aug-20 18:36:19 GMT; HttpOnly
42
+ Cf-Ray:
43
+ - 5bf3721e3a64ed8b-SJC
44
+ Access-Control-Allow-Origin:
45
+ - "*"
46
+ Vary:
47
+ - Accept-Encoding
48
+ Cf-Cache-Status:
49
+ - DYNAMIC
50
+ Cf-Request-Id:
51
+ - 046c05a6e10000ed8b05ab1200000001
52
+ Expect-Ct:
53
+ - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
54
+ Request-Context:
55
+ - appId=cid-v1:ef200074-f922-49b8-a889-360bb27d5561
56
+ Server:
57
+ - cloudflare
58
+ body:
59
+ encoding: ASCII-8BIT
60
+ string: '{"template_id":"t-5a518f6d-fc53-4c6a-96a1-34ef5ff89916","template_version":1596828979123}'
61
+ recorded_at: Fri, 07 Aug 2020 19:36:19 GMT
62
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,1065 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: HTMLCSSToImage
8
+
9
+ &mdash; Documentation by YARD 0.9.25
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "HTMLCSSToImage";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (H)</a> &raquo;
40
+
41
+
42
+ <span class="title">HTMLCSSToImage</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: HTMLCSSToImage
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">HTMLCSSToImage</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <dl>
91
+ <dt>Includes:</dt>
92
+ <dd>HTTParty</dd>
93
+ </dl>
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <dl>
101
+ <dt>Defined in:</dt>
102
+ <dd>lib/htmlcsstoimage.rb<span class="defines">,<br />
103
+ lib/htmlcsstoimage/version.rb</span>
104
+ </dd>
105
+ </dl>
106
+
107
+ </div>
108
+
109
+ <h2>Defined Under Namespace</h2>
110
+ <p class="children">
111
+
112
+
113
+
114
+
115
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="HTMLCSSToImage/ApiResponse.html" title="HTMLCSSToImage::ApiResponse (class)">ApiResponse</a></span>
116
+
117
+
118
+ </p>
119
+
120
+
121
+ <h2>
122
+ Constant Summary
123
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
124
+ </h2>
125
+
126
+ <dl class="constants">
127
+
128
+ <dt id="SIGNED_URL_TEMPLATE-constant" class="">SIGNED_URL_TEMPLATE =
129
+
130
+ </dt>
131
+ <dd><pre class="code"><span class='const'>Addressable</span><span class='op'>::</span><span class='const'>Template</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://hcti.io/v1/image/{template_id}/{signed_token}{/format*}{?query*}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span></pre></dd>
132
+
133
+ <dt id="VERSION-constant" class="">VERSION =
134
+
135
+ </dt>
136
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
137
+
138
+ </dl>
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+ <h2>
149
+ Instance Method Summary
150
+ <small><a href="#" class="summary_toggle">collapse</a></small>
151
+ </h2>
152
+
153
+ <ul class="summary">
154
+
155
+ <li class="public ">
156
+ <span class="summary_signature">
157
+
158
+ <a href="#create_image-instance_method" title="#create_image (instance method)">#<strong>create_image</strong>(html, params = {}) &#x21d2; HTMLCSSToImage::ApiResponse </a>
159
+
160
+
161
+
162
+ </span>
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+ <span class="summary_desc"><div class='inline'>
173
+ <p>Converts HTML/CSS to an image with the API.</p>
174
+ </div></span>
175
+
176
+ </li>
177
+
178
+
179
+ <li class="public ">
180
+ <span class="summary_signature">
181
+
182
+ <a href="#create_image_from_template-instance_method" title="#create_image_from_template (instance method)">#<strong>create_image_from_template</strong>(template_id, template_values = {}, params = {}) &#x21d2; Object </a>
183
+
184
+
185
+
186
+ </span>
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+ <span class="summary_desc"><div class='inline'>
197
+ <p>Creates a signed URL for generating an image from a template This URL contains the template_values in it.</p>
198
+ </div></span>
199
+
200
+ </li>
201
+
202
+
203
+ <li class="public ">
204
+ <span class="summary_signature">
205
+
206
+ <a href="#delete_image-instance_method" title="#delete_image (instance method)">#<strong>delete_image</strong>(image_id) &#x21d2; Object </a>
207
+
208
+
209
+
210
+ </span>
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ <span class="summary_desc"><div class='inline'>
221
+ <p>Deletes an image.</p>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ <li class="public ">
228
+ <span class="summary_signature">
229
+
230
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(user_id: ENV[&quot;HCTI_USER_ID&quot;], api_key: ENV[&quot;HCTI_API_KEY&quot;]) &#x21d2; HTMLCSSToImage </a>
231
+
232
+
233
+
234
+ </span>
235
+
236
+
237
+ <span class="note title constructor">constructor</span>
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+ <span class="summary_desc"><div class='inline'>
247
+ <p>Creates an instance of HTMLCSSToImage with API credentials.</p>
248
+ </div></span>
249
+
250
+ </li>
251
+
252
+
253
+ <li class="public ">
254
+ <span class="summary_signature">
255
+
256
+ <a href="#templates-instance_method" title="#templates (instance method)">#<strong>templates</strong>(params = {}) &#x21d2; Object </a>
257
+
258
+
259
+
260
+ </span>
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+ <span class="summary_desc"><div class='inline'>
271
+ <p>Retrieves all available templates.</p>
272
+ </div></span>
273
+
274
+ </li>
275
+
276
+
277
+ <li class="public ">
278
+ <span class="summary_signature">
279
+
280
+ <a href="#url_to_image-instance_method" title="#url_to_image (instance method)">#<strong>url_to_image</strong>(url, params = {}) &#x21d2; Object </a>
281
+
282
+
283
+
284
+ </span>
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+ <span class="summary_desc"><div class='inline'>
295
+ <p>Generate a screenshot of a URL.</p>
296
+ </div></span>
297
+
298
+ </li>
299
+
300
+
301
+ </ul>
302
+
303
+
304
+
305
+ <div id="constructor_details" class="method_details_list">
306
+ <h2>Constructor Details</h2>
307
+
308
+ <div class="method_details first">
309
+ <h3 class="signature first" id="initialize-instance_method">
310
+
311
+ #<strong>initialize</strong>(user_id: ENV[&quot;HCTI_USER_ID&quot;], api_key: ENV[&quot;HCTI_API_KEY&quot;]) &#x21d2; <tt><span class='object_link'><a href="" title="HTMLCSSToImage (class)">HTMLCSSToImage</a></span></tt>
312
+
313
+
314
+
315
+
316
+
317
+ </h3><div class="docstring">
318
+ <div class="discussion">
319
+
320
+ <p>Creates an instance of HTMLCSSToImage with API credentials.</p>
321
+
322
+ <pre class="code ruby"><code class="ruby">If credentials are not provided, will try to use environment variables.
323
+ `HCTI_USER_ID` and `HCTI_API_KEY`.
324
+ </code></pre>
325
+
326
+
327
+ </div>
328
+ </div>
329
+ <div class="tags">
330
+ <p class="tag_title">Parameters:</p>
331
+ <ul class="param">
332
+
333
+ <li>
334
+
335
+ <span class='name'>user_id</span>
336
+
337
+
338
+ <span class='type'>(<tt>String</tt>)</span>
339
+
340
+
341
+ <em class="default">(defaults to: <tt>ENV[&quot;HCTI_USER_ID&quot;]</tt>)</em>
342
+
343
+
344
+ &mdash;
345
+ <div class='inline'>
346
+ <p>the user_id for the account.</p>
347
+ </div>
348
+
349
+ </li>
350
+
351
+ <li>
352
+
353
+ <span class='name'>api_key</span>
354
+
355
+
356
+ <span class='type'>(<tt>String</tt>)</span>
357
+
358
+
359
+ <em class="default">(defaults to: <tt>ENV[&quot;HCTI_API_KEY&quot;]</tt>)</em>
360
+
361
+
362
+ &mdash;
363
+ <div class='inline'>
364
+ <p>the api_key for the account.</p>
365
+ </div>
366
+
367
+ </li>
368
+
369
+ </ul>
370
+
371
+
372
+ <p class="tag_title">See Also:</p>
373
+ <ul class="see">
374
+
375
+ <li><a href="https://htmlcsstoimage.com/dashboard" target="_parent" title="https://htmlcsstoimage.com/dashboard">https://htmlcsstoimage.com/dashboard</a></li>
376
+
377
+ </ul>
378
+
379
+ </div><table class="source_code">
380
+ <tr>
381
+ <td>
382
+ <pre class="lines">
383
+
384
+
385
+ 36
386
+ 37
387
+ 38</pre>
388
+ </td>
389
+ <td>
390
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 36</span>
391
+
392
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>user_id:</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>HCTI_USER_ID</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>api_key:</span> <span class='const'>ENV</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>HCTI_API_KEY</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
393
+ <span class='ivar'>@auth</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>username:</span> <span class='id identifier rubyid_user_id'>user_id</span><span class='comma'>,</span> <span class='label'>password:</span> <span class='id identifier rubyid_api_key'>api_key</span> <span class='rbrace'>}</span>
394
+ <span class='kw'>end</span></pre>
395
+ </td>
396
+ </tr>
397
+ </table>
398
+ </div>
399
+
400
+ </div>
401
+
402
+
403
+ <div id="instance_method_details" class="method_details_list">
404
+ <h2>Instance Method Details</h2>
405
+
406
+
407
+ <div class="method_details first">
408
+ <h3 class="signature first" id="create_image-instance_method">
409
+
410
+ #<strong>create_image</strong>(html, params = {}) &#x21d2; <tt><span class='object_link'><a href="HTMLCSSToImage/ApiResponse.html" title="HTMLCSSToImage::ApiResponse (class)">HTMLCSSToImage::ApiResponse</a></span></tt>
411
+
412
+
413
+
414
+
415
+
416
+ </h3><div class="docstring">
417
+ <div class="discussion">
418
+
419
+ <p>Converts HTML/CSS to an image with the API</p>
420
+
421
+
422
+ </div>
423
+ </div>
424
+ <div class="tags">
425
+ <p class="tag_title">Parameters:</p>
426
+ <ul class="param">
427
+
428
+ <li>
429
+
430
+ <span class='name'>html</span>
431
+
432
+
433
+ <span class='type'>(<tt>String</tt>)</span>
434
+
435
+
436
+
437
+ &mdash;
438
+ <div class='inline'>
439
+ <p>This is the HTML you want to render. You can send an HTML snippet (`&lt;div&gt;Your content&lt;/div&gt;`) or an entire webpage.</p>
440
+ </div>
441
+
442
+ </li>
443
+
444
+ <li>
445
+
446
+ <span class='name'>params</span>
447
+
448
+
449
+ <span class='type'>(<tt>Hash</tt>)</span>
450
+
451
+
452
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
453
+
454
+
455
+ &mdash;
456
+ <div class='inline'>
457
+ <p>a customizable set of options</p>
458
+ </div>
459
+
460
+ </li>
461
+
462
+ </ul>
463
+
464
+
465
+
466
+
467
+
468
+
469
+ <p class="tag_title">Options Hash (<tt>params</tt>):</p>
470
+ <ul class="option">
471
+
472
+ <li>
473
+ <span class="name">:css</span>
474
+ <span class="type">(<tt>String</tt>)</span>
475
+ <span class="default">
476
+
477
+ </span>
478
+
479
+ &mdash; <div class='inline'>
480
+ <p>The CSS for your image.</p>
481
+ </div>
482
+
483
+ </li>
484
+
485
+ <li>
486
+ <span class="name">:google_fonts</span>
487
+ <span class="type">(<tt>String</tt>)</span>
488
+ <span class="default">
489
+
490
+ </span>
491
+
492
+ &mdash; <div class='inline'>
493
+ <p>[Google fonts](<a href="https://docs.htmlcsstoimage.com/guides/using-google-fonts">docs.htmlcsstoimage.com/guides/using-google-fonts</a>/) to be loaded. Example: `Roboto`. Multiple fonts can be loaded like this: `Roboto|Open Sans`</p>
494
+ </div>
495
+
496
+ </li>
497
+
498
+ <li>
499
+ <span class="name">:selector</span>
500
+ <span class="type">(<tt>String</tt>)</span>
501
+ <span class="default">
502
+
503
+ </span>
504
+
505
+ &mdash; <div class='inline'>
506
+ <p>A CSS selector for an element on the webpage. We&#39;ll crop the image to this specific element. For example: `section#complete-toolkit.container-lg`</p>
507
+ </div>
508
+
509
+ </li>
510
+
511
+ <li>
512
+ <span class="name">:ms_delay</span>
513
+ <span class="type">(<tt>Integer</tt>)</span>
514
+ <span class="default">
515
+
516
+ </span>
517
+
518
+ &mdash; <div class='inline'>
519
+ <p>The number of milliseconds the API should delay before generating the image. This is useful when waiting for JavaScript. We recommend starting with `500`. Large values slow down the initial render time.</p>
520
+ </div>
521
+
522
+ </li>
523
+
524
+ <li>
525
+ <span class="name">:device_scale</span>
526
+ <span class="type">(<tt>Double</tt>)</span>
527
+ <span class="default">
528
+
529
+ </span>
530
+
531
+ &mdash; <div class='inline'>
532
+ <p>This adjusts the pixel ratio for the screenshot. Minimum: `1`, Maximum: `3`.</p>
533
+ </div>
534
+
535
+ </li>
536
+
537
+ <li>
538
+ <span class="name">:render_when_ready</span>
539
+ <span class="type">(<tt>Boolean</tt>)</span>
540
+ <span class="default">
541
+
542
+ </span>
543
+
544
+ &mdash; <div class='inline'>
545
+ <p>Set to true to control when the image is generated. Call `ScreenshotReady()` from JavaScript to generate the image. [Learn more](<a href="https://docs.htmlcsstoimage.com/guides/render-when-ready">docs.htmlcsstoimage.com/guides/render-when-ready</a>/).</p>
546
+ </div>
547
+
548
+ </li>
549
+
550
+ <li>
551
+ <span class="name">:viewport_width</span>
552
+ <span class="type">(<tt>Integer</tt>)</span>
553
+ <span class="default">
554
+
555
+ </span>
556
+
557
+ &mdash; <div class='inline'>
558
+ <p>Set the width of Chrome&#39;s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.</p>
559
+ </div>
560
+
561
+ </li>
562
+
563
+ <li>
564
+ <span class="name">:viewport_height</span>
565
+ <span class="type">(<tt>Integer</tt>)</span>
566
+ <span class="default">
567
+
568
+ </span>
569
+
570
+ &mdash; <div class='inline'>
571
+ <p>Set the height of Chrome&#39;s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.</p>
572
+ </div>
573
+
574
+ </li>
575
+
576
+ </ul>
577
+
578
+
579
+ <p class="tag_title">Returns:</p>
580
+ <ul class="return">
581
+
582
+ <li>
583
+
584
+
585
+ <span class='type'>(<tt><span class='object_link'><a href="HTMLCSSToImage/ApiResponse.html" title="HTMLCSSToImage::ApiResponse (class)">HTMLCSSToImage::ApiResponse</a></span></tt>)</span>
586
+
587
+
588
+
589
+ &mdash;
590
+ <div class='inline'>
591
+ <p>image URL available at `.url`.</p>
592
+ </div>
593
+
594
+ </li>
595
+
596
+ </ul>
597
+
598
+ <p class="tag_title">See Also:</p>
599
+ <ul class="see">
600
+
601
+ <li><a href="https://docs.htmlcsstoimage.com/getting-started/using-the-api" target="_parent" title="https://docs.htmlcsstoimage.com/getting-started/using-the-api">https://docs.htmlcsstoimage.com/getting-started/using-the-api</a></li>
602
+
603
+ </ul>
604
+
605
+ </div><table class="source_code">
606
+ <tr>
607
+ <td>
608
+ <pre class="lines">
609
+
610
+
611
+ 56
612
+ 57
613
+ 58
614
+ 59
615
+ 60
616
+ 61</pre>
617
+ </td>
618
+ <td>
619
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 56</span>
620
+
621
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_image'>create_image</span><span class='lparen'>(</span><span class='id identifier rubyid_html'>html</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
622
+ <span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>html:</span> <span class='id identifier rubyid_html'>html</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
623
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>basic_auth:</span> <span class='ivar'>@auth</span><span class='comma'>,</span> <span class='label'>body:</span> <span class='id identifier rubyid_body'>body</span><span class='comma'>,</span> <span class='label'>query:</span> <span class='lbrace'>{</span> <span class='label'>includeId:</span> <span class='kw'>true</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
624
+
625
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/v1/image</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
626
+ <span class='kw'>end</span></pre>
627
+ </td>
628
+ </tr>
629
+ </table>
630
+ </div>
631
+
632
+ <div class="method_details ">
633
+ <h3 class="signature " id="create_image_from_template-instance_method">
634
+
635
+ #<strong>create_image_from_template</strong>(template_id, template_values = {}, params = {}) &#x21d2; <tt>Object</tt>
636
+
637
+
638
+
639
+
640
+
641
+ </h3><div class="docstring">
642
+ <div class="discussion">
643
+
644
+ <p>Creates a signed URL for generating an image from a template This URL contains the template_values in it. It is signed with HMAC so that it cannot be changed by anyone without the API Key.</p>
645
+
646
+ <p>Does not make any network requests.</p>
647
+
648
+
649
+ </div>
650
+ </div>
651
+ <div class="tags">
652
+ <p class="tag_title">Parameters:</p>
653
+ <ul class="param">
654
+
655
+ <li>
656
+
657
+ <span class='name'>template_id</span>
658
+
659
+
660
+ <span class='type'>(<tt>String</tt>)</span>
661
+
662
+
663
+
664
+ &mdash;
665
+ <div class='inline'>
666
+ <p>The ID for the template</p>
667
+ </div>
668
+
669
+ </li>
670
+
671
+ <li>
672
+
673
+ <span class='name'>template_values</span>
674
+
675
+
676
+ <span class='type'>(<tt>Hash</tt>)</span>
677
+
678
+
679
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
680
+
681
+
682
+ &mdash;
683
+ <div class='inline'>
684
+ <p>A hash containing the values to replace in the template</p>
685
+ </div>
686
+
687
+ </li>
688
+
689
+ </ul>
690
+
691
+
692
+ <p class="tag_title">See Also:</p>
693
+ <ul class="see">
694
+
695
+ <li><a href="https://docs.htmlcsstoimage.com/getting-started/using-the-api" target="_parent" title="https://docs.htmlcsstoimage.com/getting-started/using-the-api">https://docs.htmlcsstoimage.com/getting-started/using-the-api</a></li>
696
+
697
+ </ul>
698
+
699
+ </div><table class="source_code">
700
+ <tr>
701
+ <td>
702
+ <pre class="lines">
703
+
704
+
705
+ 87
706
+ 88
707
+ 89
708
+ 90
709
+ 91
710
+ 92
711
+ 93
712
+ 94
713
+ 95
714
+ 96
715
+ 97
716
+ 98
717
+ 99
718
+ 100
719
+ 101
720
+ 102</pre>
721
+ </td>
722
+ <td>
723
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 87</span>
724
+
725
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_image_from_template'>create_image_from_template</span><span class='lparen'>(</span><span class='id identifier rubyid_template_id'>template_id</span><span class='comma'>,</span> <span class='id identifier rubyid_template_values'>template_values</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
726
+ <span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#SIGNED_URL_TEMPLATE-constant" title="HTMLCSSToImage::SIGNED_URL_TEMPLATE (constant)">SIGNED_URL_TEMPLATE</a></span></span><span class='period'>.</span><span class='id identifier rubyid_partial_expand'>partial_expand</span><span class='lparen'>(</span><span class='lbrace'>{</span>
727
+ <span class='label'>template_id:</span> <span class='id identifier rubyid_template_id'>template_id</span><span class='comma'>,</span>
728
+ <span class='label'>query:</span> <span class='id identifier rubyid_template_values'>template_values</span>
729
+ <span class='rbrace'>}</span><span class='rparen'>)</span>
730
+
731
+ <span class='id identifier rubyid_query'>query</span> <span class='op'>=</span> <span class='const'>Addressable</span><span class='op'>::</span><span class='const'>URI</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_generate'>generate</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_query'>query</span>
732
+ <span class='id identifier rubyid_digest'>digest</span> <span class='op'>=</span> <span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>Digest</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sha256</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
733
+ <span class='id identifier rubyid_signed_token'>signed_token</span> <span class='op'>=</span> <span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>HMAC</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span><span class='lparen'>(</span><span class='id identifier rubyid_digest'>digest</span><span class='comma'>,</span> <span class='ivar'>@auth</span><span class='lbracket'>[</span><span class='symbol'>:password</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>CGI</span><span class='period'>.</span><span class='id identifier rubyid_unescape'>unescape</span><span class='lparen'>(</span><span class='id identifier rubyid_query'>query</span><span class='rparen'>)</span><span class='rparen'>)</span>
734
+
735
+ <span class='id identifier rubyid_url'>url</span> <span class='op'>=</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_expand'>expand</span><span class='lparen'>(</span><span class='lbrace'>{</span>
736
+ <span class='label'>signed_token:</span> <span class='id identifier rubyid_signed_token'>signed_token</span>
737
+ <span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
738
+
739
+ <span class='const'><span class='object_link'><a href="HTMLCSSToImage/ApiResponse.html" title="HTMLCSSToImage::ApiResponse (class)">ApiResponse</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="HTMLCSSToImage#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>url:</span> <span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
740
+ <span class='kw'>end</span></pre>
741
+ </td>
742
+ </tr>
743
+ </table>
744
+ </div>
745
+
746
+ <div class="method_details ">
747
+ <h3 class="signature " id="delete_image-instance_method">
748
+
749
+ #<strong>delete_image</strong>(image_id) &#x21d2; <tt>Object</tt>
750
+
751
+
752
+
753
+
754
+
755
+ </h3><div class="docstring">
756
+ <div class="discussion">
757
+
758
+ <p>Deletes an image</p>
759
+
760
+
761
+ </div>
762
+ </div>
763
+ <div class="tags">
764
+ <p class="tag_title">Parameters:</p>
765
+ <ul class="param">
766
+
767
+ <li>
768
+
769
+ <span class='name'>image_id</span>
770
+
771
+
772
+ <span class='type'>(<tt>String</tt>)</span>
773
+
774
+
775
+
776
+ &mdash;
777
+ <div class='inline'>
778
+ <p>The ID for the image you would like to delete</p>
779
+ </div>
780
+
781
+ </li>
782
+
783
+ </ul>
784
+
785
+
786
+ <p class="tag_title">See Also:</p>
787
+ <ul class="see">
788
+
789
+ <li><a href="https://docs.htmlcsstoimage.com/getting-started/using-the-api" target="_parent" title="https://docs.htmlcsstoimage.com/getting-started/using-the-api">https://docs.htmlcsstoimage.com/getting-started/using-the-api</a></li>
790
+
791
+ </ul>
792
+
793
+ </div><table class="source_code">
794
+ <tr>
795
+ <td>
796
+ <pre class="lines">
797
+
798
+
799
+ 68
800
+ 69
801
+ 70
802
+ 71
803
+ 72
804
+ 73
805
+ 74</pre>
806
+ </td>
807
+ <td>
808
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 68</span>
809
+
810
+ <span class='kw'>def</span> <span class='id identifier rubyid_delete_image'>delete_image</span><span class='lparen'>(</span><span class='id identifier rubyid_image_id'>image_id</span><span class='rparen'>)</span>
811
+ <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/v1/image/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_image_id'>image_id</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>basic_auth:</span> <span class='ivar'>@auth</span><span class='rparen'>)</span>
812
+
813
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_success?'>success?</span>
814
+
815
+ <span class='id identifier rubyid_response'>response</span>
816
+ <span class='kw'>end</span></pre>
817
+ </td>
818
+ </tr>
819
+ </table>
820
+ </div>
821
+
822
+ <div class="method_details ">
823
+ <h3 class="signature " id="templates-instance_method">
824
+
825
+ #<strong>templates</strong>(params = {}) &#x21d2; <tt>Object</tt>
826
+
827
+
828
+
829
+
830
+
831
+ </h3><div class="docstring">
832
+ <div class="discussion">
833
+
834
+ <p>Retrieves all available templates</p>
835
+
836
+
837
+ </div>
838
+ </div>
839
+ <div class="tags">
840
+
841
+
842
+ <p class="tag_title">See Also:</p>
843
+ <ul class="see">
844
+
845
+ <li><a href="https://docs.htmlcsstoimage.com/getting-started/templates/" target="_parent" title="https://docs.htmlcsstoimage.com/getting-started/templates/">https://docs.htmlcsstoimage.com/getting-started/templates/</a></li>
846
+
847
+ </ul>
848
+
849
+ </div><table class="source_code">
850
+ <tr>
851
+ <td>
852
+ <pre class="lines">
853
+
854
+
855
+ 125
856
+ 126
857
+ 127
858
+ 128</pre>
859
+ </td>
860
+ <td>
861
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 125</span>
862
+
863
+ <span class='kw'>def</span> <span class='id identifier rubyid_templates'>templates</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
864
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>basic_auth:</span> <span class='ivar'>@auth</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
865
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/v1/template</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
866
+ <span class='kw'>end</span></pre>
867
+ </td>
868
+ </tr>
869
+ </table>
870
+ </div>
871
+
872
+ <div class="method_details ">
873
+ <h3 class="signature " id="url_to_image-instance_method">
874
+
875
+ #<strong>url_to_image</strong>(url, params = {}) &#x21d2; <tt>Object</tt>
876
+
877
+
878
+
879
+
880
+
881
+ </h3><div class="docstring">
882
+ <div class="discussion">
883
+
884
+ <p>Generate a screenshot of a URL</p>
885
+
886
+
887
+ </div>
888
+ </div>
889
+ <div class="tags">
890
+ <p class="tag_title">Parameters:</p>
891
+ <ul class="param">
892
+
893
+ <li>
894
+
895
+ <span class='name'>url</span>
896
+
897
+
898
+ <span class='type'>(<tt>String</tt>)</span>
899
+
900
+
901
+
902
+ &mdash;
903
+ <div class='inline'>
904
+ <p>The fully qualified URL to a public webpage. Such as <a href="https://htmlcsstoimage.com">htmlcsstoimage.com</a>.</p>
905
+ </div>
906
+
907
+ </li>
908
+
909
+ <li>
910
+
911
+ <span class='name'>params</span>
912
+
913
+
914
+ <span class='type'>(<tt>Hash</tt>)</span>
915
+
916
+
917
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
918
+
919
+
920
+ &mdash;
921
+ <div class='inline'>
922
+ <p>a customizable set of options</p>
923
+ </div>
924
+
925
+ </li>
926
+
927
+ </ul>
928
+
929
+
930
+
931
+
932
+
933
+
934
+ <p class="tag_title">Options Hash (<tt>params</tt>):</p>
935
+ <ul class="option">
936
+
937
+ <li>
938
+ <span class="name">:selector</span>
939
+ <span class="type">(<tt>String</tt>)</span>
940
+ <span class="default">
941
+
942
+ </span>
943
+
944
+ &mdash; <div class='inline'>
945
+ <p>A CSS selector for an element on the webpage. We&#39;ll crop the image to this specific element. For example: `section#complete-toolkit.container-lg`</p>
946
+ </div>
947
+
948
+ </li>
949
+
950
+ <li>
951
+ <span class="name">:ms_delay</span>
952
+ <span class="type">(<tt>Integer</tt>)</span>
953
+ <span class="default">
954
+
955
+ </span>
956
+
957
+ &mdash; <div class='inline'>
958
+ <p>The number of milliseconds the API should delay before generating the image. This is useful when waiting for JavaScript. We recommend starting with `500`. Large values slow down the initial render time.</p>
959
+ </div>
960
+
961
+ </li>
962
+
963
+ <li>
964
+ <span class="name">:device_scale</span>
965
+ <span class="type">(<tt>Double</tt>)</span>
966
+ <span class="default">
967
+
968
+ </span>
969
+
970
+ &mdash; <div class='inline'>
971
+ <p>This adjusts the pixel ratio for the screenshot. Minimum: `1`, Maximum: `3`.</p>
972
+ </div>
973
+
974
+ </li>
975
+
976
+ <li>
977
+ <span class="name">:render_when_ready</span>
978
+ <span class="type">(<tt>Boolean</tt>)</span>
979
+ <span class="default">
980
+
981
+ </span>
982
+
983
+ &mdash; <div class='inline'>
984
+ <p>Set to true to control when the image is generated. Call `ScreenshotReady()` from JavaScript to generate the image. [Learn more](<a href="https://docs.htmlcsstoimage.com/guides/render-when-ready">docs.htmlcsstoimage.com/guides/render-when-ready</a>/).</p>
985
+ </div>
986
+
987
+ </li>
988
+
989
+ <li>
990
+ <span class="name">:viewport_width</span>
991
+ <span class="type">(<tt>Integer</tt>)</span>
992
+ <span class="default">
993
+
994
+ </span>
995
+
996
+ &mdash; <div class='inline'>
997
+ <p>Set the width of Chrome&#39;s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.</p>
998
+ </div>
999
+
1000
+ </li>
1001
+
1002
+ <li>
1003
+ <span class="name">:viewport_height</span>
1004
+ <span class="type">(<tt>Integer</tt>)</span>
1005
+ <span class="default">
1006
+
1007
+ </span>
1008
+
1009
+ &mdash; <div class='inline'>
1010
+ <p>Set the height of Chrome&#39;s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.</p>
1011
+ </div>
1012
+
1013
+ </li>
1014
+
1015
+ </ul>
1016
+
1017
+
1018
+
1019
+ <p class="tag_title">See Also:</p>
1020
+ <ul class="see">
1021
+
1022
+ <li><a href="https://docs.htmlcsstoimage.com/getting-started/url-to-image/" target="_parent" title="https://docs.htmlcsstoimage.com/getting-started/url-to-image/">https://docs.htmlcsstoimage.com/getting-started/url-to-image/</a></li>
1023
+
1024
+ </ul>
1025
+
1026
+ </div><table class="source_code">
1027
+ <tr>
1028
+ <td>
1029
+ <pre class="lines">
1030
+
1031
+
1032
+ 115
1033
+ 116
1034
+ 117
1035
+ 118
1036
+ 119
1037
+ 120</pre>
1038
+ </td>
1039
+ <td>
1040
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 115</span>
1041
+
1042
+ <span class='kw'>def</span> <span class='id identifier rubyid_url_to_image'>url_to_image</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1043
+ <span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>url:</span> <span class='id identifier rubyid_url'>url</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
1044
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>basic_auth:</span> <span class='ivar'>@auth</span><span class='comma'>,</span> <span class='label'>body:</span> <span class='id identifier rubyid_body'>body</span><span class='comma'>,</span> <span class='label'>query:</span> <span class='lbrace'>{</span> <span class='label'>includeId:</span> <span class='kw'>true</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
1045
+
1046
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/v1/image</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
1047
+ <span class='kw'>end</span></pre>
1048
+ </td>
1049
+ </tr>
1050
+ </table>
1051
+ </div>
1052
+
1053
+ </div>
1054
+
1055
+ </div>
1056
+
1057
+ <div id="footer">
1058
+ Generated on Fri Aug 7 11:01:21 2020 by
1059
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1060
+ 0.9.25 (ruby-2.6.5).
1061
+ </div>
1062
+
1063
+ </div>
1064
+ </body>
1065
+ </html>