Skip to content

Commit 2e4ba59

Browse files
committed
Make path constants unexported
1 parent 6c8bbc2 commit 2e4ba59

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

balance/balance.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ type Balance struct {
1313
Amount float32
1414
}
1515

16+
const path = "balance"
17+
1618
// Read returns the balance information for the account that is associated with
1719
// the access key.
1820
func Read(c *messagebird.Client) (*Balance, error) {
1921
balance := &Balance{}
20-
if err := c.Request(balance, http.MethodGet, "balance", nil); err != nil {
22+
if err := c.Request(balance, http.MethodGet, path, nil); err != nil {
2123
return nil, err
2224
}
2325

hlr/hlr.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ type hlrRequest struct {
3838
Reference string `json:"reference"`
3939
}
4040

41-
// HLRPath represents the path to the HLR resource.
42-
const HLRPath = "hlr"
41+
// path represents the path to the HLR resource.
42+
const path = "hlr"
4343

4444
// Read looks up an existing HLR object for the specified id that was previously
4545
// created by the NewHLR function.
4646
func Read(c *messagebird.Client, id string) (*HLR, error) {
4747
hlr := &HLR{}
48-
if err := c.Request(hlr, http.MethodGet, HLRPath+"/"+id, nil); err != nil {
48+
if err := c.Request(hlr, http.MethodGet, path+"/"+id, nil); err != nil {
4949
return nil, err
5050
}
5151

@@ -55,7 +55,7 @@ func Read(c *messagebird.Client, id string) (*HLR, error) {
5555
// List all HLR objects that were previously created by the Create function.
5656
func List(c *messagebird.Client) (*HLRList, error) {
5757
hlrList := &HLRList{}
58-
if err := c.Request(hlrList, http.MethodGet, HLRPath, nil); err != nil {
58+
if err := c.Request(hlrList, http.MethodGet, path, nil); err != nil {
5959
return nil, err
6060
}
6161

@@ -71,7 +71,7 @@ func Create(c *messagebird.Client, msisdn string, reference string) (*HLR, error
7171

7272
hlr := &HLR{}
7373

74-
if err := c.Request(hlr, http.MethodPost, HLRPath, requestData); err != nil {
74+
if err := c.Request(hlr, http.MethodPost, path, requestData); err != nil {
7575
return nil, err
7676
}
7777

lookup/lookup.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ type lookupRequest struct {
3838
Reference string `json:"reference,omitempty"`
3939
}
4040

41-
// LookupPath represents the path to the Lookup resource.
42-
const LookupPath = "lookup"
41+
// hlrPath represents the path to the HLR resource within the lookup resource.
42+
const hlrPath = "hlr"
43+
44+
// lookupPath represents the path to the Lookup resource.
45+
const lookupPath = "lookup"
4346

4447
// Create performs a new lookup for the specified number.
4548
func Create(c *messagebird.Client, phoneNumber string, params *LookupParams) (*Lookup, error) {
4649
urlParams := paramsForLookup(params)
47-
path := LookupPath + "/" + phoneNumber + "?" + urlParams.Encode()
50+
path := lookupPath + "/" + phoneNumber + "?" + urlParams.Encode()
4851

4952
lookup := &Lookup{}
5053
if err := c.Request(lookup, http.MethodPost, path, nil); err != nil {
@@ -57,7 +60,7 @@ func Create(c *messagebird.Client, phoneNumber string, params *LookupParams) (*L
5760
// CreateHLR creates a new HLR lookup for the specified number.
5861
func CreateHLR(c *messagebird.Client, phoneNumber string, params *LookupParams) (*hlr.HLR, error) {
5962
requestData := requestDataForLookup(params)
60-
path := LookupPath + "/" + phoneNumber + "/" + hlr.HLRPath
63+
path := lookupPath + "/" + phoneNumber + "/" + hlrPath
6164

6265
hlr := &hlr.HLR{}
6366
if err := c.Request(hlr, http.MethodPost, path, requestData); err != nil {
@@ -70,7 +73,7 @@ func CreateHLR(c *messagebird.Client, phoneNumber string, params *LookupParams)
7073
// ReadHLR performs a HLR lookup for the specified number.
7174
func ReadHLR(c *messagebird.Client, phoneNumber string, params *LookupParams) (*hlr.HLR, error) {
7275
urlParams := paramsForLookup(params)
73-
path := LookupPath + "/" + phoneNumber + "/" + hlr.HLRPath + "?" + urlParams.Encode()
76+
path := lookupPath + "/" + phoneNumber + "/" + hlrPath + "?" + urlParams.Encode()
7477

7578
hlr := &hlr.HLR{}
7679
if err := c.Request(hlr, http.MethodGet, path, nil); err != nil {

message/message.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ type messageRequest struct {
8080
ScheduledDatetime string `json:"scheduledDatetime,omitempty"`
8181
}
8282

83-
// MessagePath represents the path to the Message resource.
84-
const MessagePath = "messages"
83+
// path represents the path to the Message resource.
84+
const path = "messages"
8585

8686
// Read retrieves the information of an existing Message.
8787
func Read(c *messagebird.Client, id string) (*Message, error) {
8888
message := &Message{}
89-
if err := c.Request(message, http.MethodGet, MessagePath+"/"+id, nil); err != nil {
89+
if err := c.Request(message, http.MethodGet, path+"/"+id, nil); err != nil {
9090
return nil, err
9191
}
9292

@@ -101,7 +101,7 @@ func List(c *messagebird.Client, msgListParams *MessageListParams) (*MessageList
101101
return messageList, err
102102
}
103103

104-
if err := c.Request(messageList, http.MethodGet, MessagePath+"?"+params.Encode(), nil); err != nil {
104+
if err := c.Request(messageList, http.MethodGet, path+"?"+params.Encode(), nil); err != nil {
105105
return nil, err
106106
}
107107

@@ -116,7 +116,7 @@ func Create(c *messagebird.Client, originator string, recipients []string, body
116116
}
117117

118118
message := &Message{}
119-
if err := c.Request(message, http.MethodPost, MessagePath, requestData); err != nil {
119+
if err := c.Request(message, http.MethodPost, path, requestData); err != nil {
120120
return nil, err
121121
}
122122

mmsmessage/mms_message.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ type MMSMessageParams struct {
3535
ScheduledDatetime time.Time
3636
}
3737

38-
// MMSPath represents the path to the MMS resource.
39-
const MMSPath = "mms"
38+
// path represents the path to the MMS resource.
39+
const path = "mms"
4040

4141
// Read retrieves the information of an existing MmsMessage.
4242
func Read(c *messagebird.Client, id string) (*MMSMessage, error) {
4343
mmsMessage := &MMSMessage{}
44-
if err := c.Request(mmsMessage, http.MethodGet, MMSPath+"/"+id, nil); err != nil {
44+
if err := c.Request(mmsMessage, http.MethodGet, path+"/"+id, nil); err != nil {
4545
return nil, err
4646
}
4747

@@ -59,7 +59,7 @@ func Create(c *messagebird.Client, originator string, recipients []string, msgPa
5959
params.Set("recipients", strings.Join(recipients, ","))
6060

6161
mmsMessage := &MMSMessage{}
62-
if err := c.Request(mmsMessage, http.MethodPost, MMSPath, params); err != nil {
62+
if err := c.Request(mmsMessage, http.MethodPost, path, params); err != nil {
6363
return nil, err
6464
}
6565

verify/verify.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ type verifyRequest struct {
4949
TokenLength int `json:"tokenLength,omitempty"`
5050
}
5151

52-
// VerifyPath represents the path to the Verify resource.
53-
const VerifyPath = "verify"
52+
// path represents the path to the Verify resource.
53+
const path = "verify"
5454

5555
// Create generates a new One-Time-Password for one recipient.
5656
func Create(c *messagebird.Client, recipient string, params *VerifyParams) (*Verify, error) {
@@ -60,7 +60,7 @@ func Create(c *messagebird.Client, recipient string, params *VerifyParams) (*Ver
6060
}
6161

6262
verify := &Verify{}
63-
if err := c.Request(verify, http.MethodPost, VerifyPath, requestData); err != nil {
63+
if err := c.Request(verify, http.MethodPost, path, requestData); err != nil {
6464
return nil, err
6565
}
6666

@@ -72,10 +72,10 @@ func VerifyToken(c *messagebird.Client, id, token string) (*Verify, error) {
7272
params := &url.Values{}
7373
params.Set("token", token)
7474

75-
path := VerifyPath + "/" + id + "?" + params.Encode()
75+
pathWithParams := path + "/" + id + "?" + params.Encode()
7676

7777
verify := &Verify{}
78-
if err := c.Request(verify, http.MethodGet, path, nil); err != nil {
78+
if err := c.Request(verify, http.MethodGet, pathWithParams, nil); err != nil {
7979
return nil, err
8080
}
8181

voicemessage/voice_message.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ type voiceMessageRequest struct {
5858
ScheduledDatetime string `json:"scheduledDatetime,omitempty"`
5959
}
6060

61-
// VoiceMessagePath represents the VoiceMessagePath to the VoiceMessage resource.
62-
const VoiceMessagePath = "voicemessages"
61+
// path represents the path to the VoiceMessage resource.
62+
const path = "voicemessages"
6363

6464
// Read retrieves the information of an existing VoiceMessage.
6565
func Read(c *messagebird.Client, id string) (*VoiceMessage, error) {
6666
message := &VoiceMessage{}
67-
if err := c.Request(message, http.MethodGet, VoiceMessagePath+"/"+id, nil); err != nil {
67+
if err := c.Request(message, http.MethodGet, path+"/"+id, nil); err != nil {
6868
return nil, err
6969
}
7070

@@ -74,7 +74,7 @@ func Read(c *messagebird.Client, id string) (*VoiceMessage, error) {
7474
// List retrieves all VoiceMessages of the user.
7575
func List(c *messagebird.Client) (*VoiceMessageList, error) {
7676
messageList := &VoiceMessageList{}
77-
if err := c.Request(messageList, http.MethodGet, VoiceMessagePath, nil); err != nil {
77+
if err := c.Request(messageList, http.MethodGet, path, nil); err != nil {
7878
return nil, err
7979
}
8080

@@ -89,7 +89,7 @@ func Create(c *messagebird.Client, recipients []string, body string, params *Voi
8989
}
9090

9191
message := &VoiceMessage{}
92-
if err := c.Request(message, http.MethodPost, VoiceMessagePath, requestData); err != nil {
92+
if err := c.Request(message, http.MethodPost, path, requestData); err != nil {
9393
return nil, err
9494
}
9595

0 commit comments

Comments
 (0)