@@ -25,9 +25,9 @@ class Avatars extends Service {
2525 '/avatars/browsers/{code}' .replaceAll ('{code}' , code.value);
2626
2727 final Map <String , dynamic > params = {
28- 'width' : width,
29- 'height' : height,
30- 'quality' : quality,
28+ if (width != null ) 'width' : width,
29+ if (height != null ) 'height' : height,
30+ if (quality != null ) 'quality' : quality,
3131 'project' : client.config['project' ],
3232 };
3333
@@ -54,9 +54,9 @@ class Avatars extends Service {
5454 '/avatars/credit-cards/{code}' .replaceAll ('{code}' , code.value);
5555
5656 final Map <String , dynamic > params = {
57- 'width' : width,
58- 'height' : height,
59- 'quality' : quality,
57+ if (width != null ) 'width' : width,
58+ if (height != null ) 'height' : height,
59+ if (quality != null ) 'quality' : quality,
6060 'project' : client.config['project' ],
6161 };
6262
@@ -98,9 +98,9 @@ class Avatars extends Service {
9898 '/avatars/flags/{code}' .replaceAll ('{code}' , code.value);
9999
100100 final Map <String , dynamic > params = {
101- 'width' : width,
102- 'height' : height,
103- 'quality' : quality,
101+ if (width != null ) 'width' : width,
102+ if (height != null ) 'height' : height,
103+ if (quality != null ) 'quality' : quality,
104104 'project' : client.config['project' ],
105105 };
106106
@@ -126,8 +126,8 @@ class Avatars extends Service {
126126
127127 final Map <String , dynamic > params = {
128128 'url' : url,
129- 'width' : width,
130- 'height' : height,
129+ if (width != null ) 'width' : width,
130+ if (height != null ) 'height' : height,
131131 'project' : client.config['project' ],
132132 };
133133
@@ -157,10 +157,10 @@ class Avatars extends Service {
157157 const String apiPath = '/avatars/initials' ;
158158
159159 final Map <String , dynamic > params = {
160- 'name' : name,
161- 'width' : width,
162- 'height' : height,
163- 'background' : background,
160+ if (name != null ) 'name' : name,
161+ if (width != null ) 'width' : width,
162+ if (height != null ) 'height' : height,
163+ if (background != null ) 'background' : background,
164164 'project' : client.config['project' ],
165165 };
166166
@@ -178,9 +178,71 @@ class Avatars extends Service {
178178
179179 final Map <String , dynamic > params = {
180180 'text' : text,
181- 'size' : size,
182- 'margin' : margin,
183- 'download' : download,
181+ if (size != null ) 'size' : size,
182+ if (margin != null ) 'margin' : margin,
183+ if (download != null ) 'download' : download,
184+ 'project' : client.config['project' ],
185+ };
186+
187+ final res = await client.call (HttpMethod .get ,
188+ path: apiPath, params: params, responseType: ResponseType .bytes);
189+ return res.data;
190+ }
191+
192+ /// Use this endpoint to capture a screenshot of any website URL. This endpoint
193+ /// uses a headless browser to render the webpage and capture it as an image.
194+ ///
195+ /// You can configure the browser viewport size, theme, user agent,
196+ /// geolocation, permissions, and more. Capture either just the viewport or the
197+ /// full page scroll.
198+ ///
199+ /// When width and height are specified, the image is resized accordingly. If
200+ /// both dimensions are 0, the API provides an image at original size. If
201+ /// dimensions are not specified, the default viewport size is 1280x720px.
202+ Future <Uint8List > getScreenshot (
203+ {required String url,
204+ Map ? headers,
205+ int ? viewportWidth,
206+ int ? viewportHeight,
207+ double ? scale,
208+ enums.Theme ? theme,
209+ String ? userAgent,
210+ bool ? fullpage,
211+ String ? locale,
212+ enums.Timezone ? timezone,
213+ double ? latitude,
214+ double ? longitude,
215+ double ? accuracy,
216+ bool ? touch,
217+ List <String >? permissions,
218+ int ? sleep,
219+ int ? width,
220+ int ? height,
221+ int ? quality,
222+ enums.Output ? output}) async {
223+ const String apiPath = '/avatars/screenshots' ;
224+
225+ final Map <String , dynamic > params = {
226+ 'url' : url,
227+ if (headers != null ) 'headers' : headers,
228+ if (viewportWidth != null ) 'viewportWidth' : viewportWidth,
229+ if (viewportHeight != null ) 'viewportHeight' : viewportHeight,
230+ if (scale != null ) 'scale' : scale,
231+ if (theme != null ) 'theme' : theme! .value,
232+ if (userAgent != null ) 'userAgent' : userAgent,
233+ if (fullpage != null ) 'fullpage' : fullpage,
234+ if (locale != null ) 'locale' : locale,
235+ if (timezone != null ) 'timezone' : timezone! .value,
236+ if (latitude != null ) 'latitude' : latitude,
237+ if (longitude != null ) 'longitude' : longitude,
238+ if (accuracy != null ) 'accuracy' : accuracy,
239+ if (touch != null ) 'touch' : touch,
240+ if (permissions != null ) 'permissions' : permissions,
241+ if (sleep != null ) 'sleep' : sleep,
242+ if (width != null ) 'width' : width,
243+ if (height != null ) 'height' : height,
244+ if (quality != null ) 'quality' : quality,
245+ if (output != null ) 'output' : output! .value,
184246 'project' : client.config['project' ],
185247 };
186248
0 commit comments