From 69a45d66e311821ebf1426323bf36eb47b6d3079 Mon Sep 17 00:00:00 2001 From: Nandan Date: Sun, 9 Feb 2020 22:09:44 +0100 Subject: [PATCH 1/2] Added support for campaigns/{campaign_id}/content endpoint --- campaigns.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/campaigns.go b/campaigns.go index 836fabc..2b131bc 100644 --- a/campaigns.go +++ b/campaigns.go @@ -8,6 +8,7 @@ import ( const ( campaigns_path = "/campaigns" single_campaign_path = campaigns_path + "/%s" + campaign_content_path = single_campaign_path + "/content" send_test_path = single_campaign_path + "/actions/test" send_path = single_campaign_path + "/actions/send" @@ -275,3 +276,44 @@ func (api API) SendCampaign(id string, body *SendCampaignRequest) (bool, error) } return true, nil } + + +// ------------------------------------------------------------------------------------------------ +// Campaign Content Updates +// ------------------------------------------------------------------------------------------------ + + +type CampaignContentTemplateRequest struct { + ID uint `json:"id,omitempty"` + Sections map[string]string `json:"sections,omitempty"` +} + +type CampaignContentUpdateRequest struct { + PlainText string `json:"plain_text"` + Html string `json:"html"` + Url string `json:"url"` + Template *CampaignContentTemplateRequest `json:"template,omitempty"` +} + +type CampaignContentResponse struct { + withLinks + + PlainText string `json:"plain_text"` + Html string `json:"html"` + ArchiveHtml string `json:"archive_html"` + api *API +} + +func (api API) GetCampaignContent(id string, params *BasicQueryParams) (*CampaignContentResponse, error) { + endpoint := fmt.Sprintf(campaign_content_path, id) + response := new(CampaignContentResponse) + response.api = &api + return response, api.Request("GET", endpoint, nil, params, response) +} + +func (api API) UpdateCampaignContent(id string, body *CampaignContentUpdateRequest) (*CampaignContentResponse, error) { + endpoint := fmt.Sprintf(campaign_content_path, id) + response := new(CampaignContentResponse) + response.api = &api + return response, api.Request("PUT", endpoint, nil, body, response) +} From b930336e8cd7d8fd38821775ef356d0737b89840 Mon Sep 17 00:00:00 2001 From: Nandan Date: Sun, 9 Feb 2020 22:10:44 +0100 Subject: [PATCH 2/2] Added support for templates/{template_id}/default-content endpoint --- templates.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates.go b/templates.go index e40b3ad..05fa205 100644 --- a/templates.go +++ b/templates.go @@ -8,6 +8,7 @@ import ( const ( templates_path = "/templates" single_template_path = templates_path + "/%s" + template_default_path = single_template_path + "/default-content" ) @@ -63,6 +64,14 @@ type TemplateCreationRequest struct { } +type TemplateDefaultContentResponse struct { + withLinks + + Sections map[string]string `json:"sections"` + + api *API +} + func (template TemplateResponse) CanMakeRequest() error { if template.ID == 0 { return errors.New("No ID provided on template") @@ -114,3 +123,10 @@ func (api API) DeleteTemplate(id string) (bool, error) { endpoint := fmt.Sprintf(single_template_path, id) return api.RequestOk("DELETE", endpoint) } + +func (api API) GetTemplateDefaultContent(id string, params *BasicQueryParams) (*TemplateDefaultContentResponse, error) { + endpoint := fmt.Sprintf(template_default_path, id) + response := new(TemplateDefaultContentResponse) + response.api = &api + return response, api.Request("GET", endpoint, params, nil, response) +}