@@ -311,5 +311,99 @@ open class Avatars: Service {
311311 )
312312 }
313313
314+ ///
315+ /// Use this endpoint to capture a screenshot of any website URL. This endpoint
316+ /// uses a headless browser to render the webpage and capture it as an image.
317+ ///
318+ /// You can configure the browser viewport size, theme, user agent,
319+ /// geolocation, permissions, and more. Capture either just the viewport or the
320+ /// full page scroll.
321+ ///
322+ /// When width and height are specified, the image is resized accordingly. If
323+ /// both dimensions are 0, the API provides an image at original size. If
324+ /// dimensions are not specified, the default viewport size is 1280x720px.
325+ ///
326+ /// - Parameters:
327+ /// - url: String
328+ /// - headers: Any (optional)
329+ /// - viewportWidth: Int (optional)
330+ /// - viewportHeight: Int (optional)
331+ /// - scale: Double (optional)
332+ /// - theme: AppwriteEnums.Theme (optional)
333+ /// - userAgent: String (optional)
334+ /// - fullpage: Bool (optional)
335+ /// - locale: String (optional)
336+ /// - timezone: AppwriteEnums.Timezone (optional)
337+ /// - latitude: Double (optional)
338+ /// - longitude: Double (optional)
339+ /// - accuracy: Double (optional)
340+ /// - touch: Bool (optional)
341+ /// - permissions: [String] (optional)
342+ /// - sleep: Int (optional)
343+ /// - width: Int (optional)
344+ /// - height: Int (optional)
345+ /// - quality: Int (optional)
346+ /// - output: AppwriteEnums.Output (optional)
347+ /// - Throws: Exception if the request fails
348+ /// - Returns: ByteBuffer
349+ ///
350+ open func getScreenshot(
351+ url: String ,
352+ headers: Any ? = nil ,
353+ viewportWidth: Int ? = nil ,
354+ viewportHeight: Int ? = nil ,
355+ scale: Double ? = nil ,
356+ theme: AppwriteEnums . Theme ? = nil ,
357+ userAgent: String ? = nil ,
358+ fullpage: Bool ? = nil ,
359+ locale: String ? = nil ,
360+ timezone: AppwriteEnums . Timezone ? = nil ,
361+ latitude: Double ? = nil ,
362+ longitude: Double ? = nil ,
363+ accuracy: Double ? = nil ,
364+ touch: Bool ? = nil ,
365+ permissions: [ String ] ? = nil ,
366+ sleep: Int ? = nil ,
367+ width: Int ? = nil ,
368+ height: Int ? = nil ,
369+ quality: Int ? = nil ,
370+ output: AppwriteEnums . Output ? = nil
371+ ) async throws -> ByteBuffer {
372+ let apiPath : String = " /avatars/screenshots "
373+
374+ let apiParams : [ String : Any ? ] = [
375+ " url " : url,
376+ " headers " : headers,
377+ " viewportWidth " : viewportWidth,
378+ " viewportHeight " : viewportHeight,
379+ " scale " : scale,
380+ " theme " : theme,
381+ " userAgent " : userAgent,
382+ " fullpage " : fullpage,
383+ " locale " : locale,
384+ " timezone " : timezone,
385+ " latitude " : latitude,
386+ " longitude " : longitude,
387+ " accuracy " : accuracy,
388+ " touch " : touch,
389+ " permissions " : permissions,
390+ " sleep " : sleep,
391+ " width " : width,
392+ " height " : height,
393+ " quality " : quality,
394+ " output " : output,
395+ " project " : client. config [ " project " ] ,
396+ " session " : client. config [ " session " ]
397+ ]
398+
399+ let apiHeaders : [ String : String ] = [ : ]
400+
401+ return try await client. call (
402+ method: " GET " ,
403+ path: apiPath,
404+ params: apiParams
405+ )
406+ }
407+
314408
315409}
0 commit comments