Class: Appwrite::Avatars
- Defined in:
- lib/appwrite/services/avatars.rb
Instance Method Summary collapse
-
#get_browser(code:, width: nil, height: nil, quality: nil) ⇒ Object
You can use this endpoint to show different browser icons to your users.
-
#get_credit_card(code:, width: nil, height: nil, quality: nil) ⇒ Object
The credit card endpoint will return you the icon of the credit card provider you need.
-
#get_favicon(url:) ⇒ Object
Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.
-
#get_flag(code:, width: nil, height: nil, quality: nil) ⇒ Object
You can use this endpoint to show different country flags icons to your users.
-
#get_image(url:, width: nil, height: nil) ⇒ Object
Use this endpoint to fetch a remote image URL and crop it to any image size you want.
-
#get_initials(name: nil, width: nil, height: nil, background: nil) ⇒ Object
Use this endpoint to show your user initials avatar icon on your website or app.
-
#get_qr(text:, size: nil, margin: nil, download: nil) ⇒ Object
Converts a given plain text to a QR code image.
-
#get_screenshot(url:, headers: nil, viewport_width: nil, viewport_height: nil, scale: nil, theme: nil, user_agent: nil, fullpage: nil, locale: nil, timezone: nil, latitude: nil, longitude: nil, accuracy: nil, touch: nil, permissions: nil, sleep: nil, width: nil, height: nil, quality: nil, output: nil) ⇒ Object
Use this endpoint to capture a screenshot of any website URL.
-
#initialize(client) ⇒ Avatars
constructor
A new instance of Avatars.
Constructor Details
#initialize(client) ⇒ Avatars
Returns a new instance of Avatars.
6 7 8 |
# File 'lib/appwrite/services/avatars.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#get_browser(code:, width: nil, height: nil, quality: nil) ⇒ Object
You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings.
When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/appwrite/services/avatars.rb', line 27 def get_browser(code:, width: nil, height: nil, quality: nil) api_path = '/avatars/browsers/{code}' .gsub('{code}', code) if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end api_params = { width: width, height: height, quality: quality, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |
#get_credit_card(code:, width: nil, height: nil, quality: nil) ⇒ Object
The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings.
When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/appwrite/services/avatars.rb', line 68 def get_credit_card(code:, width: nil, height: nil, quality: nil) api_path = '/avatars/credit-cards/{code}' .gsub('{code}', code) if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end api_params = { width: width, height: height, quality: quality, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |
#get_favicon(url:) ⇒ Object
Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.
This endpoint does not follow HTTP redirects.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/appwrite/services/avatars.rb', line 101 def get_favicon(url:) api_path = '/avatars/favicon' if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end api_params = { url: url, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |
#get_flag(code:, width: nil, height: nil, quality: nil) ⇒ Object
You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](en.wikipedia.org/wiki/ISO_3166-1) standard.
When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/appwrite/services/avatars.rb', line 140 def get_flag(code:, width: nil, height: nil, quality: nil) api_path = '/avatars/flags/{code}' .gsub('{code}', code) if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end api_params = { width: width, height: height, quality: quality, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |
#get_image(url:, width: nil, height: nil) ⇒ Object
Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol.
When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px.
This endpoint does not follow HTTP redirects.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/appwrite/services/avatars.rb', line 182 def get_image(url:, width: nil, height: nil) api_path = '/avatars/image' if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end api_params = { url: url, width: width, height: height, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |
#get_initials(name: nil, width: nil, height: nil, background: nil) ⇒ Object
Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the ‘name’ parameter. If no name is given and no user is logged, an empty avatar will be returned.
You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user’s initials when reloading the same theme will always return for the same initials.
When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/appwrite/services/avatars.rb', line 229 def get_initials(name: nil, width: nil, height: nil, background: nil) api_path = '/avatars/initials' api_params = { name: name, width: width, height: height, background: background, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |
#get_qr(text:, size: nil, margin: nil, download: nil) ⇒ Object
Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/appwrite/services/avatars.rb', line 260 def get_qr(text:, size: nil, margin: nil, download: nil) api_path = '/avatars/qr' if text.nil? raise Appwrite::Exception.new('Missing required parameter: "text"') end api_params = { text: text, size: size, margin: margin, download: download, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |
#get_screenshot(url:, headers: nil, viewport_width: nil, viewport_height: nil, scale: nil, theme: nil, user_agent: nil, fullpage: nil, locale: nil, timezone: nil, latitude: nil, longitude: nil, accuracy: nil, touch: nil, permissions: nil, sleep: nil, width: nil, height: nil, quality: nil, output: nil) ⇒ Object
Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image.
You can configure the browser viewport size, theme, user agent, geolocation, permissions, and more. Capture either just the viewport or the full page scroll.
When width and height are specified, the image is resized accordingly. If both dimensions are 0, the API provides an image at original size. If dimensions are not specified, the default viewport size is 1280x720px.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/appwrite/services/avatars.rb', line 318 def get_screenshot(url:, headers: nil, viewport_width: nil, viewport_height: nil, scale: nil, theme: nil, user_agent: nil, fullpage: nil, locale: nil, timezone: nil, latitude: nil, longitude: nil, accuracy: nil, touch: nil, permissions: nil, sleep: nil, width: nil, height: nil, quality: nil, output: nil) api_path = '/avatars/screenshots' if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end api_params = { url: url, headers: headers, viewportWidth: , viewportHeight: , scale: scale, theme: theme, userAgent: user_agent, fullpage: fullpage, locale: locale, timezone: timezone, latitude: latitude, longitude: longitude, accuracy: accuracy, touch: touch, permissions: , sleep: sleep, width: width, height: height, quality: quality, output: output, } api_headers = { } @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, ) end |