Storages
suppgram.storage.Storage
Storage encapsulates functionality related to storing data persistently in a database, allowing to integrate Suppgram into systems with various tech stacks.
Basically implements Repository design pattern.
initialize()
async
Performs asynchronous initialization if needed.
create_or_update_customer(identification, diff=None)
abstractmethod
async
Creates or updates customer identified by given identification
with new data provided in diff
.
Can be used with diff=None
to get already existing customer with no changes applied.
Parameters: |
|
---|
get_agent(identification)
abstractmethod
async
find_all_agents()
abstractmethod
create_or_update_agent(identification, diff=None)
abstractmethod
async
update_agent(identification, diff)
abstractmethod
async
get_workplace(identification)
abstractmethod
async
get_agent_workplaces(agent)
abstractmethod
async
get_or_create_workplace(identification)
abstractmethod
async
create_tag(name, created_by)
abstractmethod
async
find_all_tags()
abstractmethod
async
get_or_create_conversation(customer)
abstractmethod
async
find_conversations_by_ids(conversation_ids, with_messages=False)
abstractmethod
async
find_all_conversations(with_messages=False)
abstractmethod
count_all_conversations()
abstractmethod
async
update_conversation(id, diff, unassigned_only=False)
abstractmethod
async
get_agent_conversation(identification)
abstractmethod
async
find_customer_conversations(customer, with_messages=False)
abstractmethod
async
find_agent_conversations(agent, with_messages=False)
abstractmethod
async
save_message(conversation, message)
abstractmethod
async
save_event(event)
abstractmethod
async
find_all_events()
abstractmethod
Iterate over all stored events in chronological order.
count_all_events()
abstractmethod
async
SQLAlchemy
suppgram.storages.sqlalchemy.SQLAlchemyStorage
Bases: Storage
Implementation of Storage for SQLAlchemy.
__init__(engine, models)
Parameters: |
|
---|
suppgram.storages.sqlalchemy.Models
Abstraction layer over SQLAlchemy models.
Default models are declared in suppgram.storages.mongodb.collections
package.
__init__(engine, customer_model=Customer, agent_model=Agent, workplace_model=Workplace, conversation_model=Conversation, conversation_message_model=ConversationMessage, tag_model=Tag, conversation_tag_association_table=association_table, event_model=Event)
Parameters: |
|
---|
MongoDB
suppgram.storages.mongodb.MongoDBStorage
Bases: Storage
Implementation of Storage for MongoDB via Motor library.
__init__(collections)
Parameters: |
|
---|
suppgram.storages.mongodb.Collections
Abstraction layer over MongoDB database and collection names and BSON documents structure.
__init__(database, customer_collection_name='suppgram_customers', agent_collection_name='suppgram_agents', conversation_collection_name='suppgram_conversations', tag_collection_name='suppgram_tags', event_collection_name='suppgram_events', codec_options=CodecOptions(tz_aware=True, tzinfo=timezone.utc, uuid_representation=UuidRepresentation.STANDARD))
Parameters: |
|
---|