Skip to content

Commit 2794e41

Browse files
author
Dirk Hoekstra
committed
Merge remote-tracking branch 'origin/fix-linter-warnings' into add-mms
2 parents 03e8934 + 1f8d7d0 commit 2794e41

14 files changed

+63
-36
lines changed

balance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package messagebird
22

3+
// Balance describes your balance information.
34
type Balance struct {
45
Payment string
56
Type string

balance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package messagebird
22

33
import "testing"
44

5-
var balanceObject []byte = []byte(`{
5+
var balanceObject = []byte(`{
66
"payment":"prepaid",
77
"type":"credits",
88
"amount":9.2

client.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
//
55
// Author: Maurice Nonnekes <[email protected]>
66

7+
// Package messagebird is an official library for interacting with MessageBird.com API.
8+
// The MessageBird API connects your website or application to operators around the world. With our API you can integrate SMS, Chat & Voice.
9+
// More documentation you can find on the MessageBird developers portal: https://developers.messagebird.com/
710
package messagebird
811

912
import (
@@ -18,15 +21,23 @@ import (
1821
)
1922

2023
const (
24+
// ClientVersion is used in User-Agent request header to provide server with API level.
2125
ClientVersion = "3.0.0"
22-
Endpoint = "https://rest.messagebird.com"
26+
27+
// Endpoint points you to MessageBird REST API.
28+
Endpoint = "https://rest.messagebird.com"
2329
)
2430

2531
var (
26-
ErrResponse = errors.New("The MessageBird API returned an error")
32+
// ErrResponse is returned when we were able to contact API but request was not successful and contains error details.
33+
ErrResponse = errors.New("The MessageBird API returned an error")
34+
35+
// ErrUnexpectedResponse is used when there was an internal server error and nothing can be done at this point.
2736
ErrUnexpectedResponse = errors.New("The MessageBird API is currently unavailable")
2837
)
2938

39+
// Client is used to access API with a given key.
40+
// Uses standard lib HTTP client internally, so should be reused instead of created as needed and it is safe for concurrent use.
3041
type Client struct {
3142
AccessKey string // The API access key
3243
HTTPClient *http.Client // The HTTP client to send requests on
@@ -52,7 +63,7 @@ func (c *Client) request(v interface{}, path string, params *url.Values) error {
5263
}
5364

5465
if c.DebugLog != nil {
55-
if unescapedBody, err := url.QueryUnescape(body); err == nil {
66+
if unescapedBody, queryError := url.QueryUnescape(body); queryError == nil {
5667
log.Printf("HTTP REQUEST: POST %s %s", uri.String(), unescapedBody)
5768
} else {
5869
log.Printf("HTTP REQUEST: POST %s %s", uri.String(), body)

error.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package messagebird
22

3+
// Error holds details including error code, human readable description and optional parameter that is related to the error.
34
type Error struct {
45
Code int
56
Description string

hlr.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package messagebird
22

33
import "time"
44

5+
// HLR stands for Home Location Register.
6+
// Contains information about the subscribers identity, telephone number, the associated services and general information about the location of the subscriber
57
type HLR struct {
6-
Id string
8+
ID string
79
HRef string
810
MSISDN int
911
Network int

hlr_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"time"
66
)
77

8-
var hlrObject []byte = []byte(`{
8+
var hlrObject = []byte(`{
99
"id":"27978c50354a93ca0ca8de6h54340177",
1010
"href":"https:\/\/rest.messagebird.com\/hlr\/27978c50354a93ca0ca8de6h54340177",
1111
"msisdn":31612345678,
@@ -17,8 +17,8 @@ var hlrObject []byte = []byte(`{
1717
}`)
1818

1919
func assertHLRObject(t *testing.T, hlr *HLR) {
20-
if hlr.Id != "27978c50354a93ca0ca8de6h54340177" {
21-
t.Errorf("Unexpected result for HLR Id: %s", hlr.Id)
20+
if hlr.ID != "27978c50354a93ca0ca8de6h54340177" {
21+
t.Errorf("Unexpected result for HLR Id: %s", hlr.ID)
2222
}
2323

2424
if hlr.HRef != "https://rest.messagebird.com/hlr/27978c50354a93ca0ca8de6h54340177" {

lookup.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package messagebird
22

33
import "net/url"
44

5+
// Formats represents phone number in multiple formats.
56
type Formats struct {
67
E164 string
78
International string
89
National string
910
Rfc3966 string
1011
}
1112

13+
// Lookup is used to validate and look up a mobile number.
1214
type Lookup struct {
1315
Href string
1416
CountryCode string
@@ -19,6 +21,7 @@ type Lookup struct {
1921
HLR *HLR
2022
}
2123

24+
// LookupParams provide additional lookup information.
2225
type LookupParams struct {
2326
CountryCode string
2427
Reference string

lookup_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66
)
77

8-
var lookupObject []byte = []byte(`{
8+
var lookupObject = []byte(`{
99
"href":"https://rest.messagebird.com/lookup/31624971134",
1010
"countryCode":"NL",
1111
"countryPrefix":31,
@@ -27,7 +27,7 @@ var lookupObject []byte = []byte(`{
2727
}
2828
}`)
2929

30-
var lookupHLRObject []byte = []byte(`{
30+
var lookupHLRObject = []byte(`{
3131
"id":"6118d3f06566fcd0cdc8962h65065907",
3232
"network":20416,
3333
"reference":"referece2000",
@@ -49,7 +49,7 @@ func TestLookup(t *testing.T) {
4949
t.Errorf("Unexpected lookup href: %s", lookup.Href)
5050
}
5151
if strconv.FormatInt(lookup.PhoneNumber, 10) != phoneNumber {
52-
t.Errorf("Unexpected lookup phoneNumber: %s", lookup.PhoneNumber)
52+
t.Errorf("Unexpected lookup phoneNumber: %d", lookup.PhoneNumber)
5353
}
5454

5555
if lookup.Formats.International != "+31 6 24971134" {
@@ -66,8 +66,8 @@ func TestLookup(t *testing.T) {
6666
}
6767

6868
func checkHLR(t *testing.T, hlr *HLR) {
69-
if hlr.Id != "6118d3f06566fcd0cdc8962h65065907" {
70-
t.Errorf("Unexpected hlr id: %s", hlr.Id)
69+
if hlr.ID != "6118d3f06566fcd0cdc8962h65065907" {
70+
t.Errorf("Unexpected hlr id: %s", hlr.ID)
7171
}
7272
if hlr.Network != 20416 {
7373
t.Errorf("Unexpected hlr network: %d", hlr.Network)

main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var mbServer *httptest.Server
1515
var mbServerResponseCode int
1616
var mbServerResponseBody []byte
1717

18-
var accessKeyErrorObject []byte = []byte(`{
18+
var accessKeyErrorObject = []byte(`{
1919
"errors":[
2020
{
2121
"code":2,

message.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import (
77
"time"
88
)
99

10+
// TypeDetails is a hash with extra information.
11+
// Is only used when a binary or premium message is sent.
1012
type TypeDetails map[string]interface{}
1113

14+
// Message struct represents a message at MessageBird.com
1215
type Message struct {
13-
Id string
16+
ID string
1417
HRef string
1518
Direction string
1619
Type string
@@ -28,6 +31,7 @@ type Message struct {
2831
Errors []Error
2932
}
3033

34+
// MessageParams provide additional message send options and used in URL as params.
3135
type MessageParams struct {
3236
Type string
3337
Reference string

0 commit comments

Comments
 (0)