Skip to content

Commit fe46d39

Browse files
authored
Merge pull request #88 from livechat/API-11362_minor_fixes_in_sdk
API-11362_minor_fixes_in_sdk
2 parents fa73ced + 21ad218 commit fe46d39

File tree

12 files changed

+119
-90
lines changed

12 files changed

+119
-90
lines changed

changelog.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ All notable changes to this project will be documented in this file.
44
## [0.3.4] - TBA
55

66
### Added
7-
- New method in configuration-api v3.5: `list_groups_properties`.
7+
- New methods in configuration-api v3.5: `list_groups_properties`, `get_product_source`.
8+
- Support for `default_group_priority` parameter in `create_bot` and `update_bot` methods in configuration-api v3.3/v3.4/v3.5 classes.
9+
- Support for `job_title` parameter in `create_bot` method in configuration-api v3.3/v3.4/v3.5 classes.
10+
- Support for `proxies` and `verify` parameters for web base clients.
11+
12+
### Changed
13+
- Renamed method `tag_chat_usage` to `chat_usage` in reports-api v3.5.
14+
15+
### Bugfixes
16+
- Fix paths for `response_time` and `first_response_time` methods in reports-api v3.4/v3.5 classes.
17+
- Fix `upload_file` method in agent-api v3.4/v3.5 classes.
818

919
### Removed
10-
- Support for `list_group_properties` method in configuration-api v3.5 class.
20+
- Support for `list_group_properties`, `get_license_id` and `get_organization_id` method in configuration-api v3.5 class.
21+
- Support for `webhook` parameter in `create_bot` and `update_bot` methods in configuration-api v3.3/v3.4/v3.5 classes.
1122

1223
## [0.3.3] - 2022-07-20
1324

livechat/agent/web/api/v34.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def upload_file(self,
447447
httpx.Response: The Response object from `httpx` library,
448448
which contains a server’s response to an HTTP request. '''
449449
return self.session.post(f'{self.api_url}/upload_file',
450-
content=file.read(),
450+
file=file,
451451
headers=headers)
452452

453453
def send_rich_message_postback(self,

livechat/agent/web/api/v35.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def upload_file(self,
447447
httpx.Response: The Response object from `httpx` library,
448448
which contains a server’s response to an HTTP request. '''
449449
return self.session.post(f'{self.api_url}/upload_file',
450-
content=file.read(),
450+
file=file,
451451
headers=headers)
452452

453453
def send_rich_message_postback(self,

livechat/agent/web/base.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def get_client(
2222
access_token: str,
2323
version: str = stable_version,
2424
base_url: str = api_url,
25-
http2: bool = False
25+
http2: bool = False,
26+
proxies: dict = None,
27+
verify: bool = True
2628
) -> Union[AgentWebV33, AgentWebV34, AgentWebV35]:
2729
''' Returns client for specific API version.
2830
@@ -33,6 +35,11 @@ def get_client(
3335
base_url (str): API's base url. Defaults to API's production URL.
3436
http2 (bool): A boolean indicating if HTTP/2 support should be
3537
enabled. Defaults to `False`.
38+
proxies (dict): A dictionary mapping proxy keys to proxy URLs.
39+
verify (bool): SSL certificates (a.k.a CA bundle) used to
40+
verify the identity of requested hosts. Either `True` (default CA bundle),
41+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
42+
(which will disable verification). Defaults to `True`.
3643
3744
Returns:
3845
API client object for specified version.
@@ -41,9 +48,9 @@ def get_client(
4148
ValueError: If the specified version does not exist.
4249
'''
4350
client = {
44-
'3.3': AgentWebV33(access_token, base_url, http2),
45-
'3.4': AgentWebV34(access_token, base_url, http2),
46-
'3.5': AgentWebV35(access_token, base_url, http2),
51+
'3.3': AgentWebV33(access_token, base_url, http2, proxies, verify),
52+
'3.4': AgentWebV34(access_token, base_url, http2, proxies, verify),
53+
'3.5': AgentWebV35(access_token, base_url, http2, proxies, verify),
4754
}.get(version)
4855
if not client:
4956
raise ValueError('Provided version does not exist.')

livechat/configuration/api/v33.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ def create_bot(self,
397397
name: str = None,
398398
avatar: str = None,
399399
max_chats_count: int = None,
400+
default_group_priority: str = None,
401+
job_title: str = None,
400402
groups: list = None,
401-
webhooks: dict = None,
402403
work_scheduler: dict = None,
403404
timezone: str = None,
404405
owner_client_id: str = None,
@@ -410,8 +411,9 @@ def create_bot(self,
410411
name (str): Display name.
411412
avatar (str): Avatar URL.
412413
max_chats_count (int): Max. number of incoming chats that can be routed to the Bot; default: 6.
414+
default_group_priority (str): The default routing priority for a group without defined priority.
415+
job_title (str): Bot's job title.
413416
groups (list): Groups the Bot belongs to.
414-
webhooks (dict): Webhooks sent to the Bot.
415417
work_scheduler (dict): Work scheduler options to set for the new Bot.
416418
timezone (str): The time zone in which the Bot's work scheduler should operate.
417419
owner_client_id (str): Required only when authorizing via PATs.
@@ -461,8 +463,8 @@ def update_bot(self,
461463
name: str = None,
462464
avatar: str = None,
463465
max_chats_count: int = None,
466+
default_group_priority: str = None,
464467
groups: list = None,
465-
webhooks: dict = None,
466468
work_scheduler: dict = None,
467469
timezone: str = None,
468470
payload: dict = None,
@@ -474,6 +476,7 @@ def update_bot(self,
474476
name (str): Display name.
475477
avatar (str): Avatar URL.
476478
max_chats_count (int): Max. number of incoming chats that can be routed to the Bot.
479+
default_group_priority (str): The default routing priority for a group without defined priority.
477480
groups (list): Groups the Bot belongs to.
478481
webhooks (dict): Webhooks sent to the Bot.
479482
work_scheduler (dict): Work scheduler options to set for the new Bot.

livechat/configuration/api/v34.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,9 @@ def create_bot(self,
397397
name: str = None,
398398
avatar: str = None,
399399
max_chats_count: int = None,
400+
default_group_priority: str = None,
401+
job_title: str = None,
400402
groups: list = None,
401-
webhooks: dict = None,
402403
work_scheduler: dict = None,
403404
timezone: str = None,
404405
owner_client_id: str = None,
@@ -410,8 +411,9 @@ def create_bot(self,
410411
name (str): Display name.
411412
avatar (str): Avatar URL.
412413
max_chats_count (int): Max. number of incoming chats that can be routed to the Bot; default: 6.
414+
default_group_priority (str): The default routing priority for a group without defined priority.
415+
job_title (str): Bot's job title.
413416
groups (list): Groups the Bot belongs to.
414-
webhooks (dict): Webhooks sent to the Bot.
415417
work_scheduler (dict): Work scheduler options to set for the new Bot.
416418
timezone (str): The time zone in which the Bot's work scheduler should operate.
417419
owner_client_id (str): Required only when authorizing via PATs.
@@ -461,6 +463,7 @@ def update_bot(self,
461463
name: str = None,
462464
avatar: str = None,
463465
max_chats_count: int = None,
466+
default_group_priority: str = None,
464467
groups: list = None,
465468
webhooks: dict = None,
466469
work_scheduler: dict = None,
@@ -474,6 +477,7 @@ def update_bot(self,
474477
name (str): Display name.
475478
avatar (str): Avatar URL.
476479
max_chats_count (int): Max. number of incoming chats that can be routed to the Bot.
480+
default_group_priority (str): The default routing priority for a group without defined priority.
477481
groups (list): Groups the Bot belongs to.
478482
webhooks (dict): Webhooks sent to the Bot.
479483
work_scheduler (dict): Work scheduler options to set for the new Bot.

livechat/configuration/api/v35.py

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,9 @@ def create_bot(self,
399399
name: str = None,
400400
avatar: str = None,
401401
max_chats_count: int = None,
402+
default_group_priority: str = None,
403+
job_title: str = None,
402404
groups: list = None,
403-
webhooks: dict = None,
404405
work_scheduler: dict = None,
405406
timezone: str = None,
406407
owner_client_id: str = None,
@@ -411,8 +412,9 @@ def create_bot(self,
411412
name (str): Display name.
412413
avatar (str): Avatar URL.
413414
max_chats_count (int): Max. number of incoming chats that can be routed to the Bot; default: 6.
415+
default_group_priority (str): The default routing priority for a group without defined priority.
416+
job_title (str): Bot's job title.
414417
groups (list): Groups the Bot belongs to.
415-
webhooks (dict): Webhooks sent to the Bot.
416418
work_scheduler (dict): Work scheduler options to set for the new Bot.
417419
timezone (str): The time zone in which the Bot's work scheduler should operate.
418420
owner_client_id (str): ID of the client bot will be assigned to.
@@ -461,7 +463,7 @@ def update_bot(self,
461463
avatar: str = None,
462464
max_chats_count: int = None,
463465
groups: list = None,
464-
webhooks: dict = None,
466+
default_group_priority: str = None,
465467
work_scheduler: dict = None,
466468
timezone: str = None,
467469
payload: dict = None,
@@ -474,7 +476,7 @@ def update_bot(self,
474476
avatar (str): Avatar URL.
475477
max_chats_count (int): Max. number of incoming chats that can be routed to the Bot.
476478
groups (list): Groups the Bot belongs to.
477-
webhooks (dict): Webhooks sent to the Bot.
479+
default_group_priority (str): The default routing priority for a group without defined priority.
478480
work_scheduler (dict): Work scheduler options to set for the new Bot.
479481
timezone (str): The time zone in which the Bot's work scheduler should operate.
480482
payload (dict): Custom payload to be used as request's data.
@@ -1245,54 +1247,6 @@ def get_license_webhooks_state(self,
12451247

12461248
# Other
12471249

1248-
def get_license_id(self,
1249-
organization_id: str = None,
1250-
params: dict = None,
1251-
headers: dict = None) -> httpx.Response:
1252-
''' Returns license ID by given organization ID.
1253-
1254-
Args:
1255-
organization_id (str): Organization ID to get license ID for.
1256-
params (dict): Custom params to be used in request's query string.
1257-
It overrides all other parameters provided for the method.
1258-
headers (dict): Custom headers to be used with session headers.
1259-
They will be merged with session-level values that are set,
1260-
however, these method-level parameters will not be persisted across requests.
1261-
1262-
Returns:
1263-
httpx.Response: The Response object from `httpx` library,
1264-
which contains a server's response to an HTTP request.
1265-
'''
1266-
if params is None:
1267-
params = prepare_payload(locals())
1268-
return self.session.get(f'{self.api_url}/get_license_id',
1269-
params=params,
1270-
headers=headers)
1271-
1272-
def get_organization_id(self,
1273-
license_id: int = None,
1274-
params: dict = None,
1275-
headers: dict = None) -> httpx.Response:
1276-
''' Returns organization ID by given license ID.
1277-
1278-
Args:
1279-
license_id (int): License ID to get organization ID for.
1280-
params (dict): Custom params to be used in request's query string.
1281-
It overrides all other parameters provided for the method.
1282-
headers (dict): Custom headers to be used with session headers.
1283-
They will be merged with session-level values that are set,
1284-
however, these method-level parameters will not be persisted across requests.
1285-
1286-
Returns:
1287-
httpx.Response: The Response object from `httpx` library,
1288-
which contains a server's response to an HTTP request.
1289-
'''
1290-
if params is None:
1291-
params = prepare_payload(locals())
1292-
return self.session.get(f'{self.api_url}/get_organization_id',
1293-
params=params,
1294-
headers=headers)
1295-
12961250
def list_channels(self,
12971251
payload: dict = None,
12981252
headers: dict = None) -> httpx.Response:
@@ -1313,10 +1267,10 @@ def list_channels(self,
13131267
json=payload,
13141268
headers=headers)
13151269

1316-
def check_product_limits(self,
1317-
plan: str = None,
1318-
payload: dict = None,
1319-
headers: dict = None) -> httpx.Response:
1270+
def check_product_limits_for_plan(self,
1271+
plan: str = None,
1272+
payload: dict = None,
1273+
headers: dict = None) -> httpx.Response:
13201274
''' Checks product limits for plans.
13211275
Args:
13221276
plan (str): License plan to check limit for.
@@ -1336,6 +1290,26 @@ def check_product_limits(self,
13361290
json=payload,
13371291
headers=headers)
13381292

1293+
def get_product_source(self,
1294+
payload: dict = None,
1295+
headers: dict = None) -> httpx.Response:
1296+
''' Retrieves the source parameters that were passed when activating the LiveChat product.
1297+
Args:
1298+
payload (dict): Custom payload to be used as request's data.
1299+
It overrides all other parameters provided for the method.
1300+
headers (dict): Custom headers to be used with session headers.
1301+
They will be merged with session-level values that are set,
1302+
however, these method-level parameters will not be persisted across requests.
1303+
Returns:
1304+
httpx.Response: The Response object from `httpx` library,
1305+
which contains a server's response to an HTTP request.
1306+
'''
1307+
if payload is None:
1308+
payload = prepare_payload(locals())
1309+
return self.session.get(f'{self.api_url}/get_product_source',
1310+
json=payload,
1311+
headers=headers)
1312+
13391313

13401314
# Batch requests
13411315

livechat/configuration/base.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def get_client(
2323
token: str,
2424
version: str = stable_version,
2525
base_url: str = api_url,
26-
http2: bool = False
26+
http2: bool = False,
27+
proxies: dict = None,
28+
verify: bool = True
2729
) -> Union[ConfigurationApiV33, ConfigurationApiV34, ConfigurationApiV35]:
2830
''' Returns client for specific Configuration API version.
2931
@@ -34,6 +36,11 @@ def get_client(
3436
base_url (str): API's base url. Defaults to API's production URL.
3537
http2 (bool): A boolean indicating if HTTP/2 support should be
3638
enabled. Defaults to `False`.
39+
proxies (dict): A dictionary mapping proxy keys to proxy URLs.
40+
verify (bool): SSL certificates (a.k.a CA bundle) used to
41+
verify the identity of requested hosts. Either `True` (default CA bundle),
42+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
43+
(which will disable verification). Defaults to `True`.
3744
3845
Returns:
3946
ConfigurationApi: API client object for specified version.
@@ -42,9 +49,12 @@ def get_client(
4249
ValueError: If the specified version does not exist.
4350
'''
4451
client = {
45-
'3.3': ConfigurationApiV33(token, base_url, http2),
46-
'3.4': ConfigurationApiV34(token, base_url, http2),
47-
'3.5': ConfigurationApiV35(token, base_url, http2),
52+
'3.3': ConfigurationApiV33(token, base_url, http2, proxies,
53+
verify),
54+
'3.4': ConfigurationApiV34(token, base_url, http2, proxies,
55+
verify),
56+
'3.5': ConfigurationApiV35(token, base_url, http2, proxies,
57+
verify),
4858
}.get(version)
4959
if not client:
5060
raise ValueError('Provided version does not exist.')

livechat/customer/web/base.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ def get_client(
2525
version: str = stable_version,
2626
base_url: str = api_url,
2727
http2: bool = False,
28+
proxies: dict = None,
29+
verify: bool = True,
2830
organization_id: str = None
2931
) -> Union[CustomerWebV33, CustomerWebV34, CustomerWebV35]:
3032
''' Returns client for specific API version.
3133
3234
Args:
3335
license_id (int): License ID. Required to use for API version <= 3.3.
34-
token (str): Full token with type (Bearer/Basic) that will be
36+
access_token (str): Full token with type (Bearer/Basic) that will be
3537
used as `Authorization` header in requests to API.
3638
version (str): API's version. Defaults to the stable version of API.
3739
base_url (str): API's base url. Defaults to API's production URL.
3840
http2 (bool): A boolean indicating if HTTP/2 support should be
3941
enabled. Defaults to `False`.
42+
proxies (dict): A dictionary mapping proxy keys to proxy URLs.
43+
verify (bool): SSL certificates (a.k.a CA bundle) used to
44+
verify the identity of requested hosts. Either `True` (default CA bundle),
45+
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
46+
(which will disable verification). Defaults to `True`.
4047
organization_id (str): Organization ID, replaced license ID in v3.4.
4148
4249
Returns:
@@ -56,19 +63,25 @@ def get_client(
5663
'license_id': license_id,
5764
'access_token': access_token,
5865
'base_url': base_url,
59-
'http2': http2
66+
'http2': http2,
67+
'proxies': proxies,
68+
'verify': verify
6069
},
6170
'3.4': {
6271
'organization_id': organization_id,
6372
'access_token': access_token,
6473
'base_url': base_url,
65-
'http2': http2
74+
'http2': http2,
75+
'proxies': proxies,
76+
'verify': verify
6677
},
6778
'3.5': {
6879
'organization_id': organization_id,
6980
'access_token': access_token,
7081
'base_url': base_url,
71-
'http2': http2
82+
'http2': http2,
83+
'proxies': proxies,
84+
'verify': verify
7285
},
7386
}.get(version)
7487
if client:

0 commit comments

Comments
 (0)