Module intercom_python_sdk.apis.articles.schemas

Articles API Schemas

apis/articles/schemas.py

This module contains the schema definitions provided by the Intercom API Reference [1]. These schemas provide serialization/deserialization to and from the models defined in the apis/data_attributes/models.py module.


Expand source code
"""
# Articles API Schemas

`apis/articles/schemas.py`

This module contains the schema definitions provided by the Intercom API Reference [1].
These schemas provide serialization/deserialization to and from the models defined in the
`apis/data_attributes/models.py` module.

---
- [1] https://developers.intercom.com/intercom-api-reference/reference/the-article-model
"""
# Third-party
import marshmallow
from marshmallow import fields

# From Current API
from . import models as a_models

# From Current Package
from ...core.schema_base import SchemaBase


class ArticleStatisticsSchema(SchemaBase):
    """
    This schema represents the statistics of an Article on Intercom.

    Attributes:
        views (int): The number of views of the Article.
        conversations (int): The number of conversations of the Article.
        reactions (int): The number of reactions of the Article.
        happy_reaction_percentage (int): The percentage of happy reactions of the Article.
        neutral_reaction_percentage (int): The percentage of neutral reactions of the Article.
        sad_reaction_percentage (int): The percentage of sad reactions of the Article.
    """
    views = fields.Int()
    conversations = fields.Int()
    reactions = fields.Int()
    happy_reaction_percentage = fields.Int()
    neutral_reaction_percentage = fields.Int()
    sad_reaction_percentage = fields.Int()


class ArticleSchema(SchemaBase):
    """
    This schema represents an Article on Intercom.

    Attributes:
        id (int): The ID of the Article.
        type (str): The type of the Article.
        workspace_id (str): The ID of the workspace the Article belongs to.
        title (str): The title of the Article.
        description (str): The description of the Article.
        body (str): The body of the Article.
        author_id (int): The ID of the author of the Article.
        state (str): The state of the Article.
        created_at (int): The timestamp of when the Article was created.
        updated_at (int): The timestamp of when the Article was updated.
        url (str): The URL of the Article.can be null if the Article is not published.
        parent_id (int): The ID of the parent of the Article.
            Can be null if the Article is not a child of another Article.
        parent_type (str): The type of the parent of the Article.
            Can be null if the Article is not a child of another Article.
        default_locale (str): The default locale of the Article.
        statistics (dict): The statistics of the Article.
    """
    id = fields.Int(allow_none=True, required=True)
    type = fields.Str(allow_none=True, required=False)
    workspace_id = fields.Str(allow_none=True, required=False)
    title = fields.Str(required=True)
    description = fields.Str(allow_none=True, required=False)
    body = fields.Str(required=False)
    author_id = fields.Int(required=False)
    state = fields.Str(allow_none=True, required=False)
    created_at = fields.Int(allow_none=True, required=False)
    updated_at = fields.Int(allow_none=True, required=False)
    url = fields.Str(allow_none=True, required=False)
    default_locale = fields.Str(allow_none=True, required=False)
    translated_content = fields.Raw(allow_none=True, required=False)
    statistics = fields.Nested(ArticleStatisticsSchema, allow_none=True, required=False)

    parent_id = fields.Int(allow_none=True, required=False)
    parent_type = fields.Str(allow_none=True, required=False)

    @marshmallow.post_load
    def make_article(self, data, **kwargs):
        return a_models.Article(**data)


class ArticlePagesSchema(SchemaBase):
    """ Paging information for a list of Articles on Intercom. """
    type = fields.Str(default='pages')
    page = fields.Int()
    next = fields.Url(allow_none=True, required=False)
    per_page = fields.Int(default=50)
    total_pages = fields.Int()


class ArticleListSchema(SchemaBase):
    """ This schema represents a list of Articles on Intercom.

    Attributes:
        pages (dict): The pagination information of the list of Articles.
        total_count (int): The total number of Articles.
        data (list): The list of Articles.
    """
    pages = fields.Nested(ArticlePagesSchema)
    total_count = fields.Int()
    data = fields.Nested(ArticleSchema, many=True)

    @marshmallow.post_load
    def make_article_list(self, data, **kwargs):
        return a_models.ArticleList(**data)

Classes

class ArticleListSchema (*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet | None = None, unknown: str | None = None)

This schema represents a list of Articles on Intercom.

Attributes

pages : dict
The pagination information of the list of Articles.
total_count : int
The total number of Articles.
data : list
The list of Articles.
Expand source code
class ArticleListSchema(SchemaBase):
    """ This schema represents a list of Articles on Intercom.

    Attributes:
        pages (dict): The pagination information of the list of Articles.
        total_count (int): The total number of Articles.
        data (list): The list of Articles.
    """
    pages = fields.Nested(ArticlePagesSchema)
    total_count = fields.Int()
    data = fields.Nested(ArticleSchema, many=True)

    @marshmallow.post_load
    def make_article_list(self, data, **kwargs):
        return a_models.ArticleList(**data)

Ancestors

  • SchemaBase
  • marshmallow.schema.Schema
  • marshmallow.base.SchemaABC
  • abc.ABC

Class variables

var opts

Methods

def make_article_list(self, data, **kwargs)
Expand source code
@marshmallow.post_load
def make_article_list(self, data, **kwargs):
    return a_models.ArticleList(**data)

Inherited members

class ArticlePagesSchema (*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet | None = None, unknown: str | None = None)

Paging information for a list of Articles on Intercom.

Expand source code
class ArticlePagesSchema(SchemaBase):
    """ Paging information for a list of Articles on Intercom. """
    type = fields.Str(default='pages')
    page = fields.Int()
    next = fields.Url(allow_none=True, required=False)
    per_page = fields.Int(default=50)
    total_pages = fields.Int()

Ancestors

  • SchemaBase
  • marshmallow.schema.Schema
  • marshmallow.base.SchemaABC
  • abc.ABC

Class variables

var opts

Inherited members

class ArticleSchema (*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet | None = None, unknown: str | None = None)

This schema represents an Article on Intercom.

Attributes

id : int
The ID of the Article.
type : str
The type of the Article.
workspace_id : str
The ID of the workspace the Article belongs to.
title : str
The title of the Article.
description : str
The description of the Article.
body : str
The body of the Article.
author_id : int
The ID of the author of the Article.
state : str
The state of the Article.
created_at : int
The timestamp of when the Article was created.
updated_at : int
The timestamp of when the Article was updated.
url : str
The URL of the Article.can be null if the Article is not published.
parent_id : int
The ID of the parent of the Article. Can be null if the Article is not a child of another Article.
parent_type : str
The type of the parent of the Article. Can be null if the Article is not a child of another Article.
default_locale : str
The default locale of the Article.
statistics : dict
The statistics of the Article.
Expand source code
class ArticleSchema(SchemaBase):
    """
    This schema represents an Article on Intercom.

    Attributes:
        id (int): The ID of the Article.
        type (str): The type of the Article.
        workspace_id (str): The ID of the workspace the Article belongs to.
        title (str): The title of the Article.
        description (str): The description of the Article.
        body (str): The body of the Article.
        author_id (int): The ID of the author of the Article.
        state (str): The state of the Article.
        created_at (int): The timestamp of when the Article was created.
        updated_at (int): The timestamp of when the Article was updated.
        url (str): The URL of the Article.can be null if the Article is not published.
        parent_id (int): The ID of the parent of the Article.
            Can be null if the Article is not a child of another Article.
        parent_type (str): The type of the parent of the Article.
            Can be null if the Article is not a child of another Article.
        default_locale (str): The default locale of the Article.
        statistics (dict): The statistics of the Article.
    """
    id = fields.Int(allow_none=True, required=True)
    type = fields.Str(allow_none=True, required=False)
    workspace_id = fields.Str(allow_none=True, required=False)
    title = fields.Str(required=True)
    description = fields.Str(allow_none=True, required=False)
    body = fields.Str(required=False)
    author_id = fields.Int(required=False)
    state = fields.Str(allow_none=True, required=False)
    created_at = fields.Int(allow_none=True, required=False)
    updated_at = fields.Int(allow_none=True, required=False)
    url = fields.Str(allow_none=True, required=False)
    default_locale = fields.Str(allow_none=True, required=False)
    translated_content = fields.Raw(allow_none=True, required=False)
    statistics = fields.Nested(ArticleStatisticsSchema, allow_none=True, required=False)

    parent_id = fields.Int(allow_none=True, required=False)
    parent_type = fields.Str(allow_none=True, required=False)

    @marshmallow.post_load
    def make_article(self, data, **kwargs):
        return a_models.Article(**data)

Ancestors

  • SchemaBase
  • marshmallow.schema.Schema
  • marshmallow.base.SchemaABC
  • abc.ABC

Class variables

var opts

Methods

def make_article(self, data, **kwargs)
Expand source code
@marshmallow.post_load
def make_article(self, data, **kwargs):
    return a_models.Article(**data)

Inherited members

class ArticleStatisticsSchema (*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet | None = None, unknown: str | None = None)

This schema represents the statistics of an Article on Intercom.

Attributes

views : int
The number of views of the Article.
conversations : int
The number of conversations of the Article.
reactions : int
The number of reactions of the Article.
happy_reaction_percentage : int
The percentage of happy reactions of the Article.
neutral_reaction_percentage : int
The percentage of neutral reactions of the Article.
sad_reaction_percentage : int
The percentage of sad reactions of the Article.
Expand source code
class ArticleStatisticsSchema(SchemaBase):
    """
    This schema represents the statistics of an Article on Intercom.

    Attributes:
        views (int): The number of views of the Article.
        conversations (int): The number of conversations of the Article.
        reactions (int): The number of reactions of the Article.
        happy_reaction_percentage (int): The percentage of happy reactions of the Article.
        neutral_reaction_percentage (int): The percentage of neutral reactions of the Article.
        sad_reaction_percentage (int): The percentage of sad reactions of the Article.
    """
    views = fields.Int()
    conversations = fields.Int()
    reactions = fields.Int()
    happy_reaction_percentage = fields.Int()
    neutral_reaction_percentage = fields.Int()
    sad_reaction_percentage = fields.Int()

Ancestors

  • SchemaBase
  • marshmallow.schema.Schema
  • marshmallow.base.SchemaABC
  • abc.ABC

Class variables

var opts

Inherited members