github.com/twilio/twilio-go@v1.20.1/rest/numbers/v1/porting_port_in.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 'CreatePortingPortIn' 24 type CreatePortingPortInParams struct { 25 // 26 Body *map[string]interface{} `json:"body,omitempty"` 27 } 28 29 func (params *CreatePortingPortInParams) SetBody(Body map[string]interface{}) *CreatePortingPortInParams { 30 params.Body = &Body 31 return params 32 } 33 34 // Allows to create a new port in request 35 func (c *ApiService) CreatePortingPortIn(params *CreatePortingPortInParams) (*NumbersV1PortingPortIn, error) { 36 path := "/v1/Porting/PortIn" 37 38 data := url.Values{} 39 headers := map[string]interface{}{ 40 "Content-Type": "application/json", 41 } 42 43 body := []byte{} 44 if params != nil && params.Body != nil { 45 b, err := json.Marshal(*params.Body) 46 if err != nil { 47 return nil, err 48 } 49 body = b 50 } 51 52 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers, body...) 53 if err != nil { 54 return nil, err 55 } 56 57 defer resp.Body.Close() 58 59 ps := &NumbersV1PortingPortIn{} 60 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 61 return nil, err 62 } 63 64 return ps, err 65 } 66 67 // Allows to cancel a port in request by SID 68 func (c *ApiService) DeletePortingPortIn(PortInRequestSid string) error { 69 path := "/v1/Porting/PortIn/{PortInRequestSid}" 70 path = strings.Replace(path, "{"+"PortInRequestSid"+"}", PortInRequestSid, -1) 71 72 data := url.Values{} 73 headers := make(map[string]interface{}) 74 75 resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers) 76 if err != nil { 77 return err 78 } 79 80 defer resp.Body.Close() 81 82 return nil 83 } 84 85 // Fetch a port in request by SID 86 func (c *ApiService) FetchPortingPortInFetch(PortInRequestSid string) (*NumbersV1PortingPortInFetch, error) { 87 path := "/v1/Porting/PortIn/{PortInRequestSid}" 88 path = strings.Replace(path, "{"+"PortInRequestSid"+"}", PortInRequestSid, -1) 89 90 data := url.Values{} 91 headers := make(map[string]interface{}) 92 93 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 94 if err != nil { 95 return nil, err 96 } 97 98 defer resp.Body.Close() 99 100 ps := &NumbersV1PortingPortInFetch{} 101 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 102 return nil, err 103 } 104 105 return ps, err 106 }