import { Delete, Get, Post, } from '../../src/fetcheasy/decorators/method-decorators'; import { Form, HeaderParam, Json, PathParam, QueryParam, } from '../../src/fetcheasy/decorators/param-decorators'; import { FetcheasyApiFactory } from '../../src/fetcheasy/fetcheasy-factory'; import { MediaType } from '../../src/http/http-media-type'; export const API_KEY = Symbol('API_KEY'); export class RestTestClient { @Get({ path: '/api/:id', consumes: MediaType.APPLICATION_JSON, paramsSet: API_KEY, }) async get(@PathParam('id') id: string): Promise { return undefined as any; } @Post({ path: '/api', consumes: MediaType.APPLICATION_JSON, }) async add(@Json() jsonData: object): Promise { return undefined as any; } @Delete('/api/:id') async delete(@PathParam('id') id: string): Promise { return undefined as any; } @Post('/api/json/:id/:scope') async postJson( @HeaderParam('x-custom') customHeader: string, @PathParam('id') id: string, @PathParam('scope') scope: string, @QueryParam('foo') foo: string, @Json() jsonData: object, ): Promise { return undefined as any; } @Post('/api/form/:id/:scope') async postForm( @HeaderParam('x-custom') customHeader: string, @PathParam('id') id: string, @PathParam('scope') scope: string, @QueryParam('foo') foo: string, @Form() form: FormData, ): Promise { return undefined as any; } } export const testClient = FetcheasyApiFactory.builder() .baseUrl('http://host') .paramsSets([ { key: API_KEY, query: { key: 'api-key', }, header: { 'X-Version': '2.0', }, }, ]) //.requestChain(new MiddlewareChain(fetchMock.sandbox())) .basicAuthentication('test', 'test') .build(RestTestClient);