github.com/twilio/twilio-go@v1.20.1/rest/api/v2010/accounts_sip_domains.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Api 8 * This is the public Twilio REST API. 9 * 10 * NOTE: This class is auto generated by OpenAPI Generator. 11 * https://openapi-generator.tech 12 * Do not edit the class manually. 13 */ 14 15 package openapi 16 17 import ( 18 "encoding/json" 19 "fmt" 20 "net/url" 21 "strings" 22 23 "github.com/twilio/twilio-go/client" 24 ) 25 26 // Optional parameters for the method 'CreateSipDomain' 27 type CreateSipDomainParams struct { 28 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource. 29 PathAccountSid *string `json:"PathAccountSid,omitempty"` 30 // The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and \\\"-\\\" and must end with `sip.twilio.com`. 31 DomainName *string `json:"DomainName,omitempty"` 32 // A descriptive string that you created to describe the resource. It can be up to 64 characters long. 33 FriendlyName *string `json:"FriendlyName,omitempty"` 34 // The URL we should when the domain receives a call. 35 VoiceUrl *string `json:"VoiceUrl,omitempty"` 36 // The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`. 37 VoiceMethod *string `json:"VoiceMethod,omitempty"` 38 // The URL that we should call when an error occurs while retrieving or executing the TwiML from `voice_url`. 39 VoiceFallbackUrl *string `json:"VoiceFallbackUrl,omitempty"` 40 // The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. 41 VoiceFallbackMethod *string `json:"VoiceFallbackMethod,omitempty"` 42 // The URL that we should call to pass status parameters (such as call ended) to your application. 43 VoiceStatusCallbackUrl *string `json:"VoiceStatusCallbackUrl,omitempty"` 44 // The HTTP method we should use to call `voice_status_callback_url`. Can be: `GET` or `POST`. 45 VoiceStatusCallbackMethod *string `json:"VoiceStatusCallbackMethod,omitempty"` 46 // Whether to allow SIP Endpoints to register with the domain to receive calls. Can be `true` or `false`. `true` allows SIP Endpoints to register with the domain to receive calls, `false` does not. 47 SipRegistration *bool `json:"SipRegistration,omitempty"` 48 // Whether emergency calling is enabled for the domain. If enabled, allows emergency calls on the domain from phone numbers with validated addresses. 49 EmergencyCallingEnabled *bool `json:"EmergencyCallingEnabled,omitempty"` 50 // Whether secure SIP is enabled for the domain. If enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls to this sip domain. 51 Secure *bool `json:"Secure,omitempty"` 52 // The SID of the BYOC Trunk(Bring Your Own Carrier) resource that the Sip Domain will be associated with. 53 ByocTrunkSid *string `json:"ByocTrunkSid,omitempty"` 54 // Whether an emergency caller sid is configured for the domain. If present, this phone number will be used as the callback for the emergency call. 55 EmergencyCallerSid *string `json:"EmergencyCallerSid,omitempty"` 56 } 57 58 func (params *CreateSipDomainParams) SetPathAccountSid(PathAccountSid string) *CreateSipDomainParams { 59 params.PathAccountSid = &PathAccountSid 60 return params 61 } 62 func (params *CreateSipDomainParams) SetDomainName(DomainName string) *CreateSipDomainParams { 63 params.DomainName = &DomainName 64 return params 65 } 66 func (params *CreateSipDomainParams) SetFriendlyName(FriendlyName string) *CreateSipDomainParams { 67 params.FriendlyName = &FriendlyName 68 return params 69 } 70 func (params *CreateSipDomainParams) SetVoiceUrl(VoiceUrl string) *CreateSipDomainParams { 71 params.VoiceUrl = &VoiceUrl 72 return params 73 } 74 func (params *CreateSipDomainParams) SetVoiceMethod(VoiceMethod string) *CreateSipDomainParams { 75 params.VoiceMethod = &VoiceMethod 76 return params 77 } 78 func (params *CreateSipDomainParams) SetVoiceFallbackUrl(VoiceFallbackUrl string) *CreateSipDomainParams { 79 params.VoiceFallbackUrl = &VoiceFallbackUrl 80 return params 81 } 82 func (params *CreateSipDomainParams) SetVoiceFallbackMethod(VoiceFallbackMethod string) *CreateSipDomainParams { 83 params.VoiceFallbackMethod = &VoiceFallbackMethod 84 return params 85 } 86 func (params *CreateSipDomainParams) SetVoiceStatusCallbackUrl(VoiceStatusCallbackUrl string) *CreateSipDomainParams { 87 params.VoiceStatusCallbackUrl = &VoiceStatusCallbackUrl 88 return params 89 } 90 func (params *CreateSipDomainParams) SetVoiceStatusCallbackMethod(VoiceStatusCallbackMethod string) *CreateSipDomainParams { 91 params.VoiceStatusCallbackMethod = &VoiceStatusCallbackMethod 92 return params 93 } 94 func (params *CreateSipDomainParams) SetSipRegistration(SipRegistration bool) *CreateSipDomainParams { 95 params.SipRegistration = &SipRegistration 96 return params 97 } 98 func (params *CreateSipDomainParams) SetEmergencyCallingEnabled(EmergencyCallingEnabled bool) *CreateSipDomainParams { 99 params.EmergencyCallingEnabled = &EmergencyCallingEnabled 100 return params 101 } 102 func (params *CreateSipDomainParams) SetSecure(Secure bool) *CreateSipDomainParams { 103 params.Secure = &Secure 104 return params 105 } 106 func (params *CreateSipDomainParams) SetByocTrunkSid(ByocTrunkSid string) *CreateSipDomainParams { 107 params.ByocTrunkSid = &ByocTrunkSid 108 return params 109 } 110 func (params *CreateSipDomainParams) SetEmergencyCallerSid(EmergencyCallerSid string) *CreateSipDomainParams { 111 params.EmergencyCallerSid = &EmergencyCallerSid 112 return params 113 } 114 115 // Create a new Domain 116 func (c *ApiService) CreateSipDomain(params *CreateSipDomainParams) (*ApiV2010SipDomain, error) { 117 path := "/2010-04-01/Accounts/{AccountSid}/SIP/Domains.json" 118 if params != nil && params.PathAccountSid != nil { 119 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 120 } else { 121 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 122 } 123 124 data := url.Values{} 125 headers := make(map[string]interface{}) 126 127 if params != nil && params.DomainName != nil { 128 data.Set("DomainName", *params.DomainName) 129 } 130 if params != nil && params.FriendlyName != nil { 131 data.Set("FriendlyName", *params.FriendlyName) 132 } 133 if params != nil && params.VoiceUrl != nil { 134 data.Set("VoiceUrl", *params.VoiceUrl) 135 } 136 if params != nil && params.VoiceMethod != nil { 137 data.Set("VoiceMethod", *params.VoiceMethod) 138 } 139 if params != nil && params.VoiceFallbackUrl != nil { 140 data.Set("VoiceFallbackUrl", *params.VoiceFallbackUrl) 141 } 142 if params != nil && params.VoiceFallbackMethod != nil { 143 data.Set("VoiceFallbackMethod", *params.VoiceFallbackMethod) 144 } 145 if params != nil && params.VoiceStatusCallbackUrl != nil { 146 data.Set("VoiceStatusCallbackUrl", *params.VoiceStatusCallbackUrl) 147 } 148 if params != nil && params.VoiceStatusCallbackMethod != nil { 149 data.Set("VoiceStatusCallbackMethod", *params.VoiceStatusCallbackMethod) 150 } 151 if params != nil && params.SipRegistration != nil { 152 data.Set("SipRegistration", fmt.Sprint(*params.SipRegistration)) 153 } 154 if params != nil && params.EmergencyCallingEnabled != nil { 155 data.Set("EmergencyCallingEnabled", fmt.Sprint(*params.EmergencyCallingEnabled)) 156 } 157 if params != nil && params.Secure != nil { 158 data.Set("Secure", fmt.Sprint(*params.Secure)) 159 } 160 if params != nil && params.ByocTrunkSid != nil { 161 data.Set("ByocTrunkSid", *params.ByocTrunkSid) 162 } 163 if params != nil && params.EmergencyCallerSid != nil { 164 data.Set("EmergencyCallerSid", *params.EmergencyCallerSid) 165 } 166 167 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 168 if err != nil { 169 return nil, err 170 } 171 172 defer resp.Body.Close() 173 174 ps := &ApiV2010SipDomain{} 175 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 176 return nil, err 177 } 178 179 return ps, err 180 } 181 182 // Optional parameters for the method 'DeleteSipDomain' 183 type DeleteSipDomainParams struct { 184 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the SipDomain resources to delete. 185 PathAccountSid *string `json:"PathAccountSid,omitempty"` 186 } 187 188 func (params *DeleteSipDomainParams) SetPathAccountSid(PathAccountSid string) *DeleteSipDomainParams { 189 params.PathAccountSid = &PathAccountSid 190 return params 191 } 192 193 // Delete an instance of a Domain 194 func (c *ApiService) DeleteSipDomain(Sid string, params *DeleteSipDomainParams) error { 195 path := "/2010-04-01/Accounts/{AccountSid}/SIP/Domains/{Sid}.json" 196 if params != nil && params.PathAccountSid != nil { 197 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 198 } else { 199 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 200 } 201 path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1) 202 203 data := url.Values{} 204 headers := make(map[string]interface{}) 205 206 resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers) 207 if err != nil { 208 return err 209 } 210 211 defer resp.Body.Close() 212 213 return nil 214 } 215 216 // Optional parameters for the method 'FetchSipDomain' 217 type FetchSipDomainParams struct { 218 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the SipDomain resource to fetch. 219 PathAccountSid *string `json:"PathAccountSid,omitempty"` 220 } 221 222 func (params *FetchSipDomainParams) SetPathAccountSid(PathAccountSid string) *FetchSipDomainParams { 223 params.PathAccountSid = &PathAccountSid 224 return params 225 } 226 227 // Fetch an instance of a Domain 228 func (c *ApiService) FetchSipDomain(Sid string, params *FetchSipDomainParams) (*ApiV2010SipDomain, error) { 229 path := "/2010-04-01/Accounts/{AccountSid}/SIP/Domains/{Sid}.json" 230 if params != nil && params.PathAccountSid != nil { 231 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 232 } else { 233 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 234 } 235 path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1) 236 237 data := url.Values{} 238 headers := make(map[string]interface{}) 239 240 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 241 if err != nil { 242 return nil, err 243 } 244 245 defer resp.Body.Close() 246 247 ps := &ApiV2010SipDomain{} 248 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 249 return nil, err 250 } 251 252 return ps, err 253 } 254 255 // Optional parameters for the method 'ListSipDomain' 256 type ListSipDomainParams struct { 257 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the SipDomain resources to read. 258 PathAccountSid *string `json:"PathAccountSid,omitempty"` 259 // How many resources to return in each list page. The default is 50, and the maximum is 1000. 260 PageSize *int `json:"PageSize,omitempty"` 261 // Max number of records to return. 262 Limit *int `json:"limit,omitempty"` 263 } 264 265 func (params *ListSipDomainParams) SetPathAccountSid(PathAccountSid string) *ListSipDomainParams { 266 params.PathAccountSid = &PathAccountSid 267 return params 268 } 269 func (params *ListSipDomainParams) SetPageSize(PageSize int) *ListSipDomainParams { 270 params.PageSize = &PageSize 271 return params 272 } 273 func (params *ListSipDomainParams) SetLimit(Limit int) *ListSipDomainParams { 274 params.Limit = &Limit 275 return params 276 } 277 278 // Retrieve a single page of SipDomain records from the API. Request is executed immediately. 279 func (c *ApiService) PageSipDomain(params *ListSipDomainParams, pageToken, pageNumber string) (*ListSipDomainResponse, error) { 280 path := "/2010-04-01/Accounts/{AccountSid}/SIP/Domains.json" 281 282 if params != nil && params.PathAccountSid != nil { 283 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 284 } else { 285 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 286 } 287 288 data := url.Values{} 289 headers := make(map[string]interface{}) 290 291 if params != nil && params.PageSize != nil { 292 data.Set("PageSize", fmt.Sprint(*params.PageSize)) 293 } 294 295 if pageToken != "" { 296 data.Set("PageToken", pageToken) 297 } 298 if pageNumber != "" { 299 data.Set("Page", pageNumber) 300 } 301 302 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 303 if err != nil { 304 return nil, err 305 } 306 307 defer resp.Body.Close() 308 309 ps := &ListSipDomainResponse{} 310 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 311 return nil, err 312 } 313 314 return ps, err 315 } 316 317 // Lists SipDomain records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning. 318 func (c *ApiService) ListSipDomain(params *ListSipDomainParams) ([]ApiV2010SipDomain, error) { 319 response, errors := c.StreamSipDomain(params) 320 321 records := make([]ApiV2010SipDomain, 0) 322 for record := range response { 323 records = append(records, record) 324 } 325 326 if err := <-errors; err != nil { 327 return nil, err 328 } 329 330 return records, nil 331 } 332 333 // Streams SipDomain records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached. 334 func (c *ApiService) StreamSipDomain(params *ListSipDomainParams) (chan ApiV2010SipDomain, chan error) { 335 if params == nil { 336 params = &ListSipDomainParams{} 337 } 338 params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit)) 339 340 recordChannel := make(chan ApiV2010SipDomain, 1) 341 errorChannel := make(chan error, 1) 342 343 response, err := c.PageSipDomain(params, "", "") 344 if err != nil { 345 errorChannel <- err 346 close(recordChannel) 347 close(errorChannel) 348 } else { 349 go c.streamSipDomain(response, params, recordChannel, errorChannel) 350 } 351 352 return recordChannel, errorChannel 353 } 354 355 func (c *ApiService) streamSipDomain(response *ListSipDomainResponse, params *ListSipDomainParams, recordChannel chan ApiV2010SipDomain, errorChannel chan error) { 356 curRecord := 1 357 358 for response != nil { 359 responseRecords := response.Domains 360 for item := range responseRecords { 361 recordChannel <- responseRecords[item] 362 curRecord += 1 363 if params.Limit != nil && *params.Limit < curRecord { 364 close(recordChannel) 365 close(errorChannel) 366 return 367 } 368 } 369 370 record, err := client.GetNext(c.baseURL, response, c.getNextListSipDomainResponse) 371 if err != nil { 372 errorChannel <- err 373 break 374 } else if record == nil { 375 break 376 } 377 378 response = record.(*ListSipDomainResponse) 379 } 380 381 close(recordChannel) 382 close(errorChannel) 383 } 384 385 func (c *ApiService) getNextListSipDomainResponse(nextPageUrl string) (interface{}, error) { 386 if nextPageUrl == "" { 387 return nil, nil 388 } 389 resp, err := c.requestHandler.Get(nextPageUrl, nil, nil) 390 if err != nil { 391 return nil, err 392 } 393 394 defer resp.Body.Close() 395 396 ps := &ListSipDomainResponse{} 397 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 398 return nil, err 399 } 400 return ps, nil 401 } 402 403 // Optional parameters for the method 'UpdateSipDomain' 404 type UpdateSipDomainParams struct { 405 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the SipDomain resource to update. 406 PathAccountSid *string `json:"PathAccountSid,omitempty"` 407 // A descriptive string that you created to describe the resource. It can be up to 64 characters long. 408 FriendlyName *string `json:"FriendlyName,omitempty"` 409 // The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`. 410 VoiceFallbackMethod *string `json:"VoiceFallbackMethod,omitempty"` 411 // The URL that we should call when an error occurs while retrieving or executing the TwiML requested by `voice_url`. 412 VoiceFallbackUrl *string `json:"VoiceFallbackUrl,omitempty"` 413 // The HTTP method we should use to call `voice_url` 414 VoiceMethod *string `json:"VoiceMethod,omitempty"` 415 // The HTTP method we should use to call `voice_status_callback_url`. Can be: `GET` or `POST`. 416 VoiceStatusCallbackMethod *string `json:"VoiceStatusCallbackMethod,omitempty"` 417 // The URL that we should call to pass status parameters (such as call ended) to your application. 418 VoiceStatusCallbackUrl *string `json:"VoiceStatusCallbackUrl,omitempty"` 419 // The URL we should call when the domain receives a call. 420 VoiceUrl *string `json:"VoiceUrl,omitempty"` 421 // Whether to allow SIP Endpoints to register with the domain to receive calls. Can be `true` or `false`. `true` allows SIP Endpoints to register with the domain to receive calls, `false` does not. 422 SipRegistration *bool `json:"SipRegistration,omitempty"` 423 // The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and \\\"-\\\" and must end with `sip.twilio.com`. 424 DomainName *string `json:"DomainName,omitempty"` 425 // Whether emergency calling is enabled for the domain. If enabled, allows emergency calls on the domain from phone numbers with validated addresses. 426 EmergencyCallingEnabled *bool `json:"EmergencyCallingEnabled,omitempty"` 427 // Whether secure SIP is enabled for the domain. If enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls to this sip domain. 428 Secure *bool `json:"Secure,omitempty"` 429 // The SID of the BYOC Trunk(Bring Your Own Carrier) resource that the Sip Domain will be associated with. 430 ByocTrunkSid *string `json:"ByocTrunkSid,omitempty"` 431 // Whether an emergency caller sid is configured for the domain. If present, this phone number will be used as the callback for the emergency call. 432 EmergencyCallerSid *string `json:"EmergencyCallerSid,omitempty"` 433 } 434 435 func (params *UpdateSipDomainParams) SetPathAccountSid(PathAccountSid string) *UpdateSipDomainParams { 436 params.PathAccountSid = &PathAccountSid 437 return params 438 } 439 func (params *UpdateSipDomainParams) SetFriendlyName(FriendlyName string) *UpdateSipDomainParams { 440 params.FriendlyName = &FriendlyName 441 return params 442 } 443 func (params *UpdateSipDomainParams) SetVoiceFallbackMethod(VoiceFallbackMethod string) *UpdateSipDomainParams { 444 params.VoiceFallbackMethod = &VoiceFallbackMethod 445 return params 446 } 447 func (params *UpdateSipDomainParams) SetVoiceFallbackUrl(VoiceFallbackUrl string) *UpdateSipDomainParams { 448 params.VoiceFallbackUrl = &VoiceFallbackUrl 449 return params 450 } 451 func (params *UpdateSipDomainParams) SetVoiceMethod(VoiceMethod string) *UpdateSipDomainParams { 452 params.VoiceMethod = &VoiceMethod 453 return params 454 } 455 func (params *UpdateSipDomainParams) SetVoiceStatusCallbackMethod(VoiceStatusCallbackMethod string) *UpdateSipDomainParams { 456 params.VoiceStatusCallbackMethod = &VoiceStatusCallbackMethod 457 return params 458 } 459 func (params *UpdateSipDomainParams) SetVoiceStatusCallbackUrl(VoiceStatusCallbackUrl string) *UpdateSipDomainParams { 460 params.VoiceStatusCallbackUrl = &VoiceStatusCallbackUrl 461 return params 462 } 463 func (params *UpdateSipDomainParams) SetVoiceUrl(VoiceUrl string) *UpdateSipDomainParams { 464 params.VoiceUrl = &VoiceUrl 465 return params 466 } 467 func (params *UpdateSipDomainParams) SetSipRegistration(SipRegistration bool) *UpdateSipDomainParams { 468 params.SipRegistration = &SipRegistration 469 return params 470 } 471 func (params *UpdateSipDomainParams) SetDomainName(DomainName string) *UpdateSipDomainParams { 472 params.DomainName = &DomainName 473 return params 474 } 475 func (params *UpdateSipDomainParams) SetEmergencyCallingEnabled(EmergencyCallingEnabled bool) *UpdateSipDomainParams { 476 params.EmergencyCallingEnabled = &EmergencyCallingEnabled 477 return params 478 } 479 func (params *UpdateSipDomainParams) SetSecure(Secure bool) *UpdateSipDomainParams { 480 params.Secure = &Secure 481 return params 482 } 483 func (params *UpdateSipDomainParams) SetByocTrunkSid(ByocTrunkSid string) *UpdateSipDomainParams { 484 params.ByocTrunkSid = &ByocTrunkSid 485 return params 486 } 487 func (params *UpdateSipDomainParams) SetEmergencyCallerSid(EmergencyCallerSid string) *UpdateSipDomainParams { 488 params.EmergencyCallerSid = &EmergencyCallerSid 489 return params 490 } 491 492 // Update the attributes of a domain 493 func (c *ApiService) UpdateSipDomain(Sid string, params *UpdateSipDomainParams) (*ApiV2010SipDomain, error) { 494 path := "/2010-04-01/Accounts/{AccountSid}/SIP/Domains/{Sid}.json" 495 if params != nil && params.PathAccountSid != nil { 496 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 497 } else { 498 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 499 } 500 path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1) 501 502 data := url.Values{} 503 headers := make(map[string]interface{}) 504 505 if params != nil && params.FriendlyName != nil { 506 data.Set("FriendlyName", *params.FriendlyName) 507 } 508 if params != nil && params.VoiceFallbackMethod != nil { 509 data.Set("VoiceFallbackMethod", *params.VoiceFallbackMethod) 510 } 511 if params != nil && params.VoiceFallbackUrl != nil { 512 data.Set("VoiceFallbackUrl", *params.VoiceFallbackUrl) 513 } 514 if params != nil && params.VoiceMethod != nil { 515 data.Set("VoiceMethod", *params.VoiceMethod) 516 } 517 if params != nil && params.VoiceStatusCallbackMethod != nil { 518 data.Set("VoiceStatusCallbackMethod", *params.VoiceStatusCallbackMethod) 519 } 520 if params != nil && params.VoiceStatusCallbackUrl != nil { 521 data.Set("VoiceStatusCallbackUrl", *params.VoiceStatusCallbackUrl) 522 } 523 if params != nil && params.VoiceUrl != nil { 524 data.Set("VoiceUrl", *params.VoiceUrl) 525 } 526 if params != nil && params.SipRegistration != nil { 527 data.Set("SipRegistration", fmt.Sprint(*params.SipRegistration)) 528 } 529 if params != nil && params.DomainName != nil { 530 data.Set("DomainName", *params.DomainName) 531 } 532 if params != nil && params.EmergencyCallingEnabled != nil { 533 data.Set("EmergencyCallingEnabled", fmt.Sprint(*params.EmergencyCallingEnabled)) 534 } 535 if params != nil && params.Secure != nil { 536 data.Set("Secure", fmt.Sprint(*params.Secure)) 537 } 538 if params != nil && params.ByocTrunkSid != nil { 539 data.Set("ByocTrunkSid", *params.ByocTrunkSid) 540 } 541 if params != nil && params.EmergencyCallerSid != nil { 542 data.Set("EmergencyCallerSid", *params.EmergencyCallerSid) 543 } 544 545 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 546 if err != nil { 547 return nil, err 548 } 549 550 defer resp.Body.Close() 551 552 ps := &ApiV2010SipDomain{} 553 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 554 return nil, err 555 } 556 557 return ps, err 558 }