Skip to content

Commit 9a7c47d

Browse files
author
Dirk Hoekstra
committed
Use Path constants for URLs
1 parent 2725489 commit 9a7c47d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const (
3333
HLRPath = "hlr"
3434
// MessagePath represents the path to the Message resource.
3535
MessagePath = "messages"
36+
// MMSPath represents the path to the MMS resource.
37+
MMSPath = "mms"
3638
// VoiceMessagePath represents the path to the VoiceMessage resource.
3739
VoiceMessagePath = "voicemessages"
3840
// VerifyPath represents the path to the Verify resource.
@@ -220,7 +222,7 @@ func (c *Client) Messages(msgListParams *MessageListParams) (*MessageList, error
220222
return messageList, err
221223
}
222224

223-
if err := c.request(messageList, "messages?"+params.Encode(), nil); err != nil {
225+
if err := c.request(messageList, MessagePath+"?"+params.Encode(), nil); err != nil {
224226
if err == ErrResponse {
225227
return messageList, err
226228
}
@@ -257,7 +259,7 @@ func (c *Client) NewMessage(originator string, recipients []string, body string,
257259
// MMSMessage retrieves the information of an existing MmsMessage.
258260
func (c *Client) MMSMessage(id string) (*MMSMessage, error) {
259261
mmsMessage := &MMSMessage{}
260-
if err := c.request(mmsMessage, "mms/"+id, nil); err != nil {
262+
if err := c.request(mmsMessage, MMSPath+"/"+id, nil); err != nil {
261263
if err == ErrResponse {
262264
return mmsMessage, err
263265
}
@@ -279,7 +281,7 @@ func (c *Client) NewMMSMessage(originator string, recipients []string, msgParams
279281
params.Set("recipients", strings.Join(recipients, ","))
280282

281283
mmsMessage := &MMSMessage{}
282-
if err := c.request(mmsMessage, "mms", params); err != nil {
284+
if err := c.request(mmsMessage, MMSPath, params); err != nil {
283285
if err == ErrResponse {
284286
return mmsMessage, err
285287
}
@@ -392,7 +394,7 @@ func (c *Client) Lookup(phoneNumber string, params *LookupParams) (*Lookup, erro
392394
// NewLookupHLR creates a new HLR lookup for the specified number.
393395
func (c *Client) NewLookupHLR(phoneNumber string, params *LookupParams) (*HLR, error) {
394396
urlParams := paramsForLookup(params)
395-
path := LookupPath + "/" + phoneNumber + "/hlr"
397+
path := LookupPath + "/" + phoneNumber + "/" + HLRPath
396398

397399
hlr := &HLR{}
398400
if err := c.request(hlr, path, urlParams); err != nil {
@@ -409,7 +411,7 @@ func (c *Client) NewLookupHLR(phoneNumber string, params *LookupParams) (*HLR, e
409411
// LookupHLR performs a HLR lookup for the specified number.
410412
func (c *Client) LookupHLR(phoneNumber string, params *LookupParams) (*HLR, error) {
411413
urlParams := paramsForLookup(params)
412-
path := LookupPath + "/" + phoneNumber + "/hlr?" + urlParams.Encode()
414+
path := LookupPath + "/" + phoneNumber + "/" + HLRPath + "?" + urlParams.Encode()
413415

414416
hlr := &HLR{}
415417
if err := c.request(hlr, path, nil); err != nil {

0 commit comments

Comments
 (0)