|
| 1 | +/* |
| 2 | + * This code was generated by |
| 3 | + * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ |
| 4 | + * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ |
| 5 | + * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ |
| 6 | + * |
| 7 | + * Twilio - Conversations |
| 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 | + "fmt" |
| 20 | + "net/url" |
| 21 | + "time" |
| 22 | +) |
| 23 | + |
| 24 | +// Optional parameters for the method 'CreateConversationWithParticipants' |
| 25 | +type CreateConversationWithParticipantsParams struct { |
| 26 | + // The X-Twilio-Webhook-Enabled HTTP request header |
| 27 | + XTwilioWebhookEnabled *string `json:"X-Twilio-Webhook-Enabled,omitempty"` |
| 28 | + // The human-readable name of this conversation, limited to 256 characters. Optional. |
| 29 | + FriendlyName *string `json:"FriendlyName,omitempty"` |
| 30 | + // An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. |
| 31 | + UniqueName *string `json:"UniqueName,omitempty"` |
| 32 | + // The date that this resource was created. |
| 33 | + DateCreated *time.Time `json:"DateCreated,omitempty"` |
| 34 | + // The date that this resource was last updated. |
| 35 | + DateUpdated *time.Time `json:"DateUpdated,omitempty"` |
| 36 | + // The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. |
| 37 | + MessagingServiceSid *string `json:"MessagingServiceSid,omitempty"` |
| 38 | + // An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set \\\"{}\\\" will be returned. |
| 39 | + Attributes *string `json:"Attributes,omitempty"` |
| 40 | + // |
| 41 | + State *string `json:"State,omitempty"` |
| 42 | + // ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. |
| 43 | + TimersInactive *string `json:"Timers.Inactive,omitempty"` |
| 44 | + // ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. |
| 45 | + TimersClosed *string `json:"Timers.Closed,omitempty"` |
| 46 | + // The default email address that will be used when sending outbound emails in this conversation. |
| 47 | + BindingsEmailAddress *string `json:"Bindings.Email.Address,omitempty"` |
| 48 | + // The default name that will be used when sending outbound emails in this conversation. |
| 49 | + BindingsEmailName *string `json:"Bindings.Email.Name,omitempty"` |
| 50 | + // The participant to be added to the conversation in JSON format. The parameters are as in [Participant Resource](https://www.twilio.com/docs/conversations/api/conversation-participant-resource). The maximum number of participants that can be added in a single request is 10. |
| 51 | + Participant *[]string `json:"Participant,omitempty"` |
| 52 | +} |
| 53 | + |
| 54 | +func (params *CreateConversationWithParticipantsParams) SetXTwilioWebhookEnabled(XTwilioWebhookEnabled string) *CreateConversationWithParticipantsParams { |
| 55 | + params.XTwilioWebhookEnabled = &XTwilioWebhookEnabled |
| 56 | + return params |
| 57 | +} |
| 58 | +func (params *CreateConversationWithParticipantsParams) SetFriendlyName(FriendlyName string) *CreateConversationWithParticipantsParams { |
| 59 | + params.FriendlyName = &FriendlyName |
| 60 | + return params |
| 61 | +} |
| 62 | +func (params *CreateConversationWithParticipantsParams) SetUniqueName(UniqueName string) *CreateConversationWithParticipantsParams { |
| 63 | + params.UniqueName = &UniqueName |
| 64 | + return params |
| 65 | +} |
| 66 | +func (params *CreateConversationWithParticipantsParams) SetDateCreated(DateCreated time.Time) *CreateConversationWithParticipantsParams { |
| 67 | + params.DateCreated = &DateCreated |
| 68 | + return params |
| 69 | +} |
| 70 | +func (params *CreateConversationWithParticipantsParams) SetDateUpdated(DateUpdated time.Time) *CreateConversationWithParticipantsParams { |
| 71 | + params.DateUpdated = &DateUpdated |
| 72 | + return params |
| 73 | +} |
| 74 | +func (params *CreateConversationWithParticipantsParams) SetMessagingServiceSid(MessagingServiceSid string) *CreateConversationWithParticipantsParams { |
| 75 | + params.MessagingServiceSid = &MessagingServiceSid |
| 76 | + return params |
| 77 | +} |
| 78 | +func (params *CreateConversationWithParticipantsParams) SetAttributes(Attributes string) *CreateConversationWithParticipantsParams { |
| 79 | + params.Attributes = &Attributes |
| 80 | + return params |
| 81 | +} |
| 82 | +func (params *CreateConversationWithParticipantsParams) SetState(State string) *CreateConversationWithParticipantsParams { |
| 83 | + params.State = &State |
| 84 | + return params |
| 85 | +} |
| 86 | +func (params *CreateConversationWithParticipantsParams) SetTimersInactive(TimersInactive string) *CreateConversationWithParticipantsParams { |
| 87 | + params.TimersInactive = &TimersInactive |
| 88 | + return params |
| 89 | +} |
| 90 | +func (params *CreateConversationWithParticipantsParams) SetTimersClosed(TimersClosed string) *CreateConversationWithParticipantsParams { |
| 91 | + params.TimersClosed = &TimersClosed |
| 92 | + return params |
| 93 | +} |
| 94 | +func (params *CreateConversationWithParticipantsParams) SetBindingsEmailAddress(BindingsEmailAddress string) *CreateConversationWithParticipantsParams { |
| 95 | + params.BindingsEmailAddress = &BindingsEmailAddress |
| 96 | + return params |
| 97 | +} |
| 98 | +func (params *CreateConversationWithParticipantsParams) SetBindingsEmailName(BindingsEmailName string) *CreateConversationWithParticipantsParams { |
| 99 | + params.BindingsEmailName = &BindingsEmailName |
| 100 | + return params |
| 101 | +} |
| 102 | +func (params *CreateConversationWithParticipantsParams) SetParticipant(Participant []string) *CreateConversationWithParticipantsParams { |
| 103 | + params.Participant = &Participant |
| 104 | + return params |
| 105 | +} |
| 106 | + |
| 107 | +// Create a new conversation with the list of participants in your account's default service |
| 108 | +func (c *ApiService) CreateConversationWithParticipants(params *CreateConversationWithParticipantsParams) (*ConversationsV1ConversationWithParticipants, error) { |
| 109 | + path := "/v1/ConversationWithParticipants" |
| 110 | + |
| 111 | + data := url.Values{} |
| 112 | + headers := map[string]interface{}{ |
| 113 | + "Content-Type": "application/x-www-form-urlencoded", |
| 114 | + } |
| 115 | + |
| 116 | + if params != nil && params.FriendlyName != nil { |
| 117 | + data.Set("FriendlyName", *params.FriendlyName) |
| 118 | + } |
| 119 | + if params != nil && params.UniqueName != nil { |
| 120 | + data.Set("UniqueName", *params.UniqueName) |
| 121 | + } |
| 122 | + if params != nil && params.DateCreated != nil { |
| 123 | + data.Set("DateCreated", fmt.Sprint((*params.DateCreated).Format(time.RFC3339))) |
| 124 | + } |
| 125 | + if params != nil && params.DateUpdated != nil { |
| 126 | + data.Set("DateUpdated", fmt.Sprint((*params.DateUpdated).Format(time.RFC3339))) |
| 127 | + } |
| 128 | + if params != nil && params.MessagingServiceSid != nil { |
| 129 | + data.Set("MessagingServiceSid", *params.MessagingServiceSid) |
| 130 | + } |
| 131 | + if params != nil && params.Attributes != nil { |
| 132 | + data.Set("Attributes", *params.Attributes) |
| 133 | + } |
| 134 | + if params != nil && params.State != nil { |
| 135 | + data.Set("State", *params.State) |
| 136 | + } |
| 137 | + if params != nil && params.TimersInactive != nil { |
| 138 | + data.Set("Timers.Inactive", *params.TimersInactive) |
| 139 | + } |
| 140 | + if params != nil && params.TimersClosed != nil { |
| 141 | + data.Set("Timers.Closed", *params.TimersClosed) |
| 142 | + } |
| 143 | + if params != nil && params.BindingsEmailAddress != nil { |
| 144 | + data.Set("Bindings.Email.Address", *params.BindingsEmailAddress) |
| 145 | + } |
| 146 | + if params != nil && params.BindingsEmailName != nil { |
| 147 | + data.Set("Bindings.Email.Name", *params.BindingsEmailName) |
| 148 | + } |
| 149 | + if params != nil && params.Participant != nil { |
| 150 | + for _, item := range *params.Participant { |
| 151 | + data.Add("Participant", item) |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | + if params != nil && params.XTwilioWebhookEnabled != nil { |
| 156 | + headers["X-Twilio-Webhook-Enabled"] = *params.XTwilioWebhookEnabled |
| 157 | + } |
| 158 | + resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) |
| 159 | + if err != nil { |
| 160 | + return nil, err |
| 161 | + } |
| 162 | + |
| 163 | + defer resp.Body.Close() |
| 164 | + |
| 165 | + ps := &ConversationsV1ConversationWithParticipants{} |
| 166 | + if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { |
| 167 | + return nil, err |
| 168 | + } |
| 169 | + |
| 170 | + return ps, err |
| 171 | +} |
0 commit comments