From 843222566673e405f9196fe54a48ce9d047a8459 Mon Sep 17 00:00:00 2001 From: Benji Stein Date: Wed, 31 Jan 2018 16:16:40 -0800 Subject: [PATCH 1/4] Make track_{clicks,opens} be *bools to allow overriding false defaults. --- mandrill.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mandrill.go b/mandrill.go index 6845bcb..97d413b 100644 --- a/mandrill.go +++ b/mandrill.go @@ -81,9 +81,9 @@ type Message struct { // whether or not this message is important, and should be delivered ahead of non-important messages Important bool `json:"important,omitempty"` // whether or not to turn on open tracking for the message - TrackOpens bool `json:"track_opens,omitempty"` + TrackOpens *bool `json:"track_opens,omitempty"` // whether or not to turn on click tracking for the message - TrackClicks bool `json:"track_clicks,omitempty"` + TrackClicks *bool `json:"track_clicks,omitempty"` // whether or not to automatically generate a text part for messages that are not given text AutoText bool `json:"auto_text,omitempty"` // whether or not to automatically generate an HTML part for messages that are not given HTML From f72a342c709bf7bfc702998174b22ea5b03b7821 Mon Sep 17 00:00:00 2001 From: Sayan Samanta Date: Mon, 3 Dec 2018 17:18:39 -0800 Subject: [PATCH 2/4] implement additional error checking in sendApiRequest --- mandrill.go | 12 +++++++++++- mandrill_test.go | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mandrill.go b/mandrill.go index 97d413b..3e0cd46 100644 --- a/mandrill.go +++ b/mandrill.go @@ -48,6 +48,7 @@ import ( "bytes" "encoding/json" "errors" + "fmt" "io/ioutil" "net/http" ) @@ -305,6 +306,7 @@ func (c *Client) sendMessagePayload(data interface{}, path string) (responses [] } func (c *Client) sendApiRequest(data interface{}, path string) (body []byte, err error) { + var emptyErr Error payload, _ := json.Marshal(data) resp, err := c.HTTPClient.Post(c.BaseURL+path, "application/json", bytes.NewReader(payload)) @@ -320,7 +322,15 @@ func (c *Client) sendApiRequest(data interface{}, path string) (body []byte, err if resp.StatusCode >= 400 { resError := &Error{} - err = json.Unmarshal(body, resError) + if err := json.Unmarshal(body, resError); err != nil { + return body, err + } + + // if we don't receive a meaningful message from Mandrill, let's return the http status + if *resError == emptyErr { + return body, fmt.Errorf("received unexpected http response from mandrill API: %s", resp.Status) + } + return body, resError } diff --git a/mandrill_test.go b/mandrill_test.go index 109b9f6..6f331cf 100644 --- a/mandrill_test.go +++ b/mandrill_test.go @@ -6,6 +6,7 @@ import ( "net/http/httptest" "net/url" "reflect" + "strings" "testing" ) @@ -82,6 +83,15 @@ func Test_MessagesSendTemplate_Fail(t *testing.T) { expect(t, reflect.DeepEqual(correctResponse, err), true) } +func Test_MessagesSendTemplate_Unexpected(t *testing.T) { + server, m := testTools(415, `{}`) + defer server.Close() + responses, err := m.MessagesSendTemplate(&Message{}, "cheese", map[string]string{"name": "bob"}) + + expect(t, len(responses), 0) + expect(t, strings.Contains(err.Error(), "415"), true) +} + // MessagesSend ////////// func Test_MessageSend_Success(t *testing.T) { From 5da34b0cd39ce591c7b9003255c1a588faf100b6 Mon Sep 17 00:00:00 2001 From: Ayo Ijidakinro Date: Sat, 19 Jul 2025 08:55:15 -0700 Subject: [PATCH 3/4] Adding template checkbox for new EWI-6 code review standards --- .github/PULL_REQUEST_TEMPLATE.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..349bdc3 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,18 @@ +## Clever Coding Standards Agreement + +- [ ] Author and Review Statement, "We agree this code adheres to our [Clever Global Coding Standards](https://app.getguru.com/folders/ibabX5oT/Engineering-Standards-Best-Practices?activeCard=a8a444f4-9149-4ec7-a0fd-8ba42519d93e) and other applicable [Coding Standards](https://app.getguru.com/folders/ibabX5oT/Engineering-Standards-Best-Practices)" + +## JIRA +[Link to JIRA](insert url here) + +## Overview +(insert PR description here) + +## Testing +(how did you test this) + +## Rollout +(are there any special rollout considerations? specific steps? risks?) + +## Rollback +(specific steps? risks?) \ No newline at end of file From 772c3642eaba020535bd87f6a6a025140dfd377d Mon Sep 17 00:00:00 2001 From: Tanmay Sardesai Date: Tue, 2 Dec 2025 16:33:34 -0800 Subject: [PATCH 4/4] add catalog-info.yaml (#3) --- catalog-info.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 catalog-info.yaml diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000..5dbaa70 --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,11 @@ +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: mandrill + description: Simple package for sending emails through the Mandrill API. + owner: unknown +spec: + type: unknown + lifecycle: production + owner: unknown + system: Clever