Skip to content

Commit fcb558b

Browse files
authored
Merge pull request #148 from livechat/add-new-reports-to-v36
Add new reports to v3.6
2 parents f72b5ac + ce2d92e commit fcb558b

File tree

2 files changed

+143
-14
lines changed

2 files changed

+143
-14
lines changed

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [0.4.1] - TBA
5+
6+
### Added
7+
- New `groups`, `queued_visitors`, `queued_visitors_left`, `unique_visitors` methods in reports-api v3.6.
8+
49
## [0.4.0] - 2025-02-14
510

611
### Added

livechat/reports/api/v36.py

Lines changed: 138 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from livechat.utils.http_client import HttpClient
99
from livechat.utils.structures import AccessToken
1010

11+
# pylint: disable=unused-argument,too-many-arguments
12+
1113

1214
class ReportsApiV36(HttpClient):
1315
''' Reports API client class in version 3.6. '''
@@ -47,7 +49,7 @@ def duration(self,
4749
4850
Returns:
4951
httpx.Response: The Response object from `httpx` library,
50-
which contains a servers response to an HTTP request.
52+
which contains a server's response to an HTTP request.
5153
'''
5254
if payload is None:
5355
payload = prepare_payload(locals())
@@ -77,7 +79,7 @@ def tags(self,
7779
7880
Returns:
7981
httpx.Response: The Response object from `httpx` library,
80-
which contains a servers response to an HTTP request.
82+
which contains a server's response to an HTTP request.
8183
'''
8284
if payload is None:
8385
payload = prepare_payload(locals())
@@ -107,7 +109,7 @@ def total_chats(self,
107109
108110
Returns:
109111
httpx.Response: The Response object from `httpx` library,
110-
which contains a servers response to an HTTP request.
112+
which contains a server's response to an HTTP request.
111113
'''
112114
if payload is None:
113115
payload = prepare_payload(locals())
@@ -137,7 +139,7 @@ def ratings(self,
137139
138140
Returns:
139141
httpx.Response: The Response object from `httpx` library,
140-
which contains a servers response to an HTTP request.
142+
which contains a server's response to an HTTP request.
141143
'''
142144
if payload is None:
143145
payload = prepare_payload(locals())
@@ -167,7 +169,7 @@ def ranking(self,
167169
168170
Returns:
169171
httpx.Response: The Response object from `httpx` library,
170-
which contains a servers response to an HTTP request.
172+
which contains a server's response to an HTTP request.
171173
'''
172174
if payload is None:
173175
payload = prepare_payload(locals())
@@ -197,7 +199,7 @@ def engagement(self,
197199
198200
Returns:
199201
httpx.Response: The Response object from `httpx` library,
200-
which contains a servers response to an HTTP request.
202+
which contains a server's response to an HTTP request.
201203
'''
202204
if payload is None:
203205
payload = prepare_payload(locals())
@@ -227,7 +229,7 @@ def greetings_conversion(self,
227229
228230
Returns:
229231
httpx.Response: The Response object from `httpx` library,
230-
which contains a servers response to an HTTP request.
232+
which contains a server's response to an HTTP request.
231233
'''
232234
if payload is None:
233235
payload = prepare_payload(locals())
@@ -255,7 +257,7 @@ def surveys(self,
255257
256258
Returns:
257259
httpx.Response: The Response object from `httpx` library,
258-
which contains a servers response to an HTTP request.
260+
which contains a server's response to an HTTP request.
259261
'''
260262
if payload is None:
261263
payload = prepare_payload(locals())
@@ -285,7 +287,7 @@ def response_time(self,
285287
286288
Returns:
287289
httpx.Response: The Response object from `httpx` library,
288-
which contains a servers response to an HTTP request.
290+
which contains a server's response to an HTTP request.
289291
'''
290292
if payload is None:
291293
payload = prepare_payload(locals())
@@ -315,14 +317,104 @@ def first_response_time(self,
315317
316318
Returns:
317319
httpx.Response: The Response object from `httpx` library,
318-
which contains a servers response to an HTTP request.
320+
which contains a server's response to an HTTP request.
319321
'''
320322
if payload is None:
321323
payload = prepare_payload(locals())
322324
return self.session.post(f'{self.api_url}/chats/first_response_time',
323325
json=payload,
324326
headers=headers)
325327

328+
def groups(self,
329+
distribution: str = None,
330+
timezone: str = None,
331+
filters: dict = None,
332+
payload: dict = None,
333+
headers: dict = None) -> httpx.Response:
334+
''' Shows the total number of chats handled by each group during the specified period.
335+
336+
Args:
337+
distribution (str): Allowed values: `hour`, `day`, `day-hours`, `month` or `year`. Defaults to `day`.
338+
timezone (str): IANA Time Zone (e.g. America/Phoenix).
339+
Defaults to the requester's timezone.
340+
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
341+
filters (dict): If none provided, your report will span the last seven days.
342+
payload (dict): Custom payload to be used as request's data.
343+
It overrides all other parameters provided for the method.
344+
headers (dict): Custom headers to be used with session headers.
345+
They will be merged with session-level values that are set,
346+
however, these method-level parameters will not be persisted across requests.
347+
348+
Returns:
349+
httpx.Response: The Response object from `httpx` library,
350+
which contains a server's response to an HTTP request.
351+
'''
352+
if payload is None:
353+
payload = prepare_payload(locals())
354+
return self.session.post(f'{self.api_url}/chats/groups',
355+
json=payload,
356+
headers=headers)
357+
358+
def queued_visitors(self,
359+
distribution: str = None,
360+
timezone: str = None,
361+
filters: dict = None,
362+
payload: dict = None,
363+
headers: dict = None) -> httpx.Response:
364+
''' Shows how many customers were waiting in the queue during the specified period.
365+
366+
Args:
367+
distribution (str): Allowed values: `hour`, `day`, `day-hours`, `month` or `year`. Defaults to `day`.
368+
timezone (str): IANA Time Zone (e.g. America/Phoenix).
369+
Defaults to the requester's timezone.
370+
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
371+
filters (dict): If none provided, your report will span the last seven days.
372+
payload (dict): Custom payload to be used as request's data.
373+
It overrides all other parameters provided for the method.
374+
headers (dict): Custom headers to be used with session headers.
375+
They will be merged with session-level values that are set,
376+
however, these method-level parameters will not be persisted across requests.
377+
378+
Returns:
379+
httpx.Response: The Response object from `httpx` library,
380+
which contains a server's response to an HTTP request.
381+
'''
382+
if payload is None:
383+
payload = prepare_payload(locals())
384+
return self.session.post(f'{self.api_url}/chats/queued_visitors',
385+
json=payload,
386+
headers=headers)
387+
388+
def queued_visitors_left(self,
389+
distribution: str = None,
390+
timezone: str = None,
391+
filters: dict = None,
392+
payload: dict = None,
393+
headers: dict = None) -> httpx.Response:
394+
''' Shows customers that left the queue during the specified period.
395+
396+
Args:
397+
distribution (str): Allowed values: `hour`, `day`, `day-hours`, `month` or `year`. Defaults to `day`.
398+
timezone (str): IANA Time Zone (e.g. America/Phoenix).
399+
Defaults to the requester's timezone.
400+
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
401+
filters (dict): If none provided, your report will span the last seven days.
402+
payload (dict): Custom payload to be used as request's data.
403+
It overrides all other parameters provided for the method.
404+
headers (dict): Custom headers to be used with session headers.
405+
They will be merged with session-level values that are set,
406+
however, these method-level parameters will not be persisted across requests.
407+
408+
Returns:
409+
httpx.Response: The Response object from `httpx` library,
410+
which contains a server's response to an HTTP request.
411+
'''
412+
if payload is None:
413+
payload = prepare_payload(locals())
414+
return self.session.post(f'{self.api_url}/chats/queued_visitors_left',
415+
json=payload,
416+
headers=headers)
417+
326418
# Agents
327419

328420
def availability(self,
@@ -347,7 +439,7 @@ def availability(self,
347439
348440
Returns:
349441
httpx.Response: The Response object from `httpx` library,
350-
which contains a servers response to an HTTP request.
442+
which contains a server's response to an HTTP request.
351443
'''
352444
if payload is None:
353445
payload = prepare_payload(locals())
@@ -377,15 +469,14 @@ def performance(self,
377469
378470
Returns:
379471
httpx.Response: The Response object from `httpx` library,
380-
which contains a servers response to an HTTP request.
472+
which contains a server's response to an HTTP request.
381473
'''
382474
if payload is None:
383475
payload = prepare_payload(locals())
384476
return self.session.post(f'{self.api_url}/agents/performance',
385477
json=payload,
386478
headers=headers)
387479

388-
389480
# Tags
390481

391482
def chat_usage(self,
@@ -408,10 +499,43 @@ def chat_usage(self,
408499
409500
Returns:
410501
httpx.Response: The Response object from `httpx` library,
411-
which contains a servers response to an HTTP request.
502+
which contains a server's response to an HTTP request.
412503
'''
413504
if payload is None:
414505
payload = prepare_payload(locals())
415506
return self.session.post(f'{self.api_url}/tags/chat_usage',
416507
json=payload,
417508
headers=headers)
509+
510+
511+
# Stats
512+
513+
def unique_visitors(self,
514+
distribution: str = None,
515+
timezone: str = None,
516+
filters: dict = None,
517+
payload: dict = None,
518+
headers: dict = None) -> httpx.Response:
519+
''' Shows the total number of page views and unique visitors for the specified period.
520+
521+
Args:
522+
distribution (str): Allowed values: `hour`, `day`, `day-hours`, `month` or `year`. Defaults to `day`.
523+
timezone (str): IANA Time Zone (e.g. America/Phoenix).
524+
Defaults to the requester's timezone.
525+
When the requester's timezone isn't present, then `filters.from` is parsed to get the timezone.
526+
filters (dict): If none provided, your report will span the last seven days.
527+
payload (dict): Custom payload to be used as request's data.
528+
It overrides all other parameters provided for the method.
529+
headers (dict): Custom headers to be used with session headers.
530+
They will be merged with session-level values that are set,
531+
however, these method-level parameters will not be persisted across requests.
532+
533+
Returns:
534+
httpx.Response: The Response object from `httpx` library,
535+
which contains a server's response to an HTTP request.
536+
'''
537+
if payload is None:
538+
payload = prepare_payload(locals())
539+
return self.session.post(f'{self.api_url}/stats/unique_visitors',
540+
json=payload,
541+
headers=headers)

0 commit comments

Comments
 (0)