-
Notifications
You must be signed in to change notification settings - Fork 1
/
number.go
52 lines (44 loc) · 1.23 KB
/
number.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
43
44
45
46
47
48
49
50
51
52
package ilert
import (
"encoding/json"
)
// Number definition https://api.ilert.com/api-docs/#tag/Numbers
type Number struct {
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
SupportsInboundSMS bool `json:"supportsInboundSms"`
Types []string `json:"types"`
}
// NumberTypes defines number types
var NumberTypes = struct {
SMS string
Voice string
}{
SMS: "SMS",
Voice: "VOICE",
}
// GetNumbersInput represents the input of a GetNumbers operation.
type GetNumbersInput struct {
_ struct{}
}
// GetNumbersOutput represents the output of a GetNumbers operation.
type GetNumbersOutput struct {
_ struct{}
Numbers []*Number
}
// GetNumbers gets list available ilert phone numbers. https://api.ilert.com/api-docs/#tag/Numbers/paths/~1numbers/get
func (c *Client) GetNumbers(input *GetNumbersInput) (*GetNumbersOutput, error) {
resp, err := c.httpClient.R().Get(apiRoutes.numbers)
if err != nil {
return nil, err
}
if apiErr := getGenericAPIError(resp, 200); apiErr != nil {
return nil, apiErr
}
numbers := make([]*Number, 0)
err = json.Unmarshal(resp.Body(), &numbers)
if err != nil {
return nil, err
}
return &GetNumbersOutput{Numbers: numbers}, nil
}