Skip to content

Commit

Permalink
Merge branch 'master' into API-10483-refactor-customer-rtm-api
Browse files Browse the repository at this point in the history
  • Loading branch information
skamieniarz authored May 4, 2022
2 parents bc29161 + 2dbb02a commit a9bdd00
Show file tree
Hide file tree
Showing 14 changed files with 4,156 additions and 591 deletions.
2 changes: 1 addition & 1 deletion examples/agent_rtm_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
''' Agent RTM client example usage. '''

from livechat.agent.rtm.client import AgentRTM
from livechat.agent.rtm.base import AgentRTM

agent_rtm = AgentRTM.get_client()
agent_rtm.open_connection()
Expand Down
2 changes: 1 addition & 1 deletion examples/customer_web_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
''' Customer WEB client example usage. '''

from livechat.customer.web.client import CustomerWeb
from livechat.customer.web.base import CustomerWeb

customer_web = CustomerWeb.get_client(license_id=12345,
access_token='<your access token>')
Expand Down
2 changes: 1 addition & 1 deletion livechat/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# pylint: disable=C0114
from livechat.agent.rtm.client import AgentRTM
from livechat.agent.rtm.base import AgentRTM
from livechat.agent.web.base import AgentWeb
312 changes: 64 additions & 248 deletions livechat/agent/rtm/client.py → livechat/agent/rtm/api/v33.py

Large diffs are not rendered by default.

965 changes: 965 additions & 0 deletions livechat/agent/rtm/api/v34.py

Large diffs are not rendered by default.

965 changes: 965 additions & 0 deletions livechat/agent/rtm/api/v35.py

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions livechat/agent/rtm/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
''' Agent RTM client implementation. '''

# pylint: disable=W0613,W0622,C0103,R0913,R0903,W0107,W0221
from __future__ import annotations

from typing import Union

from livechat.agent.rtm.api.v33 import AgentRtmV33
from livechat.agent.rtm.api.v34 import AgentRtmV34
from livechat.agent.rtm.api.v35 import AgentRtmV35
from livechat.config import CONFIG

stable_version = CONFIG.get('stable')
api_url = CONFIG.get('url')


class AgentRTM:
''' Main class that gets specific client. '''
@staticmethod
def get_client(
version: str = stable_version,
base_url: str = api_url
) -> Union[AgentRtmV33, AgentRtmV34, AgentRtmV35]:
''' Returns client for specific Agent RTM version.
Args:
version (str): API's version. Defaults to the stable version of API.
base_url (str): API's base url. Defaults to API's production URL.
Returns:
API client object for specified version.
Raises:
ValueError: If the specified version does not exist.
'''
client = {
'3.3': AgentRtmV33,
'3.4': AgentRtmV34,
'3.5': AgentRtmV35,
}.get(version)
if not client:
raise ValueError('Provided version does not exist.')
return client(base_url)
2 changes: 1 addition & 1 deletion livechat/customer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pylint: disable=C0114
from livechat.customer.rtm.base import CustomerRTM
from livechat.customer.web.client import CustomerWeb
from livechat.customer.web.base import CustomerWeb
972 changes: 972 additions & 0 deletions livechat/customer/web/api/v33.py

Large diffs are not rendered by default.

Loading

0 comments on commit a9bdd00

Please sign in to comment.