|
| 1 | +/** |
| 2 | + * RAP Generator Workspace Contract |
| 3 | + * |
| 4 | + * ADT endpoint: /sap/bc/adt/rap/generator |
| 5 | + * Content-Type: application/vnd.sap.adt.rap.generator.v1+xml |
| 6 | + * |
| 7 | + * Supports RAP generator operations for creating new RAP business objects |
| 8 | + * and managing the generator workspace. |
| 9 | + */ |
| 10 | + |
| 11 | +import { http } from '../../base'; |
| 12 | +import { adtcore } from '../../schemas'; |
| 13 | + |
| 14 | +const basePath = '/sap/bc/adt/rap/generator'; |
| 15 | +const contentType = 'application/vnd.sap.adt.rap.generator.v1+xml'; |
| 16 | +const accept = contentType; |
| 17 | + |
| 18 | +export const rapGeneratorContract = { |
| 19 | + getWorkspace: () => |
| 20 | + http.get(basePath, { |
| 21 | + responses: { 200: adtcore }, |
| 22 | + headers: { |
| 23 | + Accept: accept, |
| 24 | + }, |
| 25 | + }), |
| 26 | + |
| 27 | + create: (options?: { corrNr?: string }) => |
| 28 | + http.post(basePath, { |
| 29 | + responses: { 200: adtcore }, |
| 30 | + headers: { |
| 31 | + Accept: accept, |
| 32 | + 'Content-Type': contentType, |
| 33 | + }, |
| 34 | + query: options?.corrNr ? { corrNr: options.corrNr } : undefined, |
| 35 | + }), |
| 36 | + |
| 37 | + delete: (name: string) => |
| 38 | + http.delete(`${basePath}/${name.toLowerCase()}`, { |
| 39 | + responses: { 204: undefined }, |
| 40 | + }), |
| 41 | + |
| 42 | + getTemplate: (templateId: string) => |
| 43 | + http.get(`${basePath}/templates/${templateId}`, { |
| 44 | + responses: { 200: adtcore }, |
| 45 | + headers: { Accept: accept }, |
| 46 | + }), |
| 47 | + |
| 48 | + listTemplates: () => |
| 49 | + http.get(`${basePath}/templates`, { |
| 50 | + responses: { 200: adtcore }, |
| 51 | + headers: { Accept: accept }, |
| 52 | + }), |
| 53 | + |
| 54 | + generate: (templateId: string, options?: { corrNr?: string }) => |
| 55 | + http.post(`${basePath}/templates/${templateId}/generate`, { |
| 56 | + responses: { 200: adtcore }, |
| 57 | + headers: { |
| 58 | + Accept: accept, |
| 59 | + 'Content-Type': contentType, |
| 60 | + }, |
| 61 | + query: options?.corrNr ? { corrNr: options.corrNr } : undefined, |
| 62 | + }), |
| 63 | +}; |
| 64 | + |
| 65 | +export type RapGeneratorContract = typeof rapGeneratorContract; |
0 commit comments