Skip to content

Commit

Permalink
Send TMS message using MessagingServiceSid key as case sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Dec 18, 2017
1 parent 78536aa commit 3085eec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion handlers/twilio/twilio.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (h *handler) SendMsg(msg courier.Msg) (courier.MsgStatus, error) {
// set our from, either as a messaging service or from our address
serviceSID := msg.Channel().StringConfigForKey(configMessagingServiceSID, "")
if serviceSID != "" {
form["MessagingServiceSID"] = []string{serviceSID}
form["MessagingServiceSid"] = []string{serviceSID}
} else {
form["From"] = []string{msg.Channel().Address()}
}
Expand Down
14 changes: 7 additions & 7 deletions handlers/twilio/twilio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ var tmsDefaultSendTestCases = []ChannelSendTestCase{
Text: "Simple Message ☺", URN: "tel:+250788383383",
Status: "W", ExternalID: "1002",
ResponseBody: `{ "sid": "1002" }`, ResponseStatus: 200,
PostParams: map[string]string{"Body": "Simple Message ☺", "To": "+250788383383", "MessagingServiceSID": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
PostParams: map[string]string{"Body": "Simple Message ☺", "To": "+250788383383", "MessagingServiceSid": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
Path: "/Account/accountSID/Messages.json",
Headers: map[string]string{"Authorization": "Basic YWNjb3VudFNJRDphdXRoVG9rZW4="},
SendPrep: setSendURL},
Expand All @@ -197,40 +197,40 @@ var tmsDefaultSendTestCases = []ChannelSendTestCase{
URN: "tel:+250788383383",
Status: "W", ExternalID: "1002",
ResponseBody: `{ "sid": "1002" }`, ResponseStatus: 200,
PostParams: map[string]string{"Body": "I need to keep adding more things to make it work", "To": "+250788383383", "MessagingServiceSID": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
PostParams: map[string]string{"Body": "I need to keep adding more things to make it work", "To": "+250788383383", "MessagingServiceSid": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
Path: "/Account/accountSID/Messages.json",
Headers: map[string]string{"Authorization": "Basic YWNjb3VudFNJRDphdXRoVG9rZW4="},
SendPrep: setSendURL},
{Label: "Error Sending",
Text: "Error Message", URN: "tel:+250788383383",
Status: "E",
ResponseBody: `{ "error": "out of credits" }`, ResponseStatus: 401,
PostParams: map[string]string{"Body": "Error Message", "To": "+250788383383", "MessagingServiceSID": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
PostParams: map[string]string{"Body": "Error Message", "To": "+250788383383", "MessagingServiceSid": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
SendPrep: setSendURL},
{Label: "Error Code",
Text: "Error Code", URN: "tel:+250788383383",
Status: "E",
ResponseBody: `{ "code": 1001 }`, ResponseStatus: 200,
PostParams: map[string]string{"Body": "Error Code", "To": "+250788383383", "MessagingServiceSID": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
PostParams: map[string]string{"Body": "Error Code", "To": "+250788383383", "MessagingServiceSid": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
SendPrep: setSendURL},
{Label: "Stopped Contact Code",
Text: "Stopped Contact", URN: "tel:+250788383383",
Status: "F",
ResponseBody: `{ "code": 21610 }`, ResponseStatus: 400,
PostParams: map[string]string{"Body": "Stopped Contact", "To": "+250788383383", "MessagingServiceSID": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
PostParams: map[string]string{"Body": "Stopped Contact", "To": "+250788383383", "MessagingServiceSid": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
SendPrep: setSendURL,
Stopped: true},
{Label: "No SID",
Text: "No SID", URN: "tel:+250788383383",
Status: "E",
ResponseBody: `{ }`, ResponseStatus: 200,
PostParams: map[string]string{"Body": "No SID", "To": "+250788383383", "MessagingServiceSID": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
PostParams: map[string]string{"Body": "No SID", "To": "+250788383383", "MessagingServiceSid": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
SendPrep: setSendURL},
{Label: "Send Attachment",
Text: "My pic!", URN: "tel:+250788383383", Attachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
Status: "W",
ResponseBody: `{ "sid": "1002" }`, ResponseStatus: 200,
PostParams: map[string]string{"Body": "My pic!", "To": "+250788383383", "MediaUrl": "https://foo.bar/image.jpg", "MessagingServiceSID": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
PostParams: map[string]string{"Body": "My pic!", "To": "+250788383383", "MediaUrl": "https://foo.bar/image.jpg", "MessagingServiceSid": "messageServiceSID", "StatusCallback": "https://localhost/c/tms/8eb23e93-5ecb-45ba-b726-3b064e0c56cd/status?id=10&action=callback"},
SendPrep: setSendURL},
}

Expand Down

0 comments on commit 3085eec

Please sign in to comment.