Skip to content

Commit

Permalink
Merge pull request #2 from zoho/beta
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
tharunpargi authored Aug 2, 2024
2 parents 1e2d40d + be51f0f commit 125edf9
Show file tree
Hide file tree
Showing 1,701 changed files with 201,476 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ License

## Latest Version

- [2.0.0](/versions/2.0.0/README.md)

- Handled Error Structure in MassDeleteTags API.

- [1.0.0](/versions/1.0.0/README.md)

- Python SDK upgraded to support v7 APIs.
Expand All @@ -48,7 +52,7 @@ For older versions, please [refer](https://github.com/zoho/zohocrm-python-sdk-7.
## Including the SDK in your project
You can include the SDK to your project using:

- For including the latest [version](https://github.com/zoho/zohocrm-python-sdk-7.0/releases/tag/1.0.0)
- For including the latest [version](https://github.com/zoho/zohocrm-python-sdk-7.0/releases/tag/2.0.0)

- Install **Python** from [python.org](https://www.python.org/downloads/) (if not installed).

Expand All @@ -75,4 +79,4 @@ For example, if you generate the tokens for your Sandbox environment in the CN d

---

For more details, kindly refer [here](/versions/1.0.0/README.md).
For more details, kindly refer [here](/versions/2.0.0/README.md).
9 changes: 9 additions & 0 deletions samples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
from . import coql
from . import record
from . import modules
from . import apis
from . import audit_log_export
from .import cadences_execution
from . import duplicate_check_preference
from . import features
from .import mass_delete_tags
from . import picklist_values
from .import zia_org_enrrichment
from .import zia_people_enrichment
63 changes: 63 additions & 0 deletions samples/apis/GetSupportedAPI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from zohocrmsdk.src.com.zoho.api.authenticator.oauth_token import OAuthToken
from zohocrmsdk.src.com.zoho.crm.api.dc.us_data_center import USDataCenter
from zohocrmsdk.src.com.zoho.crm.api.initializer import Initializer
from zohocrmsdk.src.com.zoho.crm.api.apis.apis_operations import APIsOperations
from zohocrmsdk.src.com.zoho.crm.api.apis.response_handler import ResponseHandler
from zohocrmsdk.src.com.zoho.crm.api.apis.api_exception import APIException
from zohocrmsdk.src.com.zoho.crm.api.util.api_response import APIResponse


class GetSupportedAPI:

@staticmethod
def initialize():
environment = USDataCenter.PRODUCTION()
token = OAuthToken(client_id='Client_Id', client_secret='Client_Secret', refresh_token='Refresh_Token')
Initializer.initialize(environment, token)

@staticmethod
def get_supported_api():
filters = None
apis_operations = APIsOperations(filters)
response = apis_operations.get_supported_api()

if response is not None:
print("Status Code: " + str(response.get_status_code()))

if response.get_status_code() == 204:
print("No Content")
return

response_handler = response.get_object()

if isinstance(response_handler, ResponseHandler):
response_wrapper = response_handler

if hasattr(response_wrapper, 'get_apis'):
apis = response_wrapper.get_apis()

if apis is not None:
for api in apis:
print("API Path: " + api.get_path())
operation_types = api.get_operation_types()

for operation_type in operation_types:
print("API Operation Method: " + operation_type.get_method())
print("API Operation OAuthScope: " + operation_type.get_oauth_scope())
print("API Operation MaxCredits: " + str(operation_type.get_max_credits()))
print("API Operation MinCredits: " + str(operation_type.get_min_credits()))
elif isinstance(response_handler, APIException):
exception = response_handler
print("Status: " + exception.get_status().get_value())
print("Code: " + exception.get_code().get_value())
print("Details: ")

for key, value in exception.get_details().items():
print(key + ": " + str(value))

print("Message: " + exception.get_message())



GetSupportedAPI.initialize()
GetSupportedAPI.get_supported_api()
1 change: 1 addition & 0 deletions samples/apis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .GetSupportedAPI import GetSupportedAPI
98 changes: 98 additions & 0 deletions samples/audit_log_export/CreateAuditlogExport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import json
from datetime import datetime
from zohocrmsdk.src.com.zoho.api.authenticator.oauth_token import OAuthToken
from zohocrmsdk.src.com.zoho.crm.api.dc.us_data_center import USDataCenter
from zohocrmsdk.src.com.zoho.crm.api.initializer import Initializer
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.audit_log_export_operations import AuditLogExportOperations
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.body_wrapper import BodyWrapper
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.criteria import Criteria
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.field import Field as AuditField
from zohocrmsdk.src.com.zoho.crm.api.util.api_response import APIResponse
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.action_handler import ActionHandler
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.action_wrapper import ActionWrapper
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.success_response import SuccessResponse
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.api_exception import APIException
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export import AuditLogExport
from zohocrmsdk.src.com.zoho.crm.api.dc import INDataCenter


class CreateAuditlogExport:

@staticmethod
def initialize():
environment = USDataCenter.PRODUCTION()
token = OAuthToken(client_id='Client_Id', client_secret='Client_Secret', refresh_token='Refresh_Token')
Initializer.initialize(environment, token)

@staticmethod
def create_auditlog_export():
audit_log_export_operations = AuditLogExportOperations()
request = BodyWrapper()
audit_log_export = []

audit_log_export1 = AuditLogExport()
criteria = Criteria()
criteria.set_comparator("between")

field = AuditField()
field.set_api_name("audited_time")
criteria.set_field(field)

values = [
datetime(2024, 1, 2, 10, 0, 0, 0),
datetime(2024, 1, 3, 10, 0, 0, 0)
]
criteria.set_value(values)

audit_log_export1.set_criteria(criteria)
audit_log_export.append(audit_log_export1)
request.set_audit_log_export(audit_log_export)

response = audit_log_export_operations.create_auditlog_export(request)

if response is not None:
print("Status Code: " + str(response.get_status_code()))

action_handler = response.get_object()

if isinstance(action_handler, ActionWrapper):
action_wrapper = action_handler
action_responses = action_wrapper.get_audit_log_export()

for action_response in action_responses:
if isinstance(action_response, SuccessResponse):
success_response = action_response
print("Status: " + success_response.get_status().get_value())
print("Code: " + success_response.get_code().get_value())
print("Details: ")
for key, value in success_response.get_details().items():
print(f"{key}: {value}")
print("Message: " + success_response.get_message())
elif isinstance(action_response, APIException):
exception = action_response
print("Status: " + exception.get_status().get_value())
print("Code: " + exception.get_code().get_value())
print("Details: ")
for key, value in exception.get_details().items():
print(f"{key}: {value}")
print("Message: " + exception.get_message())
elif isinstance(action_handler, APIException):
exception = action_handler
print("Status: " + exception.get_status().get_value())
print("Code: " + exception.get_code().get_value())
print("Details: ")
for key, value in exception.get_details().items():
print(f"{key}: {value}")
print("Message: " + exception.get_message())
else:
response_object = response.get_model()
response_dict = response_object.__dict__

for key, value in response_dict.items():
print(f"{key}: {value}")




CreateAuditlogExport.initialize()
CreateAuditlogExport.create_auditlog_export()
86 changes: 86 additions & 0 deletions samples/audit_log_export/GetExportedAuditlog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import os
from zohocrmsdk.src.com.zoho.api.authenticator.oauth_token import OAuthToken
from zohocrmsdk.src.com.zoho.crm.api.dc.us_data_center import USDataCenter
from zohocrmsdk.src.com.zoho.crm.api.initializer import Initializer
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.api_exception import APIException
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.audit_log_export_operations import AuditLogExportOperations
from zohocrmsdk.src.com.zoho.crm.api.util.api_response import APIResponse


class GetExportedAuditLog:


@staticmethod
def initialize():
environment = USDataCenter.PRODUCTION()
token = OAuthToken(client_id='Client_Id', client_secret='Client_Secret', refresh_token='Refresh_Token')
Initializer.initialize(environment, token)

@staticmethod
def get_exported_auditlog(id1):
audit_log_export_operations = AuditLogExportOperations()
response = audit_log_export_operations.get_exported_auditlog(id1)

if response is not None:
print("Status Code: " + str(response.get_status_code()))

if response.get_status_code() == 204:
print("No Content")
return

response_handler = response.get_object()

if hasattr(response_handler, 'get_audit_log_export'):
response_wrapper = response_handler
audit_log_export = response_wrapper.get_audit_log_export()

if audit_log_export is not None:
for audit_log_export1 in audit_log_export:
criteria = audit_log_export1.get_criteria()
if criteria is not None:
GetExportedAuditLog.print_criteria(criteria)
print("AuditLogExport Id : " + str(audit_log_export1.get_id()))
print("AuditLogExport Status : " + str(audit_log_export1.get_status()))
created_by = audit_log_export1.get_created_by()
if created_by is not None:
print("AuditLogExport User Id : " + str(created_by.get_id()))
print("AuditLogExport User Name : " + str(created_by.get_name()))
download_links = audit_log_export1.get_download_links()
if download_links != None:
for link in download_links:
print("AuditLogExport DownloadLink : " + link)
print("AuditLogExport JobStartTime : " + str(audit_log_export1.get_job_start_time()))
print("AuditLogExport JobEndTime : " + str(audit_log_export1.get_job_end_time()))
print("AuditLogExport ExpiryDate : " + str(audit_log_export1.get_expiry_date()))

elif isinstance(response_handler, APIException):
exception = response_handler
print("Status: " + exception.get_status().get_value())
print("Code: " + exception.get_code().get_value())
print("Details: ")
for key, value in exception.get_details().items():
print(key + ": " + str(value))
print("Message: " + exception.get_message())


@staticmethod
def print_criteria(criteria):
if criteria.get_comparator() is not None:
print("ExportedAuditlogs Criteria Comparator: " + criteria.get_comparator())
if criteria.get_value() is not None:
print("ExportedAuditlogs Criteria Value: " + str(criteria.get_value()))
if criteria.get_field() is not None:
print("ExportedAuditlogs Criteria field name: " + criteria.get_field().get_api_name())
criteria_group = criteria.get_group()
if criteria_group is not None:
for criteria1 in criteria_group:
GetExportedAuditLog.print_criteria(criteria1)
if criteria.get_group_operator() is not None:
print("ExportedAuditlogs Criteria Group Operator: " + criteria.get_group_operator())




GetExportedAuditLog.initialize()
id = 72722554001
GetExportedAuditLog.get_exported_auditlog(id)
91 changes: 91 additions & 0 deletions samples/audit_log_export/GetExportedAuditlogs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import os
from zohocrmsdk.src.com.zoho.api.authenticator.oauth_token import OAuthToken
from zohocrmsdk.src.com.zoho.crm.api.dc.us_data_center import USDataCenter
from zohocrmsdk.src.com.zoho.crm.api.initializer import Initializer
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.api_exception import APIException
from zohocrmsdk.src.com.zoho.crm.api.audit_log_export.audit_log_export_operations import AuditLogExportOperations
from zohocrmsdk.src.com.zoho.crm.api.util.api_response import APIResponse


class GetExportedAuditlogs:


@staticmethod
def initialize():
environment = USDataCenter.PRODUCTION()
token = OAuthToken(client_id='Client_Id', client_secret='Client_Secret', refresh_token='Refresh_Token')
Initializer.initialize(environment, token)

@staticmethod
def get_exported_auditlogs():
audit_log_export_operations = AuditLogExportOperations()
response = audit_log_export_operations.get_exported_auditlogs()

if response is not None:
print("Status Code: " + str(response.get_status_code()))

if response.get_status_code() == 204:
print("No Content")
return

response_handler = response.get_object()

if hasattr(response_handler, 'get_audit_log_export'):
response_wrapper = response_handler
audit_log_export = response_wrapper.get_audit_log_export()

if audit_log_export is not None:
for audit_log_export1 in audit_log_export:
criteria = audit_log_export1.get_criteria()
if criteria is not None:
GetExportedAuditlogs.print_criteria(criteria)
print("AuditLogExport Id : " + str(audit_log_export1.get_id()))
print("AuditLogExport Status : " + str(audit_log_export1.get_status()))
created_by = audit_log_export1.get_created_by()
if created_by is not None:
print("AuditLogExport User Id : " + str(created_by.get_id()))
print("AuditLogExport User Name : " + str(created_by.get_name()))
download_links = audit_log_export1.get_download_links()
if download_links != None:
for link in download_links:
print("AuditLogExport DownloadLink : " + link)
print("AuditLogExport JobStartTime : " + str(audit_log_export1.get_job_start_time()))
print("AuditLogExport JobEndTime : " + str(audit_log_export1.get_job_end_time()))
print("AuditLogExport ExpiryDate : " + str(audit_log_export1.get_expiry_date()))

elif isinstance(response_handler, APIException):
exception = response_handler
print("Status: " + exception.get_status().get_value())
print("Code: " + exception.get_code().get_value())
print("Details: ")
for key, value in exception.get_details().items():
print(key + ": " + str(value))
print("Message: " + exception.get_message())
else:
if response.get_status_code() != 204:
response_object = response.get_model()
response_dict = response_object.__dict__

for key, value in response_dict.items():
print(key + ": " + str(value))


@staticmethod
def print_criteria(criteria):
if criteria.get_comparator() is not None:
print("ExportedAuditlogs Criteria Comparator: " + criteria.get_comparator())
if criteria.get_value() is not None:
print("ExportedAuditlogs Criteria Value: " + str(criteria.get_value()))
if criteria.get_field() is not None:
print("ExportedAuditlogs Criteria field name: " + criteria.get_field().get_api_name())
criteria_group = criteria.get_group()
if criteria_group is not None:
for criteria1 in criteria_group:
GetExportedAuditlogs.print_criteria(criteria1)
if criteria.get_group_operator() is not None:
print("ExportedAuditlogs Criteria Group Operator: " + criteria.get_group_operator())


GetExportedAuditlogs.initialize()
GetExportedAuditlogs.get_exported_auditlogs()

3 changes: 3 additions & 0 deletions samples/audit_log_export/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .GetExportedAuditlogs import GetExportedAuditlogs
from .CreateAuditlogExport import CreateAuditlogExport
from .GetExportedAuditlog import GetExportedAuditLog
Loading

0 comments on commit 125edf9

Please sign in to comment.