forked from kevinburke/twilio-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lookup.go
42 lines (35 loc) · 1.19 KB
/
lookup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package twilio
import (
"context"
"net/url"
)
const phoneNumbersPath = "PhoneNumbers"
type LookupPhoneNumbersService struct {
client *Client
}
type CallerLookup struct {
CallerName string `json:"caller_name"`
CallerType string `json:"caller_type"`
ErrorCode int `json:"error_code"`
}
type CarrierLookup struct {
Type string `json:"type"`
ErrorCode int `json:"error_code"`
MobileNetworkCode string `json:"mobile_network_code"`
MobileCountryCode string `json:"mobile_country_code"`
Name string `json:"name"`
}
type PhoneLookup struct {
CountryCode string `json:"country_code"`
PhoneNumber string `json:"phone_number"`
NationalFormat string `json:"national_format"`
URL string `json:"url"`
CallerName CallerLookup `json:"caller_name"`
Carrier CarrierLookup `json:"carrier"`
}
// Get calls the lookups API to retrieve information about a phone number
func (s *LookupPhoneNumbersService) Get(ctx context.Context, phone string, data url.Values) (*PhoneLookup, error) {
lookup := new(PhoneLookup)
err := s.client.MakeRequest(ctx, "GET", phoneNumbersPath+"/"+phone, data, lookup)
return lookup, err
}