Skip to content

Commit

Permalink
feat(templates): Implement toggle_delivery operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Pitsilos authored and yourtallness committed Oct 5, 2023
1 parent 122a177 commit 9fa920a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clerk/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit 9fa920a

Please sign in to comment.