-
Notifications
You must be signed in to change notification settings - Fork 20
/
sms.go
34 lines (28 loc) · 898 Bytes
/
sms.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
package clerk
import (
"encoding/json"
)
type SMSService service
type SMSMessage struct {
Message string `json:"message"`
PhoneNumberID string `json:"phone_number_id"`
}
type SMSMessageResponse struct {
Object string `json:"object"`
ID string `json:"id"`
FromPhoneNumber string `json:"from_phone_number"`
ToPhoneNumber *string `json:"to_phone_number,omitempty"`
Status string `json:"status"`
DeliveredByClerk bool `json:"delivered_by_clerk"`
Data json.RawMessage `json:"data"`
SMSMessage
}
func (s *SMSService) Create(message SMSMessage) (*SMSMessageResponse, error) {
req, _ := s.client.NewRequest("POST", SMSUrl, &message)
var smsResponse SMSMessageResponse
_, err := s.client.Do(req, &smsResponse)
if err != nil {
return nil, err
}
return &smsResponse, nil
}