| 3 | import { ApiClient } from 'proton-drive-sdk-account'; |
| 4 | |
| 5 | export class HTTPClient { |
| 6 | constructor(private readonly apiClient: ApiClient) {} |
| 7 | |
| 8 | async fetchJson(options: ProtonDriveHTTPClientJsonRequest): Promise<Response> { |
| 9 | return this.apiClient.authenticatedRequest(options.url, { |
| 10 | method: options.method, |
| 11 | ...(options.json !== undefined ? { json: options.json } : {}), |
| 12 | ...(options.body !== undefined && options.json === undefined ? { body: options.body } : {}), |
| 13 | headers: options.headers, |
| 14 | timeout: options.timeoutMs, |
| 15 | signal: options.signal, |
| 16 | throwHttpErrors: false, |
| 17 | }); |
| 18 | } |
| 19 | |
| 20 | async fetchBlob(options: ProtonDriveHTTPClientBlobRequest): Promise<Response> { |
| 21 | return this.apiClient.authenticatedRequest(options.url, { |
| 22 | method: options.method, |
| 23 | body: options.body, |
| 24 | headers: options.headers, |
| 25 | timeout: options.timeoutMs, |
| 26 | signal: options.signal, |
| 27 | throwHttpErrors: false, |
| 28 | }); |
| 29 | } |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected