Skip to content

Commit

Permalink
Merge pull request #39 from nandanrao/master
Browse files Browse the repository at this point in the history
Added: templates//default-content and campaigns//content
  • Loading branch information
zeekay authored Aug 4, 2020
2 parents 66d0126 + b930336 commit ac0caad
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
42 changes: 42 additions & 0 deletions campaigns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
16 changes: 16 additions & 0 deletions templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
const (
templates_path = "/templates"
single_template_path = templates_path + "/%s"
template_default_path = single_template_path + "/default-content"
)


Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}

0 comments on commit ac0caad

Please sign in to comment.