/
api_op_create.go
82 lines (73 loc) · 4.04 KB
/
api_op_create.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Package phone_numbers contains auto-generated files. DO NOT MODIFY
package phone_numbers
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
)
// CreatePhoneNumberInput defines the input fields for creating a new phone number resource
type CreatePhoneNumberInput struct {
PhoneNumberSid string `validate:"required" form:"PhoneNumberSid"`
}
type CreatePhoneNumberCapabilitiesResponse struct {
Fax *bool `json:"fax,omitempty"`
Mms bool `json:"MMS"`
Sms bool `json:"SMS"`
Voice bool `json:"voice"`
}
// CreatePhoneNumberResponse defines the response fields for the created phone number resource
type CreatePhoneNumberResponse struct {
APIVersion string `json:"api_version"`
AccountSid string `json:"account_sid"`
AddressRequirements string `json:"address_requirements"`
Beta bool `json:"beta"`
Capabilities CreatePhoneNumberCapabilitiesResponse `json:"capabilities"`
DateCreated time.Time `json:"date_created"`
DateUpdated *time.Time `json:"date_updated,omitempty"`
FriendlyName *string `json:"friendly_name,omitempty"`
PhoneNumber string `json:"phone_number"`
Sid string `json:"sid"`
SmsApplicationSid *string `json:"sms_application_sid,omitempty"`
SmsFallbackMethod string `json:"sms_fallback_method"`
SmsFallbackURL *string `json:"sms_fallback_url,omitempty"`
SmsMethod string `json:"sms_method"`
SmsURL *string `json:"sms_url,omitempty"`
StatusCallback *string `json:"status_callback,omitempty"`
StatusCallbackMethod string `json:"status_callback_method"`
TrunkSid string `json:"trunk_sid"`
URL string `json:"url"`
VoiceApplicationSid *string `json:"voice_application_sid,omitempty"`
VoiceCallerIDLookup bool `json:"voice_caller_id_lookup"`
VoiceFallbackMethod string `json:"voice_fallback_method"`
VoiceFallbackURL *string `json:"voice_fallback_url,omitempty"`
VoiceMethod string `json:"voice_method"`
VoiceReceiveMode *string `json:"voice_receive_mode,omitempty"`
VoiceURL *string `json:"voice_url,omitempty"`
}
// Create adds a phone number resource to the SIP trunk
// See https://www.twilio.com/docs/sip-trunking/api/phonenumber-resource#create-a-phonenumber-resource for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Create(input *CreatePhoneNumberInput) (*CreatePhoneNumberResponse, error) {
return c.CreateWithContext(context.Background(), input)
}
// CreateWithContext adds a phone number resource to the SIP trunk
// See https://www.twilio.com/docs/sip-trunking/api/phonenumber-resource#create-a-phonenumber-resource for more details
func (c Client) CreateWithContext(context context.Context, input *CreatePhoneNumberInput) (*CreatePhoneNumberResponse, error) {
op := client.Operation{
Method: http.MethodPost,
URI: "/Trunks/{trunkSid}/PhoneNumbers",
ContentType: client.URLEncoded,
PathParams: map[string]string{
"trunkSid": c.trunkSid,
},
}
if input == nil {
input = &CreatePhoneNumberInput{}
}
response := &CreatePhoneNumberResponse{}
if err := c.client.Send(context, op, input, response); err != nil {
return nil, err
}
return response, nil
}