github.com/twilio/twilio-go@v1.20.1/rest/numbers/v1/porting_portability.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Numbers 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 'CreatePortingBulkPortability' 24 type CreatePortingBulkPortabilityParams struct { 25 // The phone numbers which portability is to be checked. This should be a list of strings. Phone numbers are in E.164 format (e.g. +16175551212). . 26 PhoneNumbers *[]string `json:"PhoneNumbers,omitempty"` 27 } 28 29 func (params *CreatePortingBulkPortabilityParams) SetPhoneNumbers(PhoneNumbers []string) *CreatePortingBulkPortabilityParams { 30 params.PhoneNumbers = &PhoneNumbers 31 return params 32 } 33 34 // Allows to check if a list of phone numbers can be ported to Twilio or not. This is done asynchronous for each phone number. 35 func (c *ApiService) CreatePortingBulkPortability(params *CreatePortingBulkPortabilityParams) (*NumbersV1PortingBulkPortability, error) { 36 path := "/v1/Porting/Portability" 37 38 data := url.Values{} 39 headers := make(map[string]interface{}) 40 41 if params != nil && params.PhoneNumbers != nil { 42 for _, item := range *params.PhoneNumbers { 43 data.Add("PhoneNumbers", item) 44 } 45 } 46 47 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 48 if err != nil { 49 return nil, err 50 } 51 52 defer resp.Body.Close() 53 54 ps := &NumbersV1PortingBulkPortability{} 55 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 56 return nil, err 57 } 58 59 return ps, err 60 } 61 62 // Fetch a previous portability check. This should return the current status of the validation and the result for all the numbers provided, given that they have been validated (as this process is performed asynchronously). 63 func (c *ApiService) FetchPortingBulkPortability(Sid string) (*NumbersV1PortingBulkPortability, error) { 64 path := "/v1/Porting/Portability/{Sid}" 65 path = strings.Replace(path, "{"+"Sid"+"}", Sid, -1) 66 67 data := url.Values{} 68 headers := make(map[string]interface{}) 69 70 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 71 if err != nil { 72 return nil, err 73 } 74 75 defer resp.Body.Close() 76 77 ps := &NumbersV1PortingBulkPortability{} 78 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 79 return nil, err 80 } 81 82 return ps, err 83 }