template
This commit is contained in:
parent
8037489503
commit
ad189b8568
15 changed files with 1989 additions and 4 deletions
|
|
@ -1335,3 +1335,90 @@ export const whatsappApi = {
|
|||
body: JSON.stringify(payload),
|
||||
}),
|
||||
}
|
||||
|
||||
export type WaTemplateDraft = {
|
||||
account_id: string
|
||||
phone_number_id: string
|
||||
name: string
|
||||
language: string
|
||||
category: 'MARKETING' | 'UTILITY' | 'AUTHENTICATION' | ''
|
||||
subtype: string
|
||||
parameter_format: 'POSITIONAL' | 'NAMED'
|
||||
header: {
|
||||
type: 'NONE' | 'TEXT' | 'IMAGE' | 'VIDEO' | 'DOCUMENT' | 'LOCATION'
|
||||
text: string
|
||||
examples: string[]
|
||||
handle: string
|
||||
preview_name: string
|
||||
preview_url: string
|
||||
}
|
||||
body: string
|
||||
body_examples: string[]
|
||||
footer: string
|
||||
buttons: {
|
||||
type: 'URL' | 'PHONE_NUMBER' | 'QUICK_REPLY' | 'COPY_CODE' | 'CATALOG' | 'FLOW'
|
||||
text: string
|
||||
url: string
|
||||
phone: string
|
||||
example: string
|
||||
flow_id: string
|
||||
screen: string
|
||||
}[]
|
||||
auth: {
|
||||
otp_type: 'COPY_CODE'
|
||||
add_security_recommendation: boolean
|
||||
code_expiration_minutes: number
|
||||
copy_label: string
|
||||
}
|
||||
}
|
||||
|
||||
export type WaManagedTemplate = {
|
||||
id: string
|
||||
account_id: string
|
||||
account_name: string
|
||||
waba_name: string
|
||||
phone_number_id: string | null
|
||||
display_phone: string
|
||||
meta_template_id: string | null
|
||||
name: string
|
||||
language: string
|
||||
category: string
|
||||
subtype: string
|
||||
status: string
|
||||
quality: string | null
|
||||
rejected_reason: string | null
|
||||
parameter_format: string
|
||||
definition: Partial<WaTemplateDraft>
|
||||
components: unknown[]
|
||||
messages_sent: number
|
||||
messages_sent_source: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
analytics?: {
|
||||
source: string
|
||||
note: string
|
||||
sent: number
|
||||
by_status: Record<string, number>
|
||||
}
|
||||
}
|
||||
|
||||
export const waTemplateApi = {
|
||||
languages: () => jsonRequest<{ code: string; label: string }[]>('/api/v1/whatsapp/message-templates/languages'),
|
||||
list: (accountId?: string) =>
|
||||
jsonRequest<{ templates: WaManagedTemplate[]; summary: { total: number; approved: number; pending: number; rejected: number; paused: number }; warnings: string[] }>(
|
||||
`/api/v1/whatsapp/message-templates${accountId ? `?account_id=${accountId}` : ''}`,
|
||||
),
|
||||
get: (templateId: string) => jsonRequest<WaManagedTemplate>(`/api/v1/whatsapp/message-templates/${templateId}`),
|
||||
create: (payload: WaTemplateDraft) =>
|
||||
jsonRequest<WaManagedTemplate>('/api/v1/whatsapp/message-templates', { method: 'POST', body: JSON.stringify(payload) }),
|
||||
resubmit: (templateId: string, payload: WaTemplateDraft) =>
|
||||
jsonRequest<WaManagedTemplate>(`/api/v1/whatsapp/message-templates/${templateId}/resubmit`, { method: 'POST', body: JSON.stringify(payload) }),
|
||||
remove: (templateId: string) =>
|
||||
jsonRequest<{ status: string }>(`/api/v1/whatsapp/message-templates/${templateId}`, { method: 'DELETE' }),
|
||||
uploadHeader: (accountId: string, file: File) => {
|
||||
const body = new FormData()
|
||||
body.append('account_id', accountId)
|
||||
body.append('file', file)
|
||||
return jsonRequest<{ handle: string; format: string }>('/api/v1/whatsapp/message-templates/media', { method: 'POST', body })
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue