@@ -24,9 +24,9 @@ class Avatars extends Service {
2424 '/avatars/browsers/{code}' .replaceAll ('{code}' , code.value);
2525
2626 final Map <String , dynamic > params = {
27- 'width' : width,
28- 'height' : height,
29- 'quality' : quality,
27+ if (width != null ) 'width' : width,
28+ if (height != null ) 'height' : height,
29+ if (quality != null ) 'quality' : quality,
3030 'project' : client.config['project' ],
3131 'session' : client.config['session' ],
3232 };
@@ -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 'session' : client.config['session' ],
6262 };
@@ -100,9 +100,9 @@ class Avatars extends Service {
100100 '/avatars/flags/{code}' .replaceAll ('{code}' , code.value);
101101
102102 final Map <String , dynamic > params = {
103- 'width' : width,
104- 'height' : height,
105- 'quality' : quality,
103+ if (width != null ) 'width' : width,
104+ if (height != null ) 'height' : height,
105+ if (quality != null ) 'quality' : quality,
106106 'project' : client.config['project' ],
107107 'session' : client.config['session' ],
108108 };
@@ -129,8 +129,8 @@ class Avatars extends Service {
129129
130130 final Map <String , dynamic > params = {
131131 'url' : url,
132- 'width' : width,
133- 'height' : height,
132+ if (width != null ) 'width' : width,
133+ if (height != null ) 'height' : height,
134134 'project' : client.config['project' ],
135135 'session' : client.config['session' ],
136136 };
@@ -161,10 +161,10 @@ class Avatars extends Service {
161161 final String apiPath = '/avatars/initials' ;
162162
163163 final Map <String , dynamic > params = {
164- 'name' : name,
165- 'width' : width,
166- 'height' : height,
167- 'background' : background,
164+ if (name != null ) 'name' : name,
165+ if (width != null ) 'width' : width,
166+ if (height != null ) 'height' : height,
167+ if (background != null ) 'background' : background,
168168 'project' : client.config['project' ],
169169 'session' : client.config['session' ],
170170 };
@@ -183,9 +183,72 @@ class Avatars extends Service {
183183
184184 final Map <String , dynamic > params = {
185185 'text' : text,
186- 'size' : size,
187- 'margin' : margin,
188- 'download' : download,
186+ if (size != null ) 'size' : size,
187+ if (margin != null ) 'margin' : margin,
188+ if (download != null ) 'download' : download,
189+ 'project' : client.config['project' ],
190+ 'session' : client.config['session' ],
191+ };
192+
193+ final res = await client.call (HttpMethod .get ,
194+ path: apiPath, params: params, responseType: ResponseType .bytes);
195+ return res.data;
196+ }
197+
198+ /// Use this endpoint to capture a screenshot of any website URL. This endpoint
199+ /// uses a headless browser to render the webpage and capture it as an image.
200+ ///
201+ /// You can configure the browser viewport size, theme, user agent,
202+ /// geolocation, permissions, and more. Capture either just the viewport or the
203+ /// full page scroll.
204+ ///
205+ /// When width and height are specified, the image is resized accordingly. If
206+ /// both dimensions are 0, the API provides an image at original size. If
207+ /// dimensions are not specified, the default viewport size is 1280x720px.
208+ Future <Uint8List > getScreenshot (
209+ {required String url,
210+ Map ? headers,
211+ int ? viewportWidth,
212+ int ? viewportHeight,
213+ double ? scale,
214+ enums.Theme ? theme,
215+ String ? userAgent,
216+ bool ? fullpage,
217+ String ? locale,
218+ enums.Timezone ? timezone,
219+ double ? latitude,
220+ double ? longitude,
221+ double ? accuracy,
222+ bool ? touch,
223+ List <String >? permissions,
224+ int ? sleep,
225+ int ? width,
226+ int ? height,
227+ int ? quality,
228+ enums.Output ? output}) async {
229+ final String apiPath = '/avatars/screenshots' ;
230+
231+ final Map <String , dynamic > params = {
232+ 'url' : url,
233+ if (headers != null ) 'headers' : headers,
234+ if (viewportWidth != null ) 'viewportWidth' : viewportWidth,
235+ if (viewportHeight != null ) 'viewportHeight' : viewportHeight,
236+ if (scale != null ) 'scale' : scale,
237+ if (theme != null ) 'theme' : theme! .value,
238+ if (userAgent != null ) 'userAgent' : userAgent,
239+ if (fullpage != null ) 'fullpage' : fullpage,
240+ if (locale != null ) 'locale' : locale,
241+ if (timezone != null ) 'timezone' : timezone! .value,
242+ if (latitude != null ) 'latitude' : latitude,
243+ if (longitude != null ) 'longitude' : longitude,
244+ if (accuracy != null ) 'accuracy' : accuracy,
245+ if (touch != null ) 'touch' : touch,
246+ if (permissions != null ) 'permissions' : permissions,
247+ if (sleep != null ) 'sleep' : sleep,
248+ if (width != null ) 'width' : width,
249+ if (height != null ) 'height' : height,
250+ if (quality != null ) 'quality' : quality,
251+ if (output != null ) 'output' : output! .value,
189252 'project' : client.config['project' ],
190253 'session' : client.config['session' ],
191254 };
0 commit comments