|
| 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 'CreateBulkConsents' |
| 23 | +type CreateBulkConsentsParams struct { |
| 24 | + // This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; and `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]. |
| 25 | + Items *[]interface{} `json:"Items,omitempty"` |
| 26 | +} |
| 27 | + |
| 28 | +func (params *CreateBulkConsentsParams) SetItems(Items []interface{}) *CreateBulkConsentsParams { |
| 29 | + params.Items = &Items |
| 30 | + return params |
| 31 | +} |
| 32 | + |
| 33 | +// |
| 34 | +func (c *ApiService) CreateBulkConsents(params *CreateBulkConsentsParams) (*AccountsV1BulkConsents, error) { |
| 35 | + path := "/v1/Consents/Bulk" |
| 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.Items != nil { |
| 43 | + for _, item := range *params.Items { |
| 44 | + v, err := json.Marshal(item) |
| 45 | + |
| 46 | + if err != nil { |
| 47 | + return nil, err |
| 48 | + } |
| 49 | + |
| 50 | + data.Add("Items", string(v)) |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) |
| 55 | + if err != nil { |
| 56 | + return nil, err |
| 57 | + } |
| 58 | + |
| 59 | + defer resp.Body.Close() |
| 60 | + |
| 61 | + ps := &AccountsV1BulkConsents{} |
| 62 | + if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { |
| 63 | + return nil, err |
| 64 | + } |
| 65 | + |
| 66 | + return ps, err |
| 67 | +} |
0 commit comments