Skip to content

Commit 7b880ae

Browse files
author
Dirk Hoekstra
committed
Fix merge conflicts
2 parents 8f43891 + 1f8d7d0 commit 7b880ae

14 files changed

+56
-29
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,8 +21,11 @@ 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
const (
@@ -36,10 +42,15 @@ const (
3642
)
3743

3844
var (
39-
ErrResponse = errors.New("The MessageBird API returned an error")
45+
// ErrResponse is returned when we were able to contact API but request was not successful and contains error details.
46+
ErrResponse = errors.New("The MessageBird API returned an error")
47+
48+
// ErrUnexpectedResponse is used when there was an internal server error and nothing can be done at this point.
4049
ErrUnexpectedResponse = errors.New("The MessageBird API is currently unavailable")
4150
)
4251

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

6778
if c.DebugLog != nil {
68-
if unescapedBody, err := url.QueryUnescape(body); err == nil {
79+
if unescapedBody, queryError := url.QueryUnescape(body); queryError == nil {
6980
log.Printf("HTTP REQUEST: POST %s %s", uri.String(), unescapedBody)
7081
} else {
7182
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
@@ -6,7 +6,7 @@ import (
66
"time"
77
)
88

9-
var hlrObject []byte = []byte(`{
9+
var hlrObject = []byte(`{
1010
"id":"27978c50354a93ca0ca8de6h54340177",
1111
"href":"https://rest.messagebird.com/hlr/27978c50354a93ca0ca8de6h54340177",
1212
"msisdn":31612345678,
@@ -53,8 +53,8 @@ var hlrListObject = []byte(`{
5353
}`)
5454

5555
func assertHLRObject(t *testing.T, hlr *HLR) {
56-
if hlr.Id != "27978c50354a93ca0ca8de6h54340177" {
57-
t.Errorf("Unexpected result for HLR id: %s, expected: 27978c50354a93ca0ca8de6h54340177", hlr.Id)
56+
if hlr.ID != "27978c50354a93ca0ca8de6h54340177" {
57+
t.Errorf("Unexpected result for HLR Id: %s, expected: 27978c50354a93ca0ca8de6h54340177", hlr.ID)
5858
}
5959

6060
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
@@ -38,6 +41,7 @@ type MessageList struct {
3841
Items []Message
3942
}
4043

44+
// MessageParams provide additional message send options and used in URL as params.
4145
type MessageParams struct {
4246
Type string
4347
Reference string

0 commit comments

Comments
 (0)