Skip to content

Commit

Permalink
Adding missing field in SMS API (#119)
Browse files Browse the repository at this point in the history
* changed testdata messageObjectWithCreatedDatetime -> messageObjectWithScheduledDatetime

* added missing fields

* tests updated & added TestRead

* update testdata

* go version up

* add read tests

* add tests for Delete method

* replace deprecated DialTLS with DialTLSContext

* improve error_test

* add GroupIds to messageRequest

* add GroupIds to request and tests

* remove bool in result of sms.Delete

* update version to 8

* update client version
  • Loading branch information
vallerion authored Jun 24, 2022
1 parent c3c2f72 commit 88ad799
Show file tree
Hide file tree
Showing 59 changed files with 375 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: true
matrix:
go-version: [ 1.16.x, 1.17.x, 1.18.x]
go-version: [ 1.16.x, 1.17.x, 1.18.x ]

name: Go ${{ matrix.go-version }}

Expand Down
5 changes: 5 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,8 @@ So all imports of `go-rest-api` are replaced as `go-rest-api/v6`.
## `v6.1.0` -> `v7.0.0`
### Verify Recipient type
As v7 introduces support for using the Verify API with email recipients, the `Verify.Recipient` field has been changed from to a string type.

## `v7.1.0` -> `v8.0.0`
### Update SMS API
Added [missed fields](https://github.com/messagebird/go-rest-api/pull/119/commits/f9331269238f1518dd35d798a0fbf251bb04bb62) in SMS API.
Updated `sms.Delete` method so now in return only error or nil as result.
2 changes: 1 addition & 1 deletion balance/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package balance
import (
"net/http"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

// Balance describes your balance information.
Expand Down
4 changes: 2 additions & 2 deletions balance/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"net/http"
"testing"

messagebird "github.com/messagebird/go-rest-api/v7"
"github.com/messagebird/go-rest-api/v7/internal/mbtest"
messagebird "github.com/messagebird/go-rest-api/v8"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

const (
// ClientVersion is used in User-Agent request header to provide server with API level.
ClientVersion = "7.1.0"
ClientVersion = "8.0.0"

// Endpoint points you to MessageBird REST API.
Endpoint = "https://rest.messagebird.com"
Expand Down
2 changes: 1 addition & 1 deletion contact/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"time"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

// Contact gets returned by the API.
Expand Down
2 changes: 1 addition & 1 deletion contact/contact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
)

func TestMain(m *testing.M) {
Expand Down
2 changes: 1 addition & 1 deletion conversation/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"time"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion conversation/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"net/http"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

// ListOptions can be used to set pagination options in List().
Expand Down
2 changes: 1 addition & 1 deletion conversation/conversation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion conversation/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"net/http"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

type MessageCreateRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion conversation/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"testing"

"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion conversation/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package conversation
import (
"net/http"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

type WebhookCreateRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion conversation/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"testing"

"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
18 changes: 18 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,21 @@ func TestError(t *testing.T) {
assert.Error(t, errRes)
})
}

func TestErrorWithEmptyErrors(t *testing.T) {
errRes := ErrorResponse{}
assert.Error(t, errRes)
assert.Equal(t, "API errors: ", errRes.Error())
}

func TestErrorWithOneEmptyError(t *testing.T) {
errRes := ErrorResponse{Errors: []Error{
{
Code: 11,
Description: "",
Parameter: "",
},
}}
assert.Error(t, errRes)
assert.Equal(t, "API errors: ", errRes.Error())
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/messagebird/go-rest-api/v7
module github.com/messagebird/go-rest-api/v8

go 1.14
go 1.16

require (
github.com/golang-jwt/jwt v3.2.1+incompatible
Expand Down
4 changes: 2 additions & 2 deletions group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"time"

messagebird "github.com/messagebird/go-rest-api/v7"
"github.com/messagebird/go-rest-api/v7/contact"
messagebird "github.com/messagebird/go-rest-api/v8"
"github.com/messagebird/go-rest-api/v8/contact"
)

// Group gets returned by the API.
Expand Down
2 changes: 1 addition & 1 deletion group/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion hlr/hlr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"time"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

// HLR stands for Home Location Register. Contains information about the
Expand Down
4 changes: 2 additions & 2 deletions hlr/hlr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"time"

"github.com/messagebird/go-rest-api/v7"
"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/mbtest/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"testing"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

// testWriter can be used to have the client write to the tests's error log.
Expand Down
15 changes: 12 additions & 3 deletions internal/mbtest/test_server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mbtest

import (
"context"
"crypto/tls"
"io/ioutil"
"net"
Expand Down Expand Up @@ -72,6 +73,13 @@ func WillReturn(b []byte, s int) {
status = s
}

// WillReturnOnlyStatus sets the response status (s) to be returned by the
// server for incoming requests.
func WillReturnOnlyStatus(s int) {
responseBody = []byte{}
status = s
}

// WillReturnTestdata sets the status (s) for the test server to respond with.
// Additionally it reads the bytes from the relativePath file and returns that
// for requests. It fails the test if the file can not be read. The path is
Expand Down Expand Up @@ -102,10 +110,11 @@ func HTTPTestTransport(handler http.Handler) (*http.Transport, func()) {
s := httptest.NewTLSServer(handler)

transport := &http.Transport{
DialTLS: func(network, _ string) (net.Conn, error) {
return tls.Dial(network, s.Listener.Addr().String(), &tls.Config{
DialTLSContext: func(ctx context.Context, network, _ string) (net.Conn, error) {
d := &tls.Dialer{Config: &tls.Config{
InsecureSkipVerify: true,
})
}}
return d.DialContext(ctx, network, s.Listener.Addr().String())
},
}

Expand Down
4 changes: 2 additions & 2 deletions lookup/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"net/http"
"net/url"

messagebird "github.com/messagebird/go-rest-api/v7"
"github.com/messagebird/go-rest-api/v7/hlr"
messagebird "github.com/messagebird/go-rest-api/v8"
"github.com/messagebird/go-rest-api/v8/hlr"
)

// Formats represents phone number in multiple formats.
Expand Down
4 changes: 2 additions & 2 deletions lookup/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strconv"
"testing"

"github.com/messagebird/go-rest-api/v7/hlr"
"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/hlr"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion mms/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

// Message represents a MMS Message.
Expand Down
4 changes: 2 additions & 2 deletions mms/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"time"

messagebird "github.com/messagebird/go-rest-api/v7"
"github.com/messagebird/go-rest-api/v7/internal/mbtest"
messagebird "github.com/messagebird/go-rest-api/v8"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion number/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/url"
"strconv"

messagebird "github.com/messagebird/go-rest-api/v7"
messagebird "github.com/messagebird/go-rest-api/v8"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion number/number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"testing"

"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
22 changes: 19 additions & 3 deletions recipient.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,25 @@ import "time"

// Recipient struct holds information for a single msisdn with status details.
type Recipient struct {
Recipient int64
Status string
StatusDatetime *time.Time
Recipient int64
Status string
StatusDatetime *time.Time
RecipientCountry *string
RecipientCountryPrefix *int
RecipientOperator *string
MessageLength *int
StatusErrorCode *int
StatusReason *string
Price *Price
Mccmnc *string
Mcc *string
Mnc *string
MessagePartCount int
}

type Price struct {
Amount int
Currency string
}

// Recipients holds a collection of Recepient structs along with send stats.
Expand Down
2 changes: 1 addition & 1 deletion signature_jwt/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/messagebird/go-rest-api/v7/internal/mbtest"
"github.com/messagebird/go-rest-api/v8/internal/mbtest"
"github.com/stretchr/testify/assert"
)

Expand Down
Loading

0 comments on commit 88ad799

Please sign in to comment.