|
| 1 | +/** |
| 2 | + * LINKURIOUS CONFIDENTIAL |
| 3 | + * Copyright Linkurious SAS 2012 - 2025 |
| 4 | + * |
| 5 | + * - Created on 2025-11-27. |
| 6 | + */ |
| 7 | +import {Request} from '../../http/request'; |
| 8 | +import {LkErrorKey} from '../../http/response'; |
| 9 | + |
| 10 | +import { |
| 11 | + CreateImportTemplateParams, |
| 12 | + DeleteImportTemplateParams, |
| 13 | + GetImportTemplatesParams, |
| 14 | + ImportTemplate |
| 15 | +} from './types'; |
| 16 | + |
| 17 | +export * from './types'; |
| 18 | + |
| 19 | +const {UNAUTHORIZED, DATA_SOURCE_UNAVAILABLE, FORBIDDEN, NOT_FOUND} = LkErrorKey; |
| 20 | + |
| 21 | +export class ImportAPI extends Request { |
| 22 | + /** |
| 23 | + * Create a new import template. |
| 24 | + */ |
| 25 | + createImportTemplate(this: Request<ImportTemplate>, params: CreateImportTemplateParams) { |
| 26 | + return this.request({ |
| 27 | + errors: [UNAUTHORIZED, FORBIDDEN, DATA_SOURCE_UNAVAILABLE], |
| 28 | + url: '/:sourceKey/imports/templates', |
| 29 | + method: 'POST', |
| 30 | + params: params |
| 31 | + }); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Delete an existing import template. |
| 36 | + */ |
| 37 | + deleteImportTemplate(params: DeleteImportTemplateParams) { |
| 38 | + return this.request({ |
| 39 | + errors: [UNAUTHORIZED, FORBIDDEN, DATA_SOURCE_UNAVAILABLE, NOT_FOUND], |
| 40 | + url: '/:sourceKey/imports/templates/:id', |
| 41 | + method: 'DELETE', |
| 42 | + params: params |
| 43 | + }); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * List all the import templates (the publicly shared ones and the private ones owned by the user). |
| 48 | + */ |
| 49 | + getImportTemplates(this: Request<{items: ImportTemplate[]}>, params: GetImportTemplatesParams) { |
| 50 | + return this.request({ |
| 51 | + errors: [UNAUTHORIZED, FORBIDDEN, DATA_SOURCE_UNAVAILABLE], |
| 52 | + url: '/:sourceKey/imports/templates', |
| 53 | + method: 'GET', |
| 54 | + params: params |
| 55 | + }); |
| 56 | + } |
| 57 | +} |
0 commit comments