Skip to content

Commit

Permalink
Merge 3688c63 into a74bed7
Browse files Browse the repository at this point in the history
  • Loading branch information
marian-craciunescu committed Mar 21, 2017
2 parents a74bed7 + 3688c63 commit 2a7532a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions server/sms/nexmo_sms.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type NexmoSms struct {
To string `json:"to"`
From string `json:"from"`
Text string `json:"text"`
ClientRef string `json:"client-ref"`
}

func (sms *NexmoSms) EncodeNexmoSms(apiKey, apiSecret string) ([]byte, error) {
Expand Down
4 changes: 2 additions & 2 deletions server/sms/nexmo_sms_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (r *retryable) executeAndCheck(op func() (*NexmoMessageResponse, error)) er
}

func (ns *NexmoSender) sendSms(sms *NexmoSms) (*NexmoMessageResponse, error) {
logger.WithField("sms_details", sms).Info("sendSms")
logger.WithField("sms_details", sms).WithField("order_id", sms.ClientRef).Info("sendSms")

smsEncoded, err := sms.EncodeNexmoSms(ns.ApiKey, ns.ApiSecret)
if err != nil {
Expand Down Expand Up @@ -231,7 +231,7 @@ func (ns *NexmoSender) sendSms(sms *NexmoSms) (*NexmoMessageResponse, error) {
pNexmoResponseInternalErrors.Inc()
return nil, ErrSMSResponseDecodingFailed
}
logger.WithField("messageResponse", messageResponse).Info("Actual nexmo response")
logger.WithField("messageResponse", messageResponse).WithField("order_id", sms.ClientRef).Info("Actual nexmo response")

return messageResponse, nil
}
Expand Down
9 changes: 5 additions & 4 deletions server/sms/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func composeNexmoMessageResponse(sms NexmoSms, code ResponseCode, messageCount i
Status: code,
MessageID: "msgID",
To: sms.To,
ClientReference: "",
ClientReference: "ref",
RemainingBalance: "2",
MessagePrice: "0.005",
Network: "TELEKOM",
Expand Down Expand Up @@ -85,9 +85,10 @@ func createKVStore(t *testing.T, filename string) (kvstore.KVStore, string) {
func encodeProtocolMessage(t *testing.T, ID int) protocol.Message {
a := assert.New(t)
sms := NexmoSms{
To: "toNumber",
From: fmt.Sprintf("%d", ID),
Text: "body",
To: "toNumber",
From: fmt.Sprintf("%d", ID),
Text: "body",
ClientRef: "ref",
}
d, err := json.Marshal(&sms)
if err != nil {
Expand Down

0 comments on commit 2a7532a

Please sign in to comment.