| 349 | */ |
| 350 | getImage(url: string, width?: number, height?: number): Promise<ArrayBuffer>; |
| 351 | getImage( |
| 352 | paramsOrFirst: { url: string, width?: number, height?: number } | string, |
| 353 | ...rest: [(number)?, (number)?] |
| 354 | ): Promise<ArrayBuffer> { |
| 355 | let params: { url: string, width?: number, height?: number }; |
| 356 | |
| 357 | if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { |
| 358 | params = (paramsOrFirst || {}) as { url: string, width?: number, height?: number }; |
| 359 | } else { |
| 360 | params = { |
| 361 | url: paramsOrFirst as string, |
| 362 | width: rest[0] as number, |
| 363 | height: rest[1] as number |
| 364 | }; |
| 365 | } |
| 366 | |
| 367 | const url = params.url; |
| 368 | const width = params.width; |
| 369 | const height = params.height; |
| 370 | |
| 371 | if (typeof url === 'undefined') { |
| 372 | throw new AppwriteException('Missing required parameter: "url"'); |
| 373 | } |
| 374 | |
| 375 | const apiPath = '/avatars/image'; |
| 376 | const payload: Payload = {}; |
| 377 | |
| 378 | if (typeof url !== 'undefined') { |
| 379 | payload['url'] = url; |
| 380 | } |
| 381 | |
| 382 | if (typeof width !== 'undefined') { |
| 383 | payload['width'] = width; |
| 384 | } |
| 385 | |
| 386 | if (typeof height !== 'undefined') { |
| 387 | payload['height'] = height; |
| 388 | } |
| 389 | |
| 390 | const uri = new URL(this.client.config.endpoint + apiPath); |
| 391 | payload['project'] = this.client.config.project; |
| 392 | |
| 393 | |
| 394 | for (const [key, value] of Object.entries(Service.flatten(payload))) { |
| 395 | uri.searchParams.append(key, value); |
| 396 | } |
| 397 | return this.client.call('get', uri, { |
| 398 | }, payload, 'arrayBuffer'); |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * 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. |