github.com/twilio/twilio-go@v1.20.1/rest/pricing/v2/voice_numbers.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Pricing 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 // Optional parameters for the method 'FetchVoiceNumber' 24 type FetchVoiceNumberParams struct { 25 // The origination phone number, in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, for which to fetch the origin-based voice pricing information. E.164 format consists of a + followed by the country code and subscriber number. 26 OriginationNumber *string `json:"OriginationNumber,omitempty"` 27 } 28 29 func (params *FetchVoiceNumberParams) SetOriginationNumber(OriginationNumber string) *FetchVoiceNumberParams { 30 params.OriginationNumber = &OriginationNumber 31 return params 32 } 33 34 // Fetch pricing information for a specific destination and, optionally, origination phone number. 35 func (c *ApiService) FetchVoiceNumber(DestinationNumber string, params *FetchVoiceNumberParams) (*PricingV2VoiceNumber, error) { 36 path := "/v2/Voice/Numbers/{DestinationNumber}" 37 path = strings.Replace(path, "{"+"DestinationNumber"+"}", DestinationNumber, -1) 38 39 data := url.Values{} 40 headers := make(map[string]interface{}) 41 42 if params != nil && params.OriginationNumber != nil { 43 data.Set("OriginationNumber", *params.OriginationNumber) 44 } 45 46 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 47 if err != nil { 48 return nil, err 49 } 50 51 defer resp.Body.Close() 52 53 ps := &PricingV2VoiceNumber{} 54 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 55 return nil, err 56 } 57 58 return ps, err 59 }