github.com/twilio/twilio-go@v1.20.1/rest/routes/v2/phone_numbers.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Routes 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 "net/url" 20 "strings" 21 ) 22 23 // Fetch the Inbound Processing Region assigned to a phone number. 24 func (c *ApiService) FetchPhoneNumber(PhoneNumber string) (*RoutesV2PhoneNumber, error) { 25 path := "/v2/PhoneNumbers/{PhoneNumber}" 26 path = strings.Replace(path, "{"+"PhoneNumber"+"}", PhoneNumber, -1) 27 28 data := url.Values{} 29 headers := make(map[string]interface{}) 30 31 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 32 if err != nil { 33 return nil, err 34 } 35 36 defer resp.Body.Close() 37 38 ps := &RoutesV2PhoneNumber{} 39 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 40 return nil, err 41 } 42 43 return ps, err 44 } 45 46 // Optional parameters for the method 'UpdatePhoneNumber' 47 type UpdatePhoneNumberParams struct { 48 // The Inbound Processing Region used for this phone number for voice 49 VoiceRegion *string `json:"VoiceRegion,omitempty"` 50 // A human readable description of this resource, up to 64 characters. 51 FriendlyName *string `json:"FriendlyName,omitempty"` 52 } 53 54 func (params *UpdatePhoneNumberParams) SetVoiceRegion(VoiceRegion string) *UpdatePhoneNumberParams { 55 params.VoiceRegion = &VoiceRegion 56 return params 57 } 58 func (params *UpdatePhoneNumberParams) SetFriendlyName(FriendlyName string) *UpdatePhoneNumberParams { 59 params.FriendlyName = &FriendlyName 60 return params 61 } 62 63 // Assign an Inbound Processing Region to a phone number. 64 func (c *ApiService) UpdatePhoneNumber(PhoneNumber string, params *UpdatePhoneNumberParams) (*RoutesV2PhoneNumber, error) { 65 path := "/v2/PhoneNumbers/{PhoneNumber}" 66 path = strings.Replace(path, "{"+"PhoneNumber"+"}", PhoneNumber, -1) 67 68 data := url.Values{} 69 headers := make(map[string]interface{}) 70 71 if params != nil && params.VoiceRegion != nil { 72 data.Set("VoiceRegion", *params.VoiceRegion) 73 } 74 if params != nil && params.FriendlyName != nil { 75 data.Set("FriendlyName", *params.FriendlyName) 76 } 77 78 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 79 if err != nil { 80 return nil, err 81 } 82 83 defer resp.Body.Close() 84 85 ps := &RoutesV2PhoneNumber{} 86 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 87 return nil, err 88 } 89 90 return ps, err 91 }