Module intercom_python_sdk.apis.data_events.api
Data Events API
apis/data_events/api.py
This module contains the Data EventsAPI class, which defines a client for the Data Events API. It is used to interact with the Intercom Data Events API [1] as defined in the Intercom API Reference [2].
- [1] https://developers.intercom.com/intercom-api-reference/reference/createdataevent
- [2] https://github.com/intercom/Intercom-OpenAPI
Expand source code
"""
# Data Events API
`apis/data_events/api.py`
This module contains the Data EventsAPI class, which defines a client for the Data Events API.
It is used to interact with the Intercom Data Events API [1] as defined in the Intercom API Reference [2].
---
- [1] https://developers.intercom.com/intercom-api-reference/reference/createdataevent
- [2] https://github.com/intercom/Intercom-OpenAPI
"""
# External
from uplink import (
get, post,
returns,
response_handler,
Body, Query
)
# From Current API
from .schemas import (
DataEventSchema,
DataEventListSchema
)
from .models import (
DataEventList
)
# From Current Package
from ...core.api_base import APIBase
from ...core.errors import catch_api_error
@response_handler(catch_api_error)
class DataEventsAPI(APIBase):
""" Data Events API Client. """
URI = "/events/"
# Internal method required here so we can implement custom query parameter logic
@returns(DataEventListSchema()) # type: ignore
@get("")
def __list_all(self,
user_id: Query("user_id", str) = None, # noqa # type: ignore
intercom_user_id: Query("intercom_user_id", str) = None, # noqa # type: ignore
email: Query("email", str) = None, # noqa # type: ignore
type: Query("type", str) = "user", # noqa # type: ignore
summary: Query("summary", bool) = False): # noqa # type: ignore
""" List all data events. Internal method for `list_all`."""
def list_all(self,
user_id: str = "",
intercom_user_id: str = "",
email: str = "",
summary: bool = False) -> DataEventList:
""" List all data events.
Args:
user_id (str): The user id of the user who triggered the event.
intercom_user_id (str): The intercom user id of the user who triggered the event.
email (str): The email of the user who triggered the event.
summary (bool): Whether to return a summary of the data events.
_Requires at least one of `user_id`, `intercom_user_id`, or `email`._
Returns:
DataEventsList: A list of data events.
"""
# Validate input
if not any([user_id, intercom_user_id, email]):
raise ValueError("At least one of `user_id`, `intercom_user_id`, or `email` must be provided.")
return self.__list_all(user_id=user_id, intercom_user_id=intercom_user_id, email=email, summary=summary)
@returns(DataEventSchema()) # type: ignore
@post("")
def submit(self, event: Body(type=DataEventSchema)): # type: ignore
""" Submit a new data event.
Args:
event (DataEventSchema): The data event to submit.
Takes in a DataEventSchema object as defined in `apis/data_events/schemas.py`.
Returns:
DataEvent: The data event that was submitted.
"""
Classes
class DataEventsAPI (config: Configuration, **kwargs)
-
Data Events API Client.
Initializes a new instance of the APIBase class. Overrides the Consumer class from the Uplink library to configure the Consumer instance using a Configuration object.
Args
config
- The configuration settings for the API.
Expand source code
@response_handler(catch_api_error) class DataEventsAPI(APIBase): """ Data Events API Client. """ URI = "/events/" # Internal method required here so we can implement custom query parameter logic @returns(DataEventListSchema()) # type: ignore @get("") def __list_all(self, user_id: Query("user_id", str) = None, # noqa # type: ignore intercom_user_id: Query("intercom_user_id", str) = None, # noqa # type: ignore email: Query("email", str) = None, # noqa # type: ignore type: Query("type", str) = "user", # noqa # type: ignore summary: Query("summary", bool) = False): # noqa # type: ignore """ List all data events. Internal method for `list_all`.""" def list_all(self, user_id: str = "", intercom_user_id: str = "", email: str = "", summary: bool = False) -> DataEventList: """ List all data events. Args: user_id (str): The user id of the user who triggered the event. intercom_user_id (str): The intercom user id of the user who triggered the event. email (str): The email of the user who triggered the event. summary (bool): Whether to return a summary of the data events. _Requires at least one of `user_id`, `intercom_user_id`, or `email`._ Returns: DataEventsList: A list of data events. """ # Validate input if not any([user_id, intercom_user_id, email]): raise ValueError("At least one of `user_id`, `intercom_user_id`, or `email` must be provided.") return self.__list_all(user_id=user_id, intercom_user_id=intercom_user_id, email=email, summary=summary) @returns(DataEventSchema()) # type: ignore @post("") def submit(self, event: Body(type=DataEventSchema)): # type: ignore """ Submit a new data event. Args: event (DataEventSchema): The data event to submit. Takes in a DataEventSchema object as defined in `apis/data_events/schemas.py`. Returns: DataEvent: The data event that was submitted. """
Ancestors
- APIBase
- uplink.builder.Consumer
- uplink.interfaces.Consumer
- uplink.builder._Consumer
Class variables
var URI
Methods
def list_all(self, user_id: str = '', intercom_user_id: str = '', email: str = '', summary: bool = False) ‑> DataEventList
-
List all data events.
Args
user_id
:str
- The user id of the user who triggered the event.
intercom_user_id
:str
- The intercom user id of the user who triggered the event.
email
:str
- The email of the user who triggered the event.
summary
:bool
- Whether to return a summary of the data events.
Requires at least one of
user_id
,intercom_user_id
, oremail
.Returns
DataEventsList
- A list of data events.
Expand source code
def list_all(self, user_id: str = "", intercom_user_id: str = "", email: str = "", summary: bool = False) -> DataEventList: """ List all data events. Args: user_id (str): The user id of the user who triggered the event. intercom_user_id (str): The intercom user id of the user who triggered the event. email (str): The email of the user who triggered the event. summary (bool): Whether to return a summary of the data events. _Requires at least one of `user_id`, `intercom_user_id`, or `email`._ Returns: DataEventsList: A list of data events. """ # Validate input if not any([user_id, intercom_user_id, email]): raise ValueError("At least one of `user_id`, `intercom_user_id`, or `email` must be provided.") return self.__list_all(user_id=user_id, intercom_user_id=intercom_user_id, email=email, summary=summary)
def submit(self, event:
) -
Submit a new data event.
Args
event
:DataEventSchema
- The data event to submit.
Takes in a DataEventSchema object as defined in
apis/data_events/schemas.py
.
Returns
DataEvent
- The data event that was submitted.
Expand source code
@returns(DataEventSchema()) # type: ignore @post("") def submit(self, event: Body(type=DataEventSchema)): # type: ignore """ Submit a new data event. Args: event (DataEventSchema): The data event to submit. Takes in a DataEventSchema object as defined in `apis/data_events/schemas.py`. Returns: DataEvent: The data event that was submitted. """