forked from duarten/appsync-mapping-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.ts
28 lines (24 loc) · 820 Bytes
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { RequestTemplate, ResponseTemplate } from "./request-response-template"
import { MappingTemplateVersion } from "./mapping-template"
export class Api {
private static globalVersion = MappingTemplateVersion.V1
public static setGlobalVersion(v: MappingTemplateVersion): void {
this.globalVersion = v
}
public static requestTemplate(
f: (r: RequestTemplate) => void,
v: MappingTemplateVersion = Api.globalVersion,
): string {
const r = new RequestTemplate(v)
f(r)
return r.renderTemplate(0)
}
public static responseTemplate(
f: (r: ResponseTemplate) => void,
v: MappingTemplateVersion = Api.globalVersion,
): string {
const r = new ResponseTemplate(v)
f(r)
return r.renderTemplate(0)
}
}