Skip to content

Commit

Permalink
Merge branch 'release/v0.0.1'
Browse files Browse the repository at this point in the history
send sms.
  • Loading branch information
jimmy-go committed Aug 25, 2016
2 parents cd9f476 + e3dcb52 commit e1b5dcf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
####Nexmo client for Go.

For now you can send sms only. Not tested with credentials.

[![License MIT](https://img.shields.io/npm/l/express.svg)](http://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.org/jimmy-go/nexmo.svg?branch=master)](https://travis-ci.org/jimmy-go/nexmo)
[![Go Report Card](https://goreportcard.com/badge/github.com/jimmy-go/nexmo)](https://goreportcard.com/report/github.com/jimmy-go/nexmo)
Expand Down
2 changes: 1 addition & 1 deletion nexmo.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (x *Nexmo) SMS(r *Request) (*Response, error) {
v.Add("to", r.To)
v.Add("from", r.From)
v.Add("text", strings.Replace(r.Text, " ", "+", -1))
req, err := http.NewRequest(http.MethodGet, restEndpoint, bytes.NewBufferString(v.Encode()))
req, err := http.NewRequest("GET", restEndpoint, bytes.NewBufferString(v.Encode()))
if err != nil {
return res, err
}
Expand Down
14 changes: 11 additions & 3 deletions nexmo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@ import (
)

func TestSMS(t *testing.T) {
nex, err := New("123", "123", time.Second)
nmo, err := New("123", "123", time.Second)
if err != nil {
t.Logf("new : err [%s]", err)
t.Fail()
return
}
res, err := nex.BasicSMS("5215522334455", "nexmotest", "Hi nexmo test")

res, err := nmo.BasicSMS("5215522334455", "nexmotest", "Hi nexmo test")
// we can take this as a natural error in tests. FIXME;
if err == ErrInvalidRequest {
t.Logf("basicSMS : expected error : err [%s]", err)
return
}
if err != nil {
t.Logf("basicSMS : err [%s]", err)
t.Fail()
}
if res == nil {
t.Logf("basicSMS : res nil")
return
}
if len(res.Messages) < 1 {
Expand Down

0 comments on commit e1b5dcf

Please sign in to comment.