1111- [1] https://developers.intercom.com/intercom-api-reference/reference/the-article-model
1212"""
1313
14+ # Built-in
15+ from enum import Enum
16+
1417# External
1518import marshmallow
1619from marshmallow import fields
1720
1821# From Current API
1922from . import models as a_models
23+ from .languages import ArticleLanguages
2024
2125# From Current Package
2226from ...core .schema_base import SchemaBase
@@ -65,34 +69,52 @@ class ArticleSchema(SchemaBase):
6569 default_locale (str): The default locale of the Article.
6670 statistics (dict): The statistics of the Article.
6771 """
68- id = fields .Int (required = True )
69- type = fields .Str (allow_none = True )
70- workspace_id = fields .Str (allow_none = True )
72+ id = fields .Int (required = False )
73+ type = fields .Str (allow_none = True , required = False )
74+ workspace_id = fields .Str (allow_none = True , required = False )
7175 title = fields .Str (required = True )
72- description = fields .Str (allow_none = True )
73- body = fields .Str (required = True )
74- author_id = fields .Int (required = True )
75- state = fields .Str (allow_none = True )
76- created_at = fields .Int (allow_none = True )
77- updated_at = fields .Int (allow_none = True )
78- url = fields .Str (allow_none = True )
79- default_locale = fields .Str (allow_none = True )
80- translated_content = fields .Dict ( values = fields . Str (), default = '' , allow_none = True )
81- statistics = fields .Nested (ArticleStatisticsSchema , allow_none = True )
82-
83- parent_id = fields .Int (allow_none = True )
84- parent_type = fields .Str (allow_none = True )
76+ description = fields .Str (allow_none = True , required = False )
77+ body = fields .Str (required = False )
78+ author_id = fields .Int (required = False )
79+ state = fields .Str (allow_none = True , required = False )
80+ created_at = fields .Int (allow_none = True , required = False )
81+ updated_at = fields .Int (allow_none = True , required = False )
82+ url = fields .Str (allow_none = True , required = False )
83+ default_locale = fields .Str (allow_none = True , required = False )
84+ translated_content = fields .Raw ( allow_none = True , required = False )
85+ statistics = fields .Nested (ArticleStatisticsSchema , allow_none = True , required = False )
86+
87+ parent_id = fields .Int (allow_none = True , required = False )
88+ parent_type = fields .Str (allow_none = True , required = False )
8589
8690 @marshmallow .post_load
8791 def make_article (self , data , ** kwargs ):
8892 return a_models .Article (** data )
8993
9094
95+ class ArticleTranslationSchema (SchemaBase ):
96+ """
97+ This schema represents the translation of an Article on Intercom.
98+ """
99+ type = fields .Str (default = "article_translated_content" )
100+
101+ def __init__ (self , ** kwargs ):
102+ super ().__init__ (** kwargs )
103+ for language in ArticleLanguages :
104+ locale_code = language .value
105+ self .fields [locale_code ] = fields .Str (allow_none = True , required = False )
106+
107+ @marshmallow .post_load
108+ def make_article_translation (self , data , ** kwargs ):
109+ return a_models .ArticleTranslation (** data )
110+
111+
112+
91113class ArticlePagesSchema (SchemaBase ):
92114 """ Paging information for a list of Articles on Intercom. """
93115 type = fields .Str (default = 'pages' )
94116 page = fields .Int ()
95- next = fields .Url (allow_none = True )
117+ next = fields .Url (allow_none = True , required = False )
96118 per_page = fields .Int (default = 50 )
97119 total_pages = fields .Int ()
98120
@@ -112,3 +134,5 @@ class ArticleListSchema(SchemaBase):
112134 @marshmallow .post_load
113135 def make_article_list (self , data , ** kwargs ):
114136 return a_models .ArticleList (** data )
137+
138+
0 commit comments