|
| 1 | +/* |
| 2 | + * This code was generated by |
| 3 | + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ |
| 4 | + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ |
| 5 | + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ |
| 6 | + * |
| 7 | + * Twilio - Accounts |
| 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 'FetchMessagingGeopermissions' |
| 23 | +type FetchMessagingGeopermissionsParams struct { |
| 24 | + // The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned. |
| 25 | + CountryCode *string `json:"CountryCode,omitempty"` |
| 26 | +} |
| 27 | + |
| 28 | +func (params *FetchMessagingGeopermissionsParams) SetCountryCode(CountryCode string) *FetchMessagingGeopermissionsParams { |
| 29 | + params.CountryCode = &CountryCode |
| 30 | + return params |
| 31 | +} |
| 32 | + |
| 33 | +// |
| 34 | +func (c *ApiService) FetchMessagingGeopermissions(params *FetchMessagingGeopermissionsParams) (*AccountsV1MessagingGeopermissions, error) { |
| 35 | + path := "/v1/Messaging/GeoPermissions" |
| 36 | + |
| 37 | + data := url.Values{} |
| 38 | + headers := map[string]interface{}{ |
| 39 | + "Content-Type": "application/x-www-form-urlencoded", |
| 40 | + } |
| 41 | + |
| 42 | + if params != nil && params.CountryCode != nil { |
| 43 | + data.Set("CountryCode", *params.CountryCode) |
| 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 := &AccountsV1MessagingGeopermissions{} |
| 54 | + if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { |
| 55 | + return nil, err |
| 56 | + } |
| 57 | + |
| 58 | + return ps, err |
| 59 | +} |
| 60 | + |
| 61 | +// Optional parameters for the method 'UpdateMessagingGeopermissions' |
| 62 | +type UpdateMessagingGeopermissionsParams struct { |
| 63 | + // A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission. |
| 64 | + Permissions *[]interface{} `json:"Permissions,omitempty"` |
| 65 | +} |
| 66 | + |
| 67 | +func (params *UpdateMessagingGeopermissionsParams) SetPermissions(Permissions []interface{}) *UpdateMessagingGeopermissionsParams { |
| 68 | + params.Permissions = &Permissions |
| 69 | + return params |
| 70 | +} |
| 71 | + |
| 72 | +// |
| 73 | +func (c *ApiService) UpdateMessagingGeopermissions(params *UpdateMessagingGeopermissionsParams) (*AccountsV1MessagingGeopermissions, error) { |
| 74 | + path := "/v1/Messaging/GeoPermissions" |
| 75 | + |
| 76 | + data := url.Values{} |
| 77 | + headers := map[string]interface{}{ |
| 78 | + "Content-Type": "application/x-www-form-urlencoded", |
| 79 | + } |
| 80 | + |
| 81 | + if params != nil && params.Permissions != nil { |
| 82 | + for _, item := range *params.Permissions { |
| 83 | + v, err := json.Marshal(item) |
| 84 | + |
| 85 | + if err != nil { |
| 86 | + return nil, err |
| 87 | + } |
| 88 | + |
| 89 | + data.Add("Permissions", string(v)) |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + resp, err := c.requestHandler.Patch(c.baseURL+path, data, headers) |
| 94 | + if err != nil { |
| 95 | + return nil, err |
| 96 | + } |
| 97 | + |
| 98 | + defer resp.Body.Close() |
| 99 | + |
| 100 | + ps := &AccountsV1MessagingGeopermissions{} |
| 101 | + if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { |
| 102 | + return nil, err |
| 103 | + } |
| 104 | + |
| 105 | + return ps, err |
| 106 | +} |
0 commit comments