-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from livechat/API-10481-refactor-agent-rtm
API-10481: Refactor Agent RTM API client
- Loading branch information
Showing
7 changed files
with
2,040 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
312
livechat/agent/rtm/client.py → livechat/agent/rtm/api/v33.py
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters