github.com/twilio/twilio-go@v1.20.1/rest/numbers/v1/hosted_number_eligibility.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 ) 21 22 // Optional parameters for the method 'CreateEligibility' 23 type CreateEligibilityParams struct { 24 // 25 Body *map[string]interface{} `json:"body,omitempty"` 26 } 27 28 func (params *CreateEligibilityParams) SetBody(Body map[string]interface{}) *CreateEligibilityParams { 29 params.Body = &Body 30 return params 31 } 32 33 // Create an eligibility check for a number that you want to host in Twilio. 34 func (c *ApiService) CreateEligibility(params *CreateEligibilityParams) (*NumbersV1Eligibility, error) { 35 path := "/v1/HostedNumber/Eligibility" 36 37 data := url.Values{} 38 headers := map[string]interface{}{ 39 "Content-Type": "application/json", 40 } 41 42 body := []byte{} 43 if params != nil && params.Body != nil { 44 b, err := json.Marshal(*params.Body) 45 if err != nil { 46 return nil, err 47 } 48 body = b 49 } 50 51 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers, body...) 52 if err != nil { 53 return nil, err 54 } 55 56 defer resp.Body.Close() 57 58 ps := &NumbersV1Eligibility{} 59 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 60 return nil, err 61 } 62 63 return ps, err 64 }