From 9fa920aa227bb08ef3c326fd743eff147431b187 Mon Sep 17 00:00:00 2001 From: Mark Pitsilos Date: Wed, 4 Oct 2023 12:47:35 +0300 Subject: [PATCH] feat(templates): Implement toggle_delivery operation --- clerk/templates.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/clerk/templates.go b/clerk/templates.go index 05a01a36..d990d4ce 100644 --- a/clerk/templates.go +++ b/clerk/templates.go @@ -78,6 +78,10 @@ type PreviewTemplateRequest struct { FromEmailName *string `json:"from_email_name"` } +type ToggleDeliveryTemplateRequest struct { + DeliveredByClerk bool `json:"delivered_by_clerk"` +} + func (s *TemplatesService) Upsert(templateType, slug string, upsertTemplateRequest *UpsertTemplateRequest) (*TemplateExtended, error) { templateURL := fmt.Sprintf("%s/%s/%s", TemplatesUrl, templateType, slug) req, _ := s.client.NewRequest("PUT", templateURL, upsertTemplateRequest) @@ -134,3 +138,17 @@ func (s *TemplatesService) Preview(templateType, slug string, previewTemplateReq return &templatePreview, nil } + +func (s *TemplatesService) ToggleDelivery(templateType, slug string, toggleDeliveryTemplateRequest *ToggleDeliveryTemplateRequest) (*TemplateExtended, error) { + templateURL := fmt.Sprintf("%s/%s/%s/toggle_delivery", TemplatesUrl, templateType, slug) + req, _ := s.client.NewRequest("POST", templateURL, toggleDeliveryTemplateRequest) + + var toggledTemplate TemplateExtended + + _, err := s.client.Do(req, &toggledTemplate) + if err != nil { + return nil, err + } + + return &toggledTemplate, nil +}