0% found this document useful (0 votes)
6 views1 page

Fetch Genesys Conversations API

The document contains a Python class named 'Genesys' that defines a method 'fetch_conversations' for retrieving conversation analytics from a specified API. It constructs a POST request with parameters such as order, pagination, and a time interval, and handles exceptions that may occur during the request. The method returns the response from the API call.

Uploaded by

starkchrom
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Fetch Genesys Conversations API

The document contains a Python class named 'Genesys' that defines a method 'fetch_conversations' for retrieving conversation analytics from a specified API. It constructs a POST request with parameters such as order, pagination, and a time interval, and handles exceptions that may occur during the request. The method returns the response from the API call.

Uploaded by

starkchrom
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import json

import requests

class Genesys:
def fetch_conversations(self, orderBy, pageNumber, interval):
try:
# print(1/0)
base_url = '[Link]
get_conversations_api =
'/api/v2/analytics/conversations/details/query'
url = base_url + get_conversations_api
payload = [Link]({
'order': 'asc', # asc
'orderBy': orderBy, #
conversationStart
"paging": {
"pageSize": 100, # 100
"pageNumber": pageNumber, # 1
},
'interval': interval, # "2024-01-
17T00:00:00.000Z/2024-01-18T00:00:00.000Z"
})
params={}
headers = {
'Authorization': [Link],
'Content-Type': 'application/json'
}
response = [Link]("POST", url,
headers=headers ,data=payload)
return response
except Exception as e:
raise Exception(f"Error in fetch_conversations()\n{str(e)}")

You might also like