/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { CancelToken } from 'axios'; import { ApiService } from './api.interface'; import { HttpCancellationToken, HttpDelete, HttpGet, HttpPatch, HttpPost, HttpPut, HttpSettings, Response } from '../models'; export class TestHttpService implements ApiService { response?: Response = undefined; error?: any = undefined; constructor(config: { response?: Response; error?: any }) { Object.assign(this, config); } get(method: HttpGet, settings?: HttpSettings): Promise> { return this.resolveTestCall(); } post(method: HttpPost, settings?: HttpSettings): Promise> { return this.resolveTestCall(); } delete(method: HttpDelete, settings?: HttpSettings): Promise> { return this.resolveTestCall(); } patch(method: HttpPatch, settings?: HttpSettings): Promise> { return this.resolveTestCall(); } put(method: HttpPut, settings?: HttpSettings): Promise> { return this.resolveTestCall(); } createCancellationToken(): HttpCancellationToken { return { cancel: () => {}, token: { promise: new Promise(() => {}), reason: undefined, throwIfRequested: () => {} } }; } private resolveTestCall(): Promise> { const promise = new Promise>((resolve, reject) => { if (this.response) { resolve(this.response); } if (this.error) { reject(this.error); } throw Error(`Test data are not provided.`); }); return promise; } }