Skip to content

Commit

Permalink
Added new methods related to greetings conversion, chat surveys, and …
Browse files Browse the repository at this point in the history
…response time in reports-api v3.4.
  • Loading branch information
marcindebski committed Dec 1, 2021
1 parent c81ba92 commit 55967b0
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Change Log
All notable changes to this project will be documented in this file.

## [0.1.10] - 2021-12-xx

### Added

- Added new methods related to greetings conversion, chat surveys, and response time in reports-api v3.4.

## [0.1.9] - 2021-11-03

### Added
Expand Down
118 changes: 118 additions & 0 deletions livechat/reports/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,64 @@ def engagement(self,
json=payload,
headers=headers)

def greetings_conversion(self,
distribution: str = 'day',
timezone: str = None,
filters: dict = None,
payload: dict = None,
headers: dict = None) -> httpx.Response:
''' Shows the number of greetings sent to the customers and how many of those resulted in a chat or a goal.
Args:
distribution (str): Allowed values: `hour`, `day`, `day-hours`, `month` or `year`. Defaults to `day`.
timezone (str): IANA Time Zone (e.g. America/Phoenix).
Defaults to the requester's timezone.
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
filters (dict): If none provided, your report will span the last seven days.
payload (dict): Custom payload to be used as request's data.
It overrides all other parameters provided for the method.
headers (dict): Custom headers to be used with session headers.
They will be merged with session-level values that are set,
however, these method-level parameters will not be persisted across requests.
Returns:
httpx.Response: The Response object from `httpx` library,
which contains a server’s response to an HTTP request.
'''
if payload is None:
payload = prepare_payload(locals())
return self.session.post(f'{self.api_url}/chats/greetings_conversion',
json=payload,
headers=headers)

def surveys(self,
timezone: str = None,
filters: dict = None,
payload: dict = None,
headers: dict = None) -> httpx.Response:
''' Returns the number of submitted chat surveys along with the count of specific answers.
Args:
timezone (str): IANA Time Zone (e.g. America/Phoenix).
Defaults to the requester's timezone.
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
filters (dict): If none provided, your report will span the last seven days.
payload (dict): Custom payload to be used as request's data.
It overrides all other parameters provided for the method.
headers (dict): Custom headers to be used with session headers.
They will be merged with session-level values that are set,
however, these method-level parameters will not be persisted across requests.
Returns:
httpx.Response: The Response object from `httpx` library,
which contains a server’s response to an HTTP request.
'''
if payload is None:
payload = prepare_payload(locals())
return self.session.post(f'{self.api_url}/chats/surveys',
json=payload,
headers=headers)

# Agents

def availability(self,
Expand Down Expand Up @@ -452,3 +510,63 @@ def availability(self,
return self.session.post(f'{self.api_url}/agents/availability',
json=payload,
headers=headers)

def response_time(self,
distribution: str = 'day',
timezone: str = None,
filters: dict = None,
payload: dict = None,
headers: dict = None) -> httpx.Response:
''' Shows the average agents' response time within a licence.
Args:
distribution (str): Allowed values: `hour`, `day`, `day-hours`, `month` or `year`. Defaults to `day`.
timezone (str): IANA Time Zone (e.g. America/Phoenix).
Defaults to the requester's timezone.
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
filters (dict): If none provided, your report will span the last seven days.
payload (dict): Custom payload to be used as request's data.
It overrides all other parameters provided for the method.
headers (dict): Custom headers to be used with session headers.
They will be merged with session-level values that are set,
however, these method-level parameters will not be persisted across requests.
Returns:
httpx.Response: The Response object from `httpx` library,
which contains a server’s response to an HTTP request.
'''
if payload is None:
payload = prepare_payload(locals())
return self.session.post(f'{self.api_url}/agents/response_time',
json=payload,
headers=headers)

def first_response_time(self,
distribution: str = 'day',
timezone: str = None,
filters: dict = None,
payload: dict = None,
headers: dict = None) -> httpx.Response:
''' Shows the average agents' first response time within a licence.
Args:
distribution (str): Allowed values: `hour`, `day`, `day-hours`, `month` or `year`. Defaults to `day`.
timezone (str): IANA Time Zone (e.g. America/Phoenix).
Defaults to the requester's timezone.
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
filters (dict): If none provided, your report will span the last seven days.
payload (dict): Custom payload to be used as request's data.
It overrides all other parameters provided for the method.
headers (dict): Custom headers to be used with session headers.
They will be merged with session-level values that are set,
however, these method-level parameters will not be persisted across requests.
Returns:
httpx.Response: The Response object from `httpx` library,
which contains a server’s response to an HTTP request.
'''
if payload is None:
payload = prepare_payload(locals())
return self.session.post(f'{self.api_url}/agents/first_response_time',
json=payload,
headers=headers)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = lc-sdk-python
version = 0.1.9
version = 0.1.10
description = Package which lets to work with LiveChat API.
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit 55967b0

Please sign in to comment.