Type template endpoints
This commit is contained in:
parent
ef28b033ac
commit
edbcc1f764
|
@ -1,4 +1,18 @@
|
|||
export const buildTemplateEndpoints = API => ({
|
||||
import { Template } from "@budibase/types"
|
||||
import { BaseAPIClient } from "./types"
|
||||
|
||||
export interface TemplateEndpoints {
|
||||
getEmailTemplates: () => Promise<Template[]>
|
||||
|
||||
// Missing request or response types
|
||||
getEmailTemplateDefinitions: () => Promise<any>
|
||||
saveEmailTemplate: (templaet: any) => Promise<any>
|
||||
getAppTemplates: () => Promise<any>
|
||||
}
|
||||
|
||||
export const buildTemplateEndpoints = (
|
||||
API: BaseAPIClient
|
||||
): TemplateEndpoints => ({
|
||||
/**
|
||||
* Gets the list of email template definitions.
|
||||
*/
|
||||
|
@ -10,7 +24,10 @@ export const buildTemplateEndpoints = API => ({
|
|||
* Gets the list of email templates.
|
||||
*/
|
||||
getEmailTemplates: async () => {
|
||||
return await API.get({ url: "/api/global/template/email" })
|
||||
const res = await API.get<Template | Template[]>({
|
||||
url: "/api/global/template/email",
|
||||
})
|
||||
return Array.isArray(res) ? res : [res]
|
||||
},
|
||||
|
||||
/**
|
|
@ -28,6 +28,7 @@ import { RowEndpoints } from "./rows"
|
|||
import { ScreenEndpoints } from "./screens"
|
||||
import { SelfEndpoints } from "./self"
|
||||
import { TableEndpoints } from "./tables"
|
||||
import { TemplateEndpoints } from "./templates"
|
||||
|
||||
export enum HTTPMethod {
|
||||
POST = "POST",
|
||||
|
@ -126,4 +127,5 @@ export type APIClient = BaseAPIClient &
|
|||
RowEndpoints &
|
||||
ScreenEndpoints &
|
||||
SelfEndpoints &
|
||||
TableEndpoints & { rowActions: RowActionEndpoints; [key: string]: any }
|
||||
TableEndpoints &
|
||||
TemplateEndpoints & { rowActions: RowActionEndpoints; [key: string]: any }
|
||||
|
|
Loading…
Reference in New Issue