|
| 1 | +r""" |
| 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 | +from datetime import datetime |
| 16 | +from typing import Any, Dict, List, Optional, Union |
| 17 | +from twilio.base import deserialize, serialize, values |
| 18 | + |
| 19 | +from twilio.base.instance_resource import InstanceResource |
| 20 | +from twilio.base.list_resource import ListResource |
| 21 | +from twilio.base.version import Version |
| 22 | + |
| 23 | + |
| 24 | +class ConversationWithParticipantsInstance(InstanceResource): |
| 25 | + |
| 26 | + class State(object): |
| 27 | + INACTIVE = "inactive" |
| 28 | + ACTIVE = "active" |
| 29 | + CLOSED = "closed" |
| 30 | + |
| 31 | + class WebhookEnabledType(object): |
| 32 | + TRUE = "true" |
| 33 | + FALSE = "false" |
| 34 | + |
| 35 | + """ |
| 36 | + :ivar account_sid: The unique ID of the [Account](https://www.twilio.com/docs/iam/api/account) responsible for this conversation. |
| 37 | + :ivar chat_service_sid: The unique ID of the [Conversation Service](https://www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to. |
| 38 | + :ivar messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. |
| 39 | + :ivar sid: A 34 character string that uniquely identifies this resource. |
| 40 | + :ivar friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. |
| 41 | + :ivar unique_name: 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. |
| 42 | + :ivar attributes: 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. |
| 43 | + :ivar state: |
| 44 | + :ivar date_created: The date that this resource was created. |
| 45 | + :ivar date_updated: The date that this resource was last updated. |
| 46 | + :ivar timers: Timer date values representing state update for this conversation. |
| 47 | + :ivar links: Contains absolute URLs to access the [participants](https://www.twilio.com/docs/conversations/api/conversation-participant-resource), [messages](https://www.twilio.com/docs/conversations/api/conversation-message-resource) and [webhooks](https://www.twilio.com/docs/conversations/api/conversation-scoped-webhook-resource) of this conversation. |
| 48 | + :ivar bindings: |
| 49 | + :ivar url: An absolute API resource URL for this conversation. |
| 50 | + """ |
| 51 | + |
| 52 | + def __init__(self, version: Version, payload: Dict[str, Any]): |
| 53 | + super().__init__(version) |
| 54 | + |
| 55 | + self.account_sid: Optional[str] = payload.get("account_sid") |
| 56 | + self.chat_service_sid: Optional[str] = payload.get("chat_service_sid") |
| 57 | + self.messaging_service_sid: Optional[str] = payload.get("messaging_service_sid") |
| 58 | + self.sid: Optional[str] = payload.get("sid") |
| 59 | + self.friendly_name: Optional[str] = payload.get("friendly_name") |
| 60 | + self.unique_name: Optional[str] = payload.get("unique_name") |
| 61 | + self.attributes: Optional[str] = payload.get("attributes") |
| 62 | + self.state: Optional["ConversationWithParticipantsInstance.State"] = ( |
| 63 | + payload.get("state") |
| 64 | + ) |
| 65 | + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( |
| 66 | + payload.get("date_created") |
| 67 | + ) |
| 68 | + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( |
| 69 | + payload.get("date_updated") |
| 70 | + ) |
| 71 | + self.timers: Optional[Dict[str, object]] = payload.get("timers") |
| 72 | + self.links: Optional[Dict[str, object]] = payload.get("links") |
| 73 | + self.bindings: Optional[Dict[str, object]] = payload.get("bindings") |
| 74 | + self.url: Optional[str] = payload.get("url") |
| 75 | + |
| 76 | + def __repr__(self) -> str: |
| 77 | + """ |
| 78 | + Provide a friendly representation |
| 79 | +
|
| 80 | + :returns: Machine friendly representation |
| 81 | + """ |
| 82 | + |
| 83 | + return "<Twilio.Conversations.V1.ConversationWithParticipantsInstance>" |
| 84 | + |
| 85 | + |
| 86 | +class ConversationWithParticipantsList(ListResource): |
| 87 | + |
| 88 | + def __init__(self, version: Version): |
| 89 | + """ |
| 90 | + Initialize the ConversationWithParticipantsList |
| 91 | +
|
| 92 | + :param version: Version that contains the resource |
| 93 | +
|
| 94 | + """ |
| 95 | + super().__init__(version) |
| 96 | + |
| 97 | + self._uri = "/ConversationWithParticipants" |
| 98 | + |
| 99 | + def create( |
| 100 | + self, |
| 101 | + x_twilio_webhook_enabled: Union[ |
| 102 | + "ConversationWithParticipantsInstance.WebhookEnabledType", object |
| 103 | + ] = values.unset, |
| 104 | + friendly_name: Union[str, object] = values.unset, |
| 105 | + unique_name: Union[str, object] = values.unset, |
| 106 | + date_created: Union[datetime, object] = values.unset, |
| 107 | + date_updated: Union[datetime, object] = values.unset, |
| 108 | + messaging_service_sid: Union[str, object] = values.unset, |
| 109 | + attributes: Union[str, object] = values.unset, |
| 110 | + state: Union[ |
| 111 | + "ConversationWithParticipantsInstance.State", object |
| 112 | + ] = values.unset, |
| 113 | + timers_inactive: Union[str, object] = values.unset, |
| 114 | + timers_closed: Union[str, object] = values.unset, |
| 115 | + bindings_email_address: Union[str, object] = values.unset, |
| 116 | + bindings_email_name: Union[str, object] = values.unset, |
| 117 | + participant: Union[List[str], object] = values.unset, |
| 118 | + ) -> ConversationWithParticipantsInstance: |
| 119 | + """ |
| 120 | + Create the ConversationWithParticipantsInstance |
| 121 | +
|
| 122 | + :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header |
| 123 | + :param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. |
| 124 | + :param unique_name: 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. |
| 125 | + :param date_created: The date that this resource was created. |
| 126 | + :param date_updated: The date that this resource was last updated. |
| 127 | + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. |
| 128 | + :param attributes: 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. |
| 129 | + :param state: |
| 130 | + :param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. |
| 131 | + :param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. |
| 132 | + :param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation. |
| 133 | + :param bindings_email_name: The default name that will be used when sending outbound emails in this conversation. |
| 134 | + :param participant: 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. |
| 135 | +
|
| 136 | + :returns: The created ConversationWithParticipantsInstance |
| 137 | + """ |
| 138 | + |
| 139 | + data = values.of( |
| 140 | + { |
| 141 | + "FriendlyName": friendly_name, |
| 142 | + "UniqueName": unique_name, |
| 143 | + "DateCreated": serialize.iso8601_datetime(date_created), |
| 144 | + "DateUpdated": serialize.iso8601_datetime(date_updated), |
| 145 | + "MessagingServiceSid": messaging_service_sid, |
| 146 | + "Attributes": attributes, |
| 147 | + "State": state, |
| 148 | + "Timers.Inactive": timers_inactive, |
| 149 | + "Timers.Closed": timers_closed, |
| 150 | + "Bindings.Email.Address": bindings_email_address, |
| 151 | + "Bindings.Email.Name": bindings_email_name, |
| 152 | + "Participant": serialize.map(participant, lambda e: e), |
| 153 | + } |
| 154 | + ) |
| 155 | + headers = values.of( |
| 156 | + { |
| 157 | + "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, |
| 158 | + "Content-Type": "application/x-www-form-urlencoded", |
| 159 | + } |
| 160 | + ) |
| 161 | + |
| 162 | + payload = self._version.create( |
| 163 | + method="POST", uri=self._uri, data=data, headers=headers |
| 164 | + ) |
| 165 | + |
| 166 | + return ConversationWithParticipantsInstance(self._version, payload) |
| 167 | + |
| 168 | + async def create_async( |
| 169 | + self, |
| 170 | + x_twilio_webhook_enabled: Union[ |
| 171 | + "ConversationWithParticipantsInstance.WebhookEnabledType", object |
| 172 | + ] = values.unset, |
| 173 | + friendly_name: Union[str, object] = values.unset, |
| 174 | + unique_name: Union[str, object] = values.unset, |
| 175 | + date_created: Union[datetime, object] = values.unset, |
| 176 | + date_updated: Union[datetime, object] = values.unset, |
| 177 | + messaging_service_sid: Union[str, object] = values.unset, |
| 178 | + attributes: Union[str, object] = values.unset, |
| 179 | + state: Union[ |
| 180 | + "ConversationWithParticipantsInstance.State", object |
| 181 | + ] = values.unset, |
| 182 | + timers_inactive: Union[str, object] = values.unset, |
| 183 | + timers_closed: Union[str, object] = values.unset, |
| 184 | + bindings_email_address: Union[str, object] = values.unset, |
| 185 | + bindings_email_name: Union[str, object] = values.unset, |
| 186 | + participant: Union[List[str], object] = values.unset, |
| 187 | + ) -> ConversationWithParticipantsInstance: |
| 188 | + """ |
| 189 | + Asynchronously create the ConversationWithParticipantsInstance |
| 190 | +
|
| 191 | + :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header |
| 192 | + :param friendly_name: The human-readable name of this conversation, limited to 256 characters. Optional. |
| 193 | + :param unique_name: 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. |
| 194 | + :param date_created: The date that this resource was created. |
| 195 | + :param date_updated: The date that this resource was last updated. |
| 196 | + :param messaging_service_sid: The unique ID of the [Messaging Service](https://www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to. |
| 197 | + :param attributes: 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. |
| 198 | + :param state: |
| 199 | + :param timers_inactive: ISO8601 duration when conversation will be switched to `inactive` state. Minimum value for this timer is 1 minute. |
| 200 | + :param timers_closed: ISO8601 duration when conversation will be switched to `closed` state. Minimum value for this timer is 10 minutes. |
| 201 | + :param bindings_email_address: The default email address that will be used when sending outbound emails in this conversation. |
| 202 | + :param bindings_email_name: The default name that will be used when sending outbound emails in this conversation. |
| 203 | + :param participant: 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. |
| 204 | +
|
| 205 | + :returns: The created ConversationWithParticipantsInstance |
| 206 | + """ |
| 207 | + |
| 208 | + data = values.of( |
| 209 | + { |
| 210 | + "FriendlyName": friendly_name, |
| 211 | + "UniqueName": unique_name, |
| 212 | + "DateCreated": serialize.iso8601_datetime(date_created), |
| 213 | + "DateUpdated": serialize.iso8601_datetime(date_updated), |
| 214 | + "MessagingServiceSid": messaging_service_sid, |
| 215 | + "Attributes": attributes, |
| 216 | + "State": state, |
| 217 | + "Timers.Inactive": timers_inactive, |
| 218 | + "Timers.Closed": timers_closed, |
| 219 | + "Bindings.Email.Address": bindings_email_address, |
| 220 | + "Bindings.Email.Name": bindings_email_name, |
| 221 | + "Participant": serialize.map(participant, lambda e: e), |
| 222 | + } |
| 223 | + ) |
| 224 | + headers = values.of( |
| 225 | + { |
| 226 | + "X-Twilio-Webhook-Enabled": x_twilio_webhook_enabled, |
| 227 | + "Content-Type": "application/x-www-form-urlencoded", |
| 228 | + } |
| 229 | + ) |
| 230 | + |
| 231 | + payload = await self._version.create_async( |
| 232 | + method="POST", uri=self._uri, data=data, headers=headers |
| 233 | + ) |
| 234 | + |
| 235 | + return ConversationWithParticipantsInstance(self._version, payload) |
| 236 | + |
| 237 | + def __repr__(self) -> str: |
| 238 | + """ |
| 239 | + Provide a friendly representation |
| 240 | +
|
| 241 | + :returns: Machine friendly representation |
| 242 | + """ |
| 243 | + return "<Twilio.Conversations.V1.ConversationWithParticipantsList>" |
0 commit comments