1+ """
2+ # Conversation API Models
3+
4+ `apis/Conversation/models.py`
5+
6+ This module contains models used to interact with the Intercom Conversation API [1].
7+ These models provide object oriented interfaces for the schemas defined in `apis/Conversation/schemas.py`.
8+
9+ ---
10+ - [1] https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Conversations/conversation/
11+ """
12+
13+ """
14+ {
15+ "type": "conversation",
16+ "id": "1295",
17+ "title": "Conversation Title",
18+ "created_at": 1663597223,
19+ "updated_at": 1663597260,
20+ "waiting_since": 1663597260,
21+ "snoozed_until": 1663597260,
22+ "open": true,
23+ "state": "open",
24+ "read": true,
25+ "priority": "priority",
26+ "admin_assignee_id": 0,
27+ "team_assignee_id": "5017691",
28+ "tags": {
29+ "type": "tag.list",
30+ "tags": [
31+ {
32+ "type": "tag",
33+ "id": "123456",
34+ "name": "Test tag",
35+ "applied_at": 1663597223,
36+ "applied_by": {
37+ "type": "contact",
38+ "id": "1a2b3c"
39+ }
40+ }
41+ ]
42+ },
43+ "conversation_rating": {
44+ "rating": 5,
45+ "remark": "",
46+ "created_at": 1671028894,
47+ "contact": {
48+ "type": "contact",
49+ "id": "5ba682d23d7cf92bef87bfd4",
50+ "external_id": "f3b87a2e09d514c6c2e79b9a"
51+ },
52+ "teammate": {
53+ "type": "contact",
54+ "id": "1a2b3c"
55+ }
56+ },
57+ "source": {
58+ "type": "conversation",
59+ "id": "3",
60+ "delivered_as": "operator_initiated",
61+ "subject": "",
62+ "body": "<p>Hey there!</p>",
63+ "author": {
64+ "type": "admin",
65+ "id": "274",
66+ "name": "Operator",
67+ "email": "operator+abcd1234@intercom.io"
68+ },
69+ "attachments": [
70+ {
71+ "type": "upload",
72+ "name": "example.png",
73+ "url": "https://picsum.photos/200/300",
74+ "content_type": "image/png",
75+ "filesize": 100,
76+ "width": 100,
77+ "height": 100
78+ }
79+ ],
80+ "url": null,
81+ "redacted": false
82+ },
83+ "contacts": {
84+ "type": "contact.list",
85+ "contacts": [
86+ {
87+ "type": "contact",
88+ "id": "5ba682d23d7cf92bef87bfd4",
89+ "external_id": "f3b87a2e09d514c6c2e79b9a"
90+ }
91+ ]
92+ },
93+ "teammates": {
94+ "type": "admin.list",
95+ "teammates": [
96+ {
97+ "type": "contact",
98+ "id": "1a2b3c"
99+ }
100+ ]
101+ },
102+ "custom_attributes": {
103+ "property1": "string",
104+ "property2": "string"
105+ },
106+ "first_contact_reply": {
107+ "created_at": 1663597223,
108+ "type": "conversation",
109+ "url": "https://developers.intercom.com/"
110+ },
111+ "sla_applied": {
112+ "type": "conversation_sla_summary",
113+ "sla_name": "",
114+ "sla_status": "hit"
115+ },
116+ "statistics": {
117+ "type": "conversation_statistics",
118+ "time_to_assignment": 2310,
119+ "time_to_admin_reply": 2310,
120+ "time_to_first_close": 2310,
121+ "time_to_last_close": 2310,
122+ "median_time_to_reply": 2310,
123+ "first_contact_reply_at": 1663597233,
124+ "first_assignment_at": 1663597233,
125+ "first_admin_reply_at": 1663597233,
126+ "first_close_at": 1663597233,
127+ "last_assignment_at": 1663597233,
128+ "last_assignment_admin_reply_at": 1663597233,
129+ "last_contact_reply_at": 1663597233,
130+ "last_admin_reply_at": 1663597233,
131+ "last_close_at": 1663597233,
132+ "last_closed_by_id": "c3po",
133+ "count_reopens": 1,
134+ "count_assignments": 1,
135+ "count_conversation_parts": 1
136+ },
137+ "conversation_parts": {
138+ "type": "conversation_part.list",
139+ "conversation_parts": [
140+ {
141+ "type": "conversation_part",
142+ "id": "3",
143+ "part_type": "comment",
144+ "body": "<p>Okay!</p>",
145+ "created_at": 1663597223,
146+ "updated_at": 1663597260,
147+ "notified_at": 1663597260,
148+ "assigned_to": {
149+ "type": "contact",
150+ "id": "1a2b3c"
151+ },
152+ "author": {
153+ "type": "admin",
154+ "id": "274",
155+ "name": "Operator",
156+ "email": "operator+abcd1234@intercom.io"
157+ },
158+ "attachments": [
159+ {
160+ "type": "upload",
161+ "name": "example.png",
162+ "url": "https://picsum.photos/200/300",
163+ "content_type": "image/png",
164+ "filesize": 100,
165+ "width": 100,
166+ "height": 100
167+ }
168+ ],
169+ "external_id": "abcd1234",
170+ "redacted": false
171+ }
172+ ],
173+ "total_count": 2
174+ },
175+ "linked_objects": {
176+ "type": "list",
177+ "total_count": 100,
178+ "has_more": false,
179+ "data": [
180+ {
181+ "type": "ticket",
182+ "id": "7583",
183+ "category": "Customer"
184+ }
185+ ]
186+ }
187+ }
188+ """
189+
190+ # External
191+ from bs4 import BeautifulSoup
192+
193+ from typing import (
194+ List ,
195+ Optional ,
196+ Union ,
197+ TYPE_CHECKING
198+ )
199+
200+ # From Current API
201+ from . import schemas as c_schemas
202+
203+ # From Current Package
204+ from ...core .model_base import ModelBase
205+
206+ # Type Check Imports - TYPE_CHECKING is assumed True by type-checkers but is False at runtime.
207+ # See: https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING
208+ if TYPE_CHECKING :
209+ from .api import ConversationAPI
210+
211+
212+ class Conversation (ModelBase ):
213+ """
214+ Represents a Conversation.
215+
216+ Attributes:
217+ See the `ConversationSchema` definition in `apis/Conversation/schemas.py` for details.
218+
219+ Model-Specific Attributes:
220+ api_client (ConversationAPI): The API Client Instance. Injected via APIProxyInterface
221+ """
222+
223+ def __init__ (self , * args , ** kwargs ):
224+ self .__type : str = kwargs .get ('type' , '' )
225+ self .__id : str = kwargs .get ('id' , '' )
226+ self .__title : str = kwargs .get ('title' , '' )
227+ self .__created_at : int = kwargs .get ('created_at' , 0 )
228+ self .__updated_at : int = kwargs .get ('updated_at' , 0 )
229+ self .__waiting_since : int = kwargs .get ('waiting_since' , 0 )
230+ self .__snoozed_until : int = kwargs .get ('snoozed_until' , 0 )
231+ self .__open : bool = kwargs .get ('open' , False )
232+ self .__state : str = kwargs .get ('state' , '' )
233+ self .__read : bool = kwargs .get ('read' , False )
234+ self .__priority : str = kwargs .get ('priority' , '' )
235+ self .__admin_assignee_id : int = kwargs .get ('admin_assignee_id' , 0 )
236+ self .__team_assignee_id : str = kwargs .get ('team_assignee_id' , '' )
237+ self .__tags : c_schemas .Tags = kwargs .get ('tags' , None )
238+ self .__conversation_rating : c_schemas .ConversationRating = kwargs .get ('conversation_rating' , None )
239+ self .__source : c_schemas .Source = kwargs .get ('source' , None )
240+ self .__contacts : c_schemas .Contacts = kwargs .get ('contacts' , None )
241+ self .__teammates : c_schemas .Teammates = kwargs .get ('teammates' , None )
242+ self .__custom_attributes : dict = kwargs .get ('custom_attributes' , {})
243+ self .__first_contact_reply : c_schemas .FirstContactReply = kwargs .get ('first_contact_reply' , None )
244+ self .__sla_applied : c_schemas .SLAApplied = kwargs .get ('sla_applied' , None )
245+ self .__statistics : c_schemas .Statistics = kwargs .get ('statistics' , None )
246+ self .__conversation_parts : c_schemas .ConversationParts = kwargs .get ('conversation_parts' , None )
247+ self .__linked_objects : c_schemas .LinkedObjects = kwargs .get ('linked_objects' , None )
248+
249+
250+
251+
0 commit comments