code
stringlengths
501
5.19M
package
stringlengths
2
81
path
stringlengths
9
304
filename
stringlengths
4
145
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.attachments.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__data = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/attachments/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.attachments.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__data = None self.__info = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def get_info(self): """ The method to get the info Returns: Info: An instance of Info """ return self.__info def set_info(self, info): """ The method to set the value to info Parameters: info (Info) : An instance of Info """ try: from zcrmsdk.src.com.zoho.crm.api.record import Info except Exception: from ..record import Info if info is not None and not isinstance(info, Info): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Info', None, None) self.__info = info self.__key_modified['info'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/attachments/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.attachments.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.attachments.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.attachments.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .action_handler import ActionHandler class APIException(ResponseHandler, ActionResponse, ActionHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/attachments/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import StreamWrapper, Constants from zcrmsdk.src.com.zoho.crm.api.attachments.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import StreamWrapper, Constants from .response_handler import ResponseHandler class FileBodyWrapper(ResponseHandler): def __init__(self): """Creates an instance of FileBodyWrapper""" super().__init__() self.__file = None self.__key_modified = dict() def get_file(self): """ The method to get the file Returns: StreamWrapper: An instance of StreamWrapper """ return self.__file def set_file(self, file): """ The method to set the value to file Parameters: file (StreamWrapper) : An instance of StreamWrapper """ if file is not None and not isinstance(file, StreamWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file EXPECTED TYPE: StreamWrapper', None, None) self.__file = file self.__key_modified['file'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/attachments/file_body_wrapper.py
file_body_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Attachment(object): def __init__(self): """Creates an instance of Attachment""" self.__owner = None self.__modified_time = None self.__file_name = None self.__created_time = None self.__size = None self.__parent_id = None self.__editable = None self.__sharing_permission = None self.__file_id = None self.__type = None self.__se_module = None self.__modified_by = None self.__attachment_type = None self.__state = None self.__id = None self.__created_by = None self.__link_url = None self.__description = None self.__category = None self.__key_modified = dict() def get_owner(self): """ The method to get the owner Returns: User: An instance of User """ return self.__owner def set_owner(self, owner): """ The method to set the value to owner Parameters: owner (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if owner is not None and not isinstance(owner, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: owner EXPECTED TYPE: User', None, None) self.__owner = owner self.__key_modified['Owner'] = 1 def get_modified_time(self): """ The method to get the modified_time Returns: datetime: An instance of datetime """ return self.__modified_time def set_modified_time(self, modified_time): """ The method to set the value to modified_time Parameters: modified_time (datetime) : An instance of datetime """ from datetime import datetime if modified_time is not None and not isinstance(modified_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_time EXPECTED TYPE: datetime', None, None) self.__modified_time = modified_time self.__key_modified['Modified_Time'] = 1 def get_file_name(self): """ The method to get the file_name Returns: string: A string representing the file_name """ return self.__file_name def set_file_name(self, file_name): """ The method to set the value to file_name Parameters: file_name (string) : A string representing the file_name """ if file_name is not None and not isinstance(file_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file_name EXPECTED TYPE: str', None, None) self.__file_name = file_name self.__key_modified['File_Name'] = 1 def get_created_time(self): """ The method to get the created_time Returns: datetime: An instance of datetime """ return self.__created_time def set_created_time(self, created_time): """ The method to set the value to created_time Parameters: created_time (datetime) : An instance of datetime """ from datetime import datetime if created_time is not None and not isinstance(created_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_time EXPECTED TYPE: datetime', None, None) self.__created_time = created_time self.__key_modified['Created_Time'] = 1 def get_size(self): """ The method to get the size Returns: int: An int representing the size """ return self.__size def set_size(self, size): """ The method to set the value to size Parameters: size (int) : An int representing the size """ if size is not None and not isinstance(size, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: size EXPECTED TYPE: int', None, None) self.__size = size self.__key_modified['Size'] = 1 def get_parent_id(self): """ The method to get the parent_id Returns: Record: An instance of Record """ return self.__parent_id def set_parent_id(self, parent_id): """ The method to set the value to parent_id Parameters: parent_id (Record) : An instance of Record """ try: from zcrmsdk.src.com.zoho.crm.api.record import Record except Exception: from ..record import Record if parent_id is not None and not isinstance(parent_id, Record): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: parent_id EXPECTED TYPE: Record', None, None) self.__parent_id = parent_id self.__key_modified['Parent_Id'] = 1 def get_editable(self): """ The method to get the editable Returns: bool: A bool representing the editable """ return self.__editable def set_editable(self, editable): """ The method to set the value to editable Parameters: editable (bool) : A bool representing the editable """ if editable is not None and not isinstance(editable, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: editable EXPECTED TYPE: bool', None, None) self.__editable = editable self.__key_modified['$editable'] = 1 def get_sharing_permission(self): """ The method to get the sharing_permission Returns: string: A string representing the sharing_permission """ return self.__sharing_permission def set_sharing_permission(self, sharing_permission): """ The method to set the value to sharing_permission Parameters: sharing_permission (string) : A string representing the sharing_permission """ if sharing_permission is not None and not isinstance(sharing_permission, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: sharing_permission EXPECTED TYPE: str', None, None) self.__sharing_permission = sharing_permission self.__key_modified['$sharing_permission'] = 1 def get_file_id(self): """ The method to get the file_id Returns: string: A string representing the file_id """ return self.__file_id def set_file_id(self, file_id): """ The method to set the value to file_id Parameters: file_id (string) : A string representing the file_id """ if file_id is not None and not isinstance(file_id, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file_id EXPECTED TYPE: str', None, None) self.__file_id = file_id self.__key_modified['$file_id'] = 1 def get_type(self): """ The method to get the type Returns: string: A string representing the type """ return self.__type def set_type(self, type): """ The method to set the value to type Parameters: type (string) : A string representing the type """ if type is not None and not isinstance(type, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: type EXPECTED TYPE: str', None, None) self.__type = type self.__key_modified['$type'] = 1 def get_se_module(self): """ The method to get the se_module Returns: string: A string representing the se_module """ return self.__se_module def set_se_module(self, se_module): """ The method to set the value to se_module Parameters: se_module (string) : A string representing the se_module """ if se_module is not None and not isinstance(se_module, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: se_module EXPECTED TYPE: str', None, None) self.__se_module = se_module self.__key_modified['$se_module'] = 1 def get_modified_by(self): """ The method to get the modified_by Returns: User: An instance of User """ return self.__modified_by def set_modified_by(self, modified_by): """ The method to set the value to modified_by Parameters: modified_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if modified_by is not None and not isinstance(modified_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_by EXPECTED TYPE: User', None, None) self.__modified_by = modified_by self.__key_modified['Modified_By'] = 1 def get_attachment_type(self): """ The method to get the attachment_type Returns: int: An int representing the attachment_type """ return self.__attachment_type def set_attachment_type(self, attachment_type): """ The method to set the value to attachment_type Parameters: attachment_type (int) : An int representing the attachment_type """ if attachment_type is not None and not isinstance(attachment_type, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: attachment_type EXPECTED TYPE: int', None, None) self.__attachment_type = attachment_type self.__key_modified['$attachment_type'] = 1 def get_state(self): """ The method to get the state Returns: string: A string representing the state """ return self.__state def set_state(self, state): """ The method to set the value to state Parameters: state (string) : A string representing the state """ if state is not None and not isinstance(state, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: state EXPECTED TYPE: str', None, None) self.__state = state self.__key_modified['$state'] = 1 def get_id(self): """ The method to get the id Returns: string: A string representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (string) : A string representing the id """ if id is not None and not isinstance(id, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: str', None, None) self.__id = id self.__key_modified['id'] = 1 def get_created_by(self): """ The method to get the created_by Returns: User: An instance of User """ return self.__created_by def set_created_by(self, created_by): """ The method to set the value to created_by Parameters: created_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_by is not None and not isinstance(created_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_by EXPECTED TYPE: User', None, None) self.__created_by = created_by self.__key_modified['Created_By'] = 1 def get_link_url(self): """ The method to get the link_url Returns: string: A string representing the link_url """ return self.__link_url def set_link_url(self, link_url): """ The method to set the value to link_url Parameters: link_url (string) : A string representing the link_url """ if link_url is not None and not isinstance(link_url, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: link_url EXPECTED TYPE: str', None, None) self.__link_url = link_url self.__key_modified['$link_url'] = 1 def get_description(self): """ The method to get the description Returns: string: A string representing the description """ return self.__description def set_description(self, description): """ The method to set the value to description Parameters: description (string) : A string representing the description """ if description is not None and not isinstance(description, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: description EXPECTED TYPE: str', None, None) self.__description = description self.__key_modified['description'] = 1 def get_category(self): """ The method to get the category Returns: string: A string representing the category """ return self.__category def set_category(self, category): """ The method to set the value to category Parameters: category (string) : A string representing the category """ if category is not None and not isinstance(category, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: category EXPECTED TYPE: str', None, None) self.__category = category self.__key_modified['category'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/attachments/attachment.py
attachment.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class AttachmentsOperations(object): def __init__(self, module_api_name, record_id): """ Creates an instance of AttachmentsOperations with the given parameters Parameters: module_api_name (string) : A string representing the module_api_name record_id (int) : An int representing the record_id """ if not isinstance(module_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module_api_name EXPECTED TYPE: str', None, None) if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) self.__module_api_name = module_api_name self.__record_id = record_id def download_attachment(self, id): """ The method to download attachment Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/Attachments/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) try: from zcrmsdk.src.com.zoho.crm.api.attachments.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/x-download') def delete_attachment(self, id): """ The method to delete attachment Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/Attachments/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) try: from zcrmsdk.src.com.zoho.crm.api.attachments.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_attachments(self, param_instance=None): """ The method to get attachments Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/Attachments' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.attachments.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def upload_attachment(self, request): """ The method to upload attachment Parameters: request (FileBodyWrapper) : An instance of FileBodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.attachments.file_body_wrapper import FileBodyWrapper except Exception: from .file_body_wrapper import FileBodyWrapper if request is not None and not isinstance(request, FileBodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: FileBodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/Attachments' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('multipart/form-data') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.attachments.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def upload_link_attachment(self, param_instance=None): """ The method to upload link attachment Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/Attachments' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.attachments.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delete_attachments(self, param_instance=None): """ The method to delete attachments Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/Attachments' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.attachments.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') class GetAttachmentsParam(object): fields = Param('fields', 'com.zoho.crm.api.Attachments.GetAttachmentsParam') page = Param('page', 'com.zoho.crm.api.Attachments.GetAttachmentsParam') per_page = Param('per_page', 'com.zoho.crm.api.Attachments.GetAttachmentsParam') class UploadLinkAttachmentParam(object): attachmenturl = Param('attachmentUrl', 'com.zoho.crm.api.Attachments.UploadLinkAttachmentParam') class DeleteAttachmentsParam(object): ids = Param('ids', 'com.zoho.crm.api.Attachments.DeleteAttachmentsParam')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/attachments/attachments_operations.py
attachments_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.attachments.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__code = None self.__details = None self.__message = None self.__status = None self.__key_modified = dict() def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/attachments/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.notification.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__watch = None self.__key_modified = dict() def get_watch(self): """ The method to get the watch Returns: list: An instance of list """ return self.__watch def set_watch(self, watch): """ The method to set the value to watch Parameters: watch (list) : An instance of list """ if watch is not None and not isinstance(watch, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: watch EXPECTED TYPE: list', None, None) self.__watch = watch self.__key_modified['watch'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notification/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.notification.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__watch = None self.__info = None self.__key_modified = dict() def get_watch(self): """ The method to get the watch Returns: list: An instance of list """ return self.__watch def set_watch(self, watch): """ The method to set the value to watch Parameters: watch (list) : An instance of list """ if watch is not None and not isinstance(watch, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: watch EXPECTED TYPE: list', None, None) self.__watch = watch self.__key_modified['watch'] = 1 def get_info(self): """ The method to get the info Returns: Info: An instance of Info """ return self.__info def set_info(self, info): """ The method to set the value to info Parameters: info (Info) : An instance of Info """ try: from zcrmsdk.src.com.zoho.crm.api.notification.info import Info except Exception: from .info import Info if info is not None and not isinstance(info, Info): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Info', None, None) self.__info = info self.__key_modified['info'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notification/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.notification.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.notification.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.notification.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .action_handler import ActionHandler class APIException(ActionResponse, ActionHandler, ResponseHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notification/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Info(object): def __init__(self): """Creates an instance of Info""" self.__per_page = None self.__count = None self.__page = None self.__more_records = None self.__key_modified = dict() def get_per_page(self): """ The method to get the per_page Returns: int: An int representing the per_page """ return self.__per_page def set_per_page(self, per_page): """ The method to set the value to per_page Parameters: per_page (int) : An int representing the per_page """ if per_page is not None and not isinstance(per_page, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: per_page EXPECTED TYPE: int', None, None) self.__per_page = per_page self.__key_modified['per_page'] = 1 def get_count(self): """ The method to get the count Returns: int: An int representing the count """ return self.__count def set_count(self, count): """ The method to set the value to count Parameters: count (int) : An int representing the count """ if count is not None and not isinstance(count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: count EXPECTED TYPE: int', None, None) self.__count = count self.__key_modified['count'] = 1 def get_page(self): """ The method to get the page Returns: int: An int representing the page """ return self.__page def set_page(self, page): """ The method to set the value to page Parameters: page (int) : An int representing the page """ if page is not None and not isinstance(page, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: page EXPECTED TYPE: int', None, None) self.__page = page self.__key_modified['page'] = 1 def get_more_records(self): """ The method to get the more_records Returns: bool: A bool representing the more_records """ return self.__more_records def set_more_records(self, more_records): """ The method to set the value to more_records Parameters: more_records (bool) : A bool representing the more_records """ if more_records is not None and not isinstance(more_records, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: more_records EXPECTED TYPE: bool', None, None) self.__more_records = more_records self.__key_modified['more_records'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notification/info.py
info.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Notification(object): def __init__(self): """Creates an instance of Notification""" self.__channel_expiry = None self.__resource_uri = None self.__resource_id = None self.__notify_url = None self.__resource_name = None self.__channel_id = None self.__events = None self.__token = None self.__notify_on_related_action = None self.__fields = None self.__deleteevents = None self.__key_modified = dict() def get_channel_expiry(self): """ The method to get the channel_expiry Returns: datetime: An instance of datetime """ return self.__channel_expiry def set_channel_expiry(self, channel_expiry): """ The method to set the value to channel_expiry Parameters: channel_expiry (datetime) : An instance of datetime """ from datetime import datetime if channel_expiry is not None and not isinstance(channel_expiry, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: channel_expiry EXPECTED TYPE: datetime', None, None) self.__channel_expiry = channel_expiry self.__key_modified['channel_expiry'] = 1 def get_resource_uri(self): """ The method to get the resource_uri Returns: string: A string representing the resource_uri """ return self.__resource_uri def set_resource_uri(self, resource_uri): """ The method to set the value to resource_uri Parameters: resource_uri (string) : A string representing the resource_uri """ if resource_uri is not None and not isinstance(resource_uri, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: resource_uri EXPECTED TYPE: str', None, None) self.__resource_uri = resource_uri self.__key_modified['resource_uri'] = 1 def get_resource_id(self): """ The method to get the resource_id Returns: string: A string representing the resource_id """ return self.__resource_id def set_resource_id(self, resource_id): """ The method to set the value to resource_id Parameters: resource_id (string) : A string representing the resource_id """ if resource_id is not None and not isinstance(resource_id, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: resource_id EXPECTED TYPE: str', None, None) self.__resource_id = resource_id self.__key_modified['resource_id'] = 1 def get_notify_url(self): """ The method to get the notify_url Returns: string: A string representing the notify_url """ return self.__notify_url def set_notify_url(self, notify_url): """ The method to set the value to notify_url Parameters: notify_url (string) : A string representing the notify_url """ if notify_url is not None and not isinstance(notify_url, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: notify_url EXPECTED TYPE: str', None, None) self.__notify_url = notify_url self.__key_modified['notify_url'] = 1 def get_resource_name(self): """ The method to get the resource_name Returns: string: A string representing the resource_name """ return self.__resource_name def set_resource_name(self, resource_name): """ The method to set the value to resource_name Parameters: resource_name (string) : A string representing the resource_name """ if resource_name is not None and not isinstance(resource_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: resource_name EXPECTED TYPE: str', None, None) self.__resource_name = resource_name self.__key_modified['resource_name'] = 1 def get_channel_id(self): """ The method to get the channel_id Returns: int: An int representing the channel_id """ return self.__channel_id def set_channel_id(self, channel_id): """ The method to set the value to channel_id Parameters: channel_id (int) : An int representing the channel_id """ if channel_id is not None and not isinstance(channel_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: channel_id EXPECTED TYPE: int', None, None) self.__channel_id = channel_id self.__key_modified['channel_id'] = 1 def get_events(self): """ The method to get the events Returns: list: An instance of list """ return self.__events def set_events(self, events): """ The method to set the value to events Parameters: events (list) : An instance of list """ if events is not None and not isinstance(events, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: events EXPECTED TYPE: list', None, None) self.__events = events self.__key_modified['events'] = 1 def get_token(self): """ The method to get the token Returns: string: A string representing the token """ return self.__token def set_token(self, token): """ The method to set the value to token Parameters: token (string) : A string representing the token """ if token is not None and not isinstance(token, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: token EXPECTED TYPE: str', None, None) self.__token = token self.__key_modified['token'] = 1 def get_notify_on_related_action(self): """ The method to get the notify_on_related_action Returns: bool: A bool representing the notify_on_related_action """ return self.__notify_on_related_action def set_notify_on_related_action(self, notify_on_related_action): """ The method to set the value to notify_on_related_action Parameters: notify_on_related_action (bool) : A bool representing the notify_on_related_action """ if notify_on_related_action is not None and not isinstance(notify_on_related_action, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: notify_on_related_action EXPECTED TYPE: bool', None, None) self.__notify_on_related_action = notify_on_related_action self.__key_modified['notify_on_related_action'] = 1 def get_fields(self): """ The method to get the fields Returns: dict: An instance of dict """ return self.__fields def set_fields(self, fields): """ The method to set the value to fields Parameters: fields (dict) : An instance of dict """ if fields is not None and not isinstance(fields, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: fields EXPECTED TYPE: dict', None, None) self.__fields = fields self.__key_modified['fields'] = 1 def get_deleteevents(self): """ The method to get the deleteevents Returns: bool: A bool representing the deleteevents """ return self.__deleteevents def set_deleteevents(self, deleteevents): """ The method to set the value to deleteevents Parameters: deleteevents (bool) : A bool representing the deleteevents """ if deleteevents is not None and not isinstance(deleteevents, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: deleteevents EXPECTED TYPE: bool', None, None) self.__deleteevents = deleteevents self.__key_modified['_delete_events'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notification/notification.py
notification.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.notification.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notification/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class NotificationOperations(object): def __init__(self): """Creates an instance of NotificationOperations""" pass def enable_notifications(self, request): """ The method to enable notifications Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.notification.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/actions/watch' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.notification.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_notification_details(self, param_instance=None): """ The method to get notification details Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/actions/watch' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.notification.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def update_notifications(self, request): """ The method to update notifications Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.notification.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/actions/watch' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.notification.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def update_notification(self, request): """ The method to update notification Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.notification.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/actions/watch' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PATCH) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.notification.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def disable_notifications(self, param_instance=None): """ The method to disable notifications Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/actions/watch' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.notification.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def disable_notification(self, request): """ The method to disable notification Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.notification.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/actions/watch' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PATCH) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.notification.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') class GetNotificationDetailsParam(object): page = Param('page', 'com.zoho.crm.api.Notification.GetNotificationDetailsParam') per_page = Param('per_page', 'com.zoho.crm.api.Notification.GetNotificationDetailsParam') channel_id = Param('channel_id', 'com.zoho.crm.api.Notification.GetNotificationDetailsParam') module = Param('module', 'com.zoho.crm.api.Notification.GetNotificationDetailsParam') class DisableNotificationsParam(object): channel_ids = Param('channel_ids', 'com.zoho.crm.api.Notification.DisableNotificationsParam')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notification/notification_operations.py
notification_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.taxes.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__taxes = None self.__key_modified = dict() def get_taxes(self): """ The method to get the taxes Returns: list: An instance of list """ return self.__taxes def set_taxes(self, taxes): """ The method to set the value to taxes Parameters: taxes (list) : An instance of list """ if taxes is not None and not isinstance(taxes, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: taxes EXPECTED TYPE: list', None, None) self.__taxes = taxes self.__key_modified['taxes'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/taxes/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.taxes.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__taxes = None self.__preference = None self.__key_modified = dict() def get_taxes(self): """ The method to get the taxes Returns: list: An instance of list """ return self.__taxes def set_taxes(self, taxes): """ The method to set the value to taxes Parameters: taxes (list) : An instance of list """ if taxes is not None and not isinstance(taxes, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: taxes EXPECTED TYPE: list', None, None) self.__taxes = taxes self.__key_modified['taxes'] = 1 def get_preference(self): """ The method to get the preference Returns: Preference: An instance of Preference """ return self.__preference def set_preference(self, preference): """ The method to set the value to preference Parameters: preference (Preference) : An instance of Preference """ try: from zcrmsdk.src.com.zoho.crm.api.taxes.preference import Preference except Exception: from .preference import Preference if preference is not None and not isinstance(preference, Preference): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: preference EXPECTED TYPE: Preference', None, None) self.__preference = preference self.__key_modified['preference'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/taxes/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.taxes.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.taxes.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.taxes.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .action_handler import ActionHandler class APIException(ResponseHandler, ActionResponse, ActionHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/taxes/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Preference(object): def __init__(self): """Creates an instance of Preference""" self.__auto_populate_tax = None self.__modify_tax_rates = None self.__key_modified = dict() def get_auto_populate_tax(self): """ The method to get the auto_populate_tax Returns: bool: A bool representing the auto_populate_tax """ return self.__auto_populate_tax def set_auto_populate_tax(self, auto_populate_tax): """ The method to set the value to auto_populate_tax Parameters: auto_populate_tax (bool) : A bool representing the auto_populate_tax """ if auto_populate_tax is not None and not isinstance(auto_populate_tax, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: auto_populate_tax EXPECTED TYPE: bool', None, None) self.__auto_populate_tax = auto_populate_tax self.__key_modified['auto_populate_tax'] = 1 def get_modify_tax_rates(self): """ The method to get the modify_tax_rates Returns: bool: A bool representing the modify_tax_rates """ return self.__modify_tax_rates def set_modify_tax_rates(self, modify_tax_rates): """ The method to set the value to modify_tax_rates Parameters: modify_tax_rates (bool) : A bool representing the modify_tax_rates """ if modify_tax_rates is not None and not isinstance(modify_tax_rates, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modify_tax_rates EXPECTED TYPE: bool', None, None) self.__modify_tax_rates = modify_tax_rates self.__key_modified['modify_tax_rates'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/taxes/preference.py
preference.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class TaxesOperations(object): def __init__(self): """Creates an instance of TaxesOperations""" pass def get_taxes(self): """ The method to get taxes Returns: APIResponse: An instance of APIResponse Raises: SDKException """ handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/taxes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) try: from zcrmsdk.src.com.zoho.crm.api.taxes.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def create_taxes(self, request): """ The method to create taxes Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.taxes.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/taxes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.taxes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def update_taxes(self, request): """ The method to update taxes Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.taxes.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/taxes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.taxes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delete_taxes(self, param_instance=None): """ The method to delete taxes Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/taxes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.taxes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_tax(self, id): """ The method to get tax Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/taxes/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) try: from zcrmsdk.src.com.zoho.crm.api.taxes.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def delete_tax(self, id): """ The method to delete tax Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/taxes/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) try: from zcrmsdk.src.com.zoho.crm.api.taxes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') class DeleteTaxesParam(object): ids = Param('ids', 'com.zoho.crm.api.Taxes.DeleteTaxesParam')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/taxes/taxes_operations.py
taxes_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Tax(object): def __init__(self): """Creates an instance of Tax""" self.__display_label = None self.__name = None self.__id = None self.__value = None self.__sequence_number = None self.__key_modified = dict() def get_display_label(self): """ The method to get the display_label Returns: string: A string representing the display_label """ return self.__display_label def set_display_label(self, display_label): """ The method to set the value to display_label Parameters: display_label (string) : A string representing the display_label """ if display_label is not None and not isinstance(display_label, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: display_label EXPECTED TYPE: str', None, None) self.__display_label = display_label self.__key_modified['display_label'] = 1 def get_name(self): """ The method to get the name Returns: string: A string representing the name """ return self.__name def set_name(self, name): """ The method to set the value to name Parameters: name (string) : A string representing the name """ if name is not None and not isinstance(name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: name EXPECTED TYPE: str', None, None) self.__name = name self.__key_modified['name'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_value(self): """ The method to get the value Returns: float: A float representing the value """ return self.__value def set_value(self, value): """ The method to set the value to value Parameters: value (float) : A float representing the value """ if value is not None and not isinstance(value, float): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: value EXPECTED TYPE: float', None, None) self.__value = value self.__key_modified['value'] = 1 def get_sequence_number(self): """ The method to get the sequence_number Returns: int: An int representing the sequence_number """ return self.__sequence_number def set_sequence_number(self, sequence_number): """ The method to set the value to sequence_number Parameters: sequence_number (int) : An int representing the sequence_number """ if sequence_number is not None and not isinstance(sequence_number, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: sequence_number EXPECTED TYPE: int', None, None) self.__sequence_number = sequence_number self.__key_modified['sequence_number'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/taxes/tax.py
tax.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.taxes.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/taxes/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.inventory_templates.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__inventory_templates = None self.__info = None self.__key_modified = dict() def get_inventory_templates(self): """ The method to get the inventory_templates Returns: list: An instance of list """ return self.__inventory_templates def set_inventory_templates(self, inventory_templates): """ The method to set the value to inventory_templates Parameters: inventory_templates (list) : An instance of list """ if inventory_templates is not None and not isinstance(inventory_templates, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: inventory_templates EXPECTED TYPE: list', None, None) self.__inventory_templates = inventory_templates self.__key_modified['inventory_templates'] = 1 def get_info(self): """ The method to get the info Returns: Info: An instance of Info """ return self.__info def set_info(self, info): """ The method to set the value to info Parameters: info (Info) : An instance of Info """ try: from zcrmsdk.src.com.zoho.crm.api.record import Info except Exception: from ..record import Info if info is not None and not isinstance(info, Info): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Info', None, None) self.__info = info self.__key_modified['info'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/inventory_templates/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.send_mail import Template except Exception: from ..exception import SDKException from ..util import Constants from ..send_mail import Template class InventoryTemplate(Template): def __init__(self): """Creates an instance of InventoryTemplate""" super().__init__() self.__content = None self.__created_time = None self.__subject = None self.__module = None self.__type = None self.__created_by = None self.__modified_time = None self.__last_usage_time = None self.__associated = None self.__name = None self.__modified_by = None self.__description = None self.__id = None self.__editor_mode = None self.__favorite = None self.__folder = None self.__key_modified = dict() def get_content(self): """ The method to get the content Returns: string: A string representing the content """ return self.__content def set_content(self, content): """ The method to set the value to content Parameters: content (string) : A string representing the content """ if content is not None and not isinstance(content, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: content EXPECTED TYPE: str', None, None) self.__content = content self.__key_modified['content'] = 1 def get_created_time(self): """ The method to get the created_time Returns: datetime: An instance of datetime """ return self.__created_time def set_created_time(self, created_time): """ The method to set the value to created_time Parameters: created_time (datetime) : An instance of datetime """ from datetime import datetime if created_time is not None and not isinstance(created_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_time EXPECTED TYPE: datetime', None, None) self.__created_time = created_time self.__key_modified['created_time'] = 1 def get_subject(self): """ The method to get the subject Returns: string: A string representing the subject """ return self.__subject def set_subject(self, subject): """ The method to set the value to subject Parameters: subject (string) : A string representing the subject """ if subject is not None and not isinstance(subject, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: subject EXPECTED TYPE: str', None, None) self.__subject = subject self.__key_modified['subject'] = 1 def get_module(self): """ The method to get the module Returns: Module: An instance of Module """ return self.__module def set_module(self, module): """ The method to set the value to module Parameters: module (Module) : An instance of Module """ try: from zcrmsdk.src.com.zoho.crm.api.modules import Module except Exception: from ..modules import Module if module is not None and not isinstance(module, Module): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module EXPECTED TYPE: Module', None, None) self.__module = module self.__key_modified['module'] = 1 def get_type(self): """ The method to get the type Returns: string: A string representing the type """ return self.__type def set_type(self, type): """ The method to set the value to type Parameters: type (string) : A string representing the type """ if type is not None and not isinstance(type, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: type EXPECTED TYPE: str', None, None) self.__type = type self.__key_modified['type'] = 1 def get_created_by(self): """ The method to get the created_by Returns: User: An instance of User """ return self.__created_by def set_created_by(self, created_by): """ The method to set the value to created_by Parameters: created_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_by is not None and not isinstance(created_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_by EXPECTED TYPE: User', None, None) self.__created_by = created_by self.__key_modified['created_by'] = 1 def get_modified_time(self): """ The method to get the modified_time Returns: datetime: An instance of datetime """ return self.__modified_time def set_modified_time(self, modified_time): """ The method to set the value to modified_time Parameters: modified_time (datetime) : An instance of datetime """ from datetime import datetime if modified_time is not None and not isinstance(modified_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_time EXPECTED TYPE: datetime', None, None) self.__modified_time = modified_time self.__key_modified['modified_time'] = 1 def get_last_usage_time(self): """ The method to get the last_usage_time Returns: datetime: An instance of datetime """ return self.__last_usage_time def set_last_usage_time(self, last_usage_time): """ The method to set the value to last_usage_time Parameters: last_usage_time (datetime) : An instance of datetime """ from datetime import datetime if last_usage_time is not None and not isinstance(last_usage_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: last_usage_time EXPECTED TYPE: datetime', None, None) self.__last_usage_time = last_usage_time self.__key_modified['last_usage_time'] = 1 def get_associated(self): """ The method to get the associated Returns: bool: A bool representing the associated """ return self.__associated def set_associated(self, associated): """ The method to set the value to associated Parameters: associated (bool) : A bool representing the associated """ if associated is not None and not isinstance(associated, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: associated EXPECTED TYPE: bool', None, None) self.__associated = associated self.__key_modified['associated'] = 1 def get_name(self): """ The method to get the name Returns: string: A string representing the name """ return self.__name def set_name(self, name): """ The method to set the value to name Parameters: name (string) : A string representing the name """ if name is not None and not isinstance(name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: name EXPECTED TYPE: str', None, None) self.__name = name self.__key_modified['name'] = 1 def get_modified_by(self): """ The method to get the modified_by Returns: User: An instance of User """ return self.__modified_by def set_modified_by(self, modified_by): """ The method to set the value to modified_by Parameters: modified_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if modified_by is not None and not isinstance(modified_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_by EXPECTED TYPE: User', None, None) self.__modified_by = modified_by self.__key_modified['modified_by'] = 1 def get_description(self): """ The method to get the description Returns: string: A string representing the description """ return self.__description def set_description(self, description): """ The method to set the value to description Parameters: description (string) : A string representing the description """ if description is not None and not isinstance(description, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: description EXPECTED TYPE: str', None, None) self.__description = description self.__key_modified['description'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_editor_mode(self): """ The method to get the editor_mode Returns: string: A string representing the editor_mode """ return self.__editor_mode def set_editor_mode(self, editor_mode): """ The method to set the value to editor_mode Parameters: editor_mode (string) : A string representing the editor_mode """ if editor_mode is not None and not isinstance(editor_mode, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: editor_mode EXPECTED TYPE: str', None, None) self.__editor_mode = editor_mode self.__key_modified['editor_mode'] = 1 def get_favorite(self): """ The method to get the favorite Returns: bool: A bool representing the favorite """ return self.__favorite def set_favorite(self, favorite): """ The method to set the value to favorite Parameters: favorite (bool) : A bool representing the favorite """ if favorite is not None and not isinstance(favorite, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: favorite EXPECTED TYPE: bool', None, None) self.__favorite = favorite self.__key_modified['favorite'] = 1 def get_folder(self): """ The method to get the folder Returns: InventoryTemplate: An instance of InventoryTemplate """ return self.__folder def set_folder(self, folder): """ The method to set the value to folder Parameters: folder (InventoryTemplate) : An instance of InventoryTemplate """ try: from zcrmsdk.src.com.zoho.crm.api.inventory_templates.inventory_template import InventoryTemplate except Exception: from .inventory_template import InventoryTemplate if folder is not None and not isinstance(folder, InventoryTemplate): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: folder EXPECTED TYPE: InventoryTemplate', None, None) self.__folder = folder self.__key_modified['folder'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/inventory_templates/inventory_template.py
inventory_template.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.inventory_templates.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .response_handler import ResponseHandler class APIException(ResponseHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__code = None self.__status = None self.__message = None self.__details = None self.__key_modified = dict() def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/inventory_templates/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class InventoryTemplatesOperations(object): def __init__(self, sort_by=None, sort_order=None, category=None): """ Creates an instance of InventoryTemplatesOperations with the given parameters Parameters: sort_by (string) : A string representing the sort_by sort_order (string) : A string representing the sort_order category (string) : A string representing the category """ if sort_by is not None and not isinstance(sort_by, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: sort_by EXPECTED TYPE: str', None, None) if sort_order is not None and not isinstance(sort_order, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: sort_order EXPECTED TYPE: str', None, None) if category is not None and not isinstance(category, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: category EXPECTED TYPE: str', None, None) self.__sort_by = sort_by self.__sort_order = sort_order self.__category = category def get_inventory_templates(self, param_instance=None): """ The method to get inventory templates Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/inventory_templates' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_param(Param('sort_by', 'com.zoho.crm.api.InventoryTemplates.GetInventoryTemplatesParam'), self.__sort_by) handler_instance.add_param(Param('sort_order', 'com.zoho.crm.api.InventoryTemplates.GetInventoryTemplatesParam'), self.__sort_order) handler_instance.add_param(Param('category', 'com.zoho.crm.api.InventoryTemplates.GetInventoryTemplatesParam'), self.__category) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.inventory_templates.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def get_inventory_template_by_id(self, id): """ The method to get inventory template by id Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/inventory_templates/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_param(Param('sort_by', 'com.zoho.crm.api.InventoryTemplates.GetInventoryTemplatebyIDParam'), self.__sort_by) handler_instance.add_param(Param('sort_order', 'com.zoho.crm.api.InventoryTemplates.GetInventoryTemplatebyIDParam'), self.__sort_order) handler_instance.add_param(Param('category', 'com.zoho.crm.api.InventoryTemplates.GetInventoryTemplatebyIDParam'), self.__category) try: from zcrmsdk.src.com.zoho.crm.api.inventory_templates.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') class GetInventoryTemplatesParam(object): module = Param('module', 'com.zoho.crm.api.InventoryTemplates.GetInventoryTemplatesParam') class GetInventoryTemplatebyIDParam(object): pass
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/inventory_templates/inventory_templates_operations.py
inventory_templates_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants except Exception: from ..exception import SDKException from ..util import Choice, Constants class Resource(object): def __init__(self): """Creates an instance of Resource""" self.__status = None self.__type = None self.__module = None self.__code = None self.__file_id = None self.__ignore_empty = None self.__find_by = None self.__field_mappings = None self.__file = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_type(self): """ The method to get the type Returns: Choice: An instance of Choice """ return self.__type def set_type(self, type): """ The method to set the value to type Parameters: type (Choice) : An instance of Choice """ if type is not None and not isinstance(type, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: type EXPECTED TYPE: Choice', None, None) self.__type = type self.__key_modified['type'] = 1 def get_module(self): """ The method to get the module Returns: Module: An instance of Module """ return self.__module def set_module(self, module): """ The method to set the value to module Parameters: module (Module) : An instance of Module """ try: from zcrmsdk.src.com.zoho.crm.api.modules import Module except Exception: from ..modules import Module if module is not None and not isinstance(module, Module): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module EXPECTED TYPE: Module', None, None) self.__module = module self.__key_modified['module'] = 1 def get_code(self): """ The method to get the code Returns: string: A string representing the code """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (string) : A string representing the code """ if code is not None and not isinstance(code, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: str', None, None) self.__code = code self.__key_modified['code'] = 1 def get_file_id(self): """ The method to get the file_id Returns: string: A string representing the file_id """ return self.__file_id def set_file_id(self, file_id): """ The method to set the value to file_id Parameters: file_id (string) : A string representing the file_id """ if file_id is not None and not isinstance(file_id, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file_id EXPECTED TYPE: str', None, None) self.__file_id = file_id self.__key_modified['file_id'] = 1 def get_ignore_empty(self): """ The method to get the ignore_empty Returns: bool: A bool representing the ignore_empty """ return self.__ignore_empty def set_ignore_empty(self, ignore_empty): """ The method to set the value to ignore_empty Parameters: ignore_empty (bool) : A bool representing the ignore_empty """ if ignore_empty is not None and not isinstance(ignore_empty, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: ignore_empty EXPECTED TYPE: bool', None, None) self.__ignore_empty = ignore_empty self.__key_modified['ignore_empty'] = 1 def get_find_by(self): """ The method to get the find_by Returns: string: A string representing the find_by """ return self.__find_by def set_find_by(self, find_by): """ The method to set the value to find_by Parameters: find_by (string) : A string representing the find_by """ if find_by is not None and not isinstance(find_by, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: find_by EXPECTED TYPE: str', None, None) self.__find_by = find_by self.__key_modified['find_by'] = 1 def get_field_mappings(self): """ The method to get the field_mappings Returns: list: An instance of list """ return self.__field_mappings def set_field_mappings(self, field_mappings): """ The method to set the value to field_mappings Parameters: field_mappings (list) : An instance of list """ if field_mappings is not None and not isinstance(field_mappings, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: field_mappings EXPECTED TYPE: list', None, None) self.__field_mappings = field_mappings self.__key_modified['field_mappings'] = 1 def get_file(self): """ The method to get the file Returns: File: An instance of File """ return self.__file def set_file(self, file): """ The method to set the value to file Parameters: file (File) : An instance of File """ try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.file import File except Exception: from .file import File if file is not None and not isinstance(file, File): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file EXPECTED TYPE: File', None, None) self.__file = file self.__key_modified['file'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/resource.py
resource.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.bulk_write.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.bulk_write.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.bulk_write.response_wrapper import ResponseWrapper except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .response_wrapper import ResponseWrapper class APIException(ActionResponse, ResponseWrapper, ResponseHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__code = None self.__message = None self.__status = None self.__details = None self.__error_message = None self.__error_code = None self.__x_error = None self.__info = None self.__x_info = None self.__http_status = None self.__key_modified = dict() def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def get_error_message(self): """ The method to get the error_message Returns: Choice: An instance of Choice """ return self.__error_message def set_error_message(self, error_message): """ The method to set the value to error_message Parameters: error_message (Choice) : An instance of Choice """ if error_message is not None and not isinstance(error_message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: error_message EXPECTED TYPE: Choice', None, None) self.__error_message = error_message self.__key_modified['ERROR_MESSAGE'] = 1 def get_error_code(self): """ The method to get the error_code Returns: int: An int representing the error_code """ return self.__error_code def set_error_code(self, error_code): """ The method to set the value to error_code Parameters: error_code (int) : An int representing the error_code """ if error_code is not None and not isinstance(error_code, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: error_code EXPECTED TYPE: int', None, None) self.__error_code = error_code self.__key_modified['ERROR_CODE'] = 1 def get_x_error(self): """ The method to get the x_error Returns: Choice: An instance of Choice """ return self.__x_error def set_x_error(self, x_error): """ The method to set the value to x_error Parameters: x_error (Choice) : An instance of Choice """ if x_error is not None and not isinstance(x_error, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: x_error EXPECTED TYPE: Choice', None, None) self.__x_error = x_error self.__key_modified['x-error'] = 1 def get_info(self): """ The method to get the info Returns: Choice: An instance of Choice """ return self.__info def set_info(self, info): """ The method to set the value to info Parameters: info (Choice) : An instance of Choice """ if info is not None and not isinstance(info, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Choice', None, None) self.__info = info self.__key_modified['info'] = 1 def get_x_info(self): """ The method to get the x_info Returns: Choice: An instance of Choice """ return self.__x_info def set_x_info(self, x_info): """ The method to set the value to x_info Parameters: x_info (Choice) : An instance of Choice """ if x_info is not None and not isinstance(x_info, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: x_info EXPECTED TYPE: Choice', None, None) self.__x_info = x_info self.__key_modified['x-info'] = 1 def get_http_status(self): """ The method to get the http_status Returns: string: A string representing the http_status """ return self.__http_status def set_http_status(self, http_status): """ The method to set the value to http_status Parameters: http_status (string) : A string representing the http_status """ if http_status is not None and not isinstance(http_status, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: http_status EXPECTED TYPE: str', None, None) self.__http_status = http_status self.__key_modified['http_status'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.bulk_write.response_wrapper import ResponseWrapper except Exception: from ..exception import SDKException from ..util import Constants from .response_wrapper import ResponseWrapper class BulkWriteResponse(ResponseWrapper): def __init__(self): """Creates an instance of BulkWriteResponse""" super().__init__() self.__status = None self.__character_encoding = None self.__resource = None self.__id = None self.__callback = None self.__result = None self.__created_by = None self.__operation = None self.__created_time = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: string: A string representing the status """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (string) : A string representing the status """ if status is not None and not isinstance(status, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: str', None, None) self.__status = status self.__key_modified['status'] = 1 def get_character_encoding(self): """ The method to get the character_encoding Returns: string: A string representing the character_encoding """ return self.__character_encoding def set_character_encoding(self, character_encoding): """ The method to set the value to character_encoding Parameters: character_encoding (string) : A string representing the character_encoding """ if character_encoding is not None and not isinstance(character_encoding, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: character_encoding EXPECTED TYPE: str', None, None) self.__character_encoding = character_encoding self.__key_modified['character_encoding'] = 1 def get_resource(self): """ The method to get the resource Returns: list: An instance of list """ return self.__resource def set_resource(self, resource): """ The method to set the value to resource Parameters: resource (list) : An instance of list """ if resource is not None and not isinstance(resource, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: resource EXPECTED TYPE: list', None, None) self.__resource = resource self.__key_modified['resource'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_callback(self): """ The method to get the callback Returns: CallBack: An instance of CallBack """ return self.__callback def set_callback(self, callback): """ The method to set the value to callback Parameters: callback (CallBack) : An instance of CallBack """ try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.call_back import CallBack except Exception: from .call_back import CallBack if callback is not None and not isinstance(callback, CallBack): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: callback EXPECTED TYPE: CallBack', None, None) self.__callback = callback self.__key_modified['callback'] = 1 def get_result(self): """ The method to get the result Returns: Result: An instance of Result """ return self.__result def set_result(self, result): """ The method to set the value to result Parameters: result (Result) : An instance of Result """ try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.result import Result except Exception: from .result import Result if result is not None and not isinstance(result, Result): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: result EXPECTED TYPE: Result', None, None) self.__result = result self.__key_modified['result'] = 1 def get_created_by(self): """ The method to get the created_by Returns: User: An instance of User """ return self.__created_by def set_created_by(self, created_by): """ The method to set the value to created_by Parameters: created_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_by is not None and not isinstance(created_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_by EXPECTED TYPE: User', None, None) self.__created_by = created_by self.__key_modified['created_by'] = 1 def get_operation(self): """ The method to get the operation Returns: string: A string representing the operation """ return self.__operation def set_operation(self, operation): """ The method to set the value to operation Parameters: operation (string) : A string representing the operation """ if operation is not None and not isinstance(operation, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: operation EXPECTED TYPE: str', None, None) self.__operation = operation self.__key_modified['operation'] = 1 def get_created_time(self): """ The method to get the created_time Returns: datetime: An instance of datetime """ return self.__created_time def set_created_time(self, created_time): """ The method to set the value to created_time Parameters: created_time (datetime) : An instance of datetime """ from datetime import datetime if created_time is not None and not isinstance(created_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_time EXPECTED TYPE: datetime', None, None) self.__created_time = created_time self.__key_modified['created_time'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/bulk_write_response.py
bulk_write_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants except Exception: from ..exception import SDKException from ..util import Choice, Constants class File(object): def __init__(self): """Creates an instance of File""" self.__status = None self.__name = None self.__added_count = None self.__skipped_count = None self.__updated_count = None self.__total_count = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_name(self): """ The method to get the name Returns: string: A string representing the name """ return self.__name def set_name(self, name): """ The method to set the value to name Parameters: name (string) : A string representing the name """ if name is not None and not isinstance(name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: name EXPECTED TYPE: str', None, None) self.__name = name self.__key_modified['name'] = 1 def get_added_count(self): """ The method to get the added_count Returns: int: An int representing the added_count """ return self.__added_count def set_added_count(self, added_count): """ The method to set the value to added_count Parameters: added_count (int) : An int representing the added_count """ if added_count is not None and not isinstance(added_count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: added_count EXPECTED TYPE: int', None, None) self.__added_count = added_count self.__key_modified['added_count'] = 1 def get_skipped_count(self): """ The method to get the skipped_count Returns: int: An int representing the skipped_count """ return self.__skipped_count def set_skipped_count(self, skipped_count): """ The method to set the value to skipped_count Parameters: skipped_count (int) : An int representing the skipped_count """ if skipped_count is not None and not isinstance(skipped_count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: skipped_count EXPECTED TYPE: int', None, None) self.__skipped_count = skipped_count self.__key_modified['skipped_count'] = 1 def get_updated_count(self): """ The method to get the updated_count Returns: int: An int representing the updated_count """ return self.__updated_count def set_updated_count(self, updated_count): """ The method to set the value to updated_count Parameters: updated_count (int) : An int representing the updated_count """ if updated_count is not None and not isinstance(updated_count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: updated_count EXPECTED TYPE: int', None, None) self.__updated_count = updated_count self.__key_modified['updated_count'] = 1 def get_total_count(self): """ The method to get the total_count Returns: int: An int representing the total_count """ return self.__total_count def set_total_count(self, total_count): """ The method to set the value to total_count Parameters: total_count (int) : An int representing the total_count """ if total_count is not None and not isinstance(total_count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: total_count EXPECTED TYPE: int', None, None) self.__total_count = total_count self.__key_modified['total_count'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/file.py
file.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants except Exception: from ..exception import SDKException from ..util import Choice, Constants class CallBack(object): def __init__(self): """Creates an instance of CallBack""" self.__url = None self.__method = None self.__key_modified = dict() def get_url(self): """ The method to get the url Returns: string: A string representing the url """ return self.__url def set_url(self, url): """ The method to set the value to url Parameters: url (string) : A string representing the url """ if url is not None and not isinstance(url, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: url EXPECTED TYPE: str', None, None) self.__url = url self.__key_modified['url'] = 1 def get_method(self): """ The method to get the method Returns: Choice: An instance of Choice """ return self.__method def set_method(self, method): """ The method to set the value to method Parameters: method (Choice) : An instance of Choice """ if method is not None and not isinstance(method, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: method EXPECTED TYPE: Choice', None, None) self.__method = method self.__key_modified['method'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/call_back.py
call_back.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.header import Header from zcrmsdk.src.com.zoho.crm.api.header_map import HeaderMap except Exception: from ..exception import SDKException from ..util import APIResponse, CommonAPIHandler, Constants from ..header import Header from ..header_map import HeaderMap class BulkWriteOperations(object): def __init__(self): """Creates an instance of BulkWriteOperations""" pass def upload_file(self, request, header_instance=None): """ The method to upload file Parameters: request (FileBodyWrapper) : An instance of FileBodyWrapper header_instance (HeaderMap) : An instance of HeaderMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.file_body_wrapper import FileBodyWrapper except Exception: from .file_body_wrapper import FileBodyWrapper if request is not None and not isinstance(request, FileBodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: FileBodyWrapper', None, None) if header_instance is not None and not isinstance(header_instance, HeaderMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: header_instance EXPECTED TYPE: HeaderMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + 'https://content.zohoapis.com/crm/v2.1/upload' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('multipart/form-data') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) handler_instance.set_header(header_instance) try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.action_response import ActionResponse except Exception: from .action_response import ActionResponse return handler_instance.api_call(ActionResponse.__module__, 'application/json') def create_bulk_write_job(self, request): """ The method to create bulk write job Parameters: request (RequestWrapper) : An instance of RequestWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.request_wrapper import RequestWrapper except Exception: from .request_wrapper import RequestWrapper if request is not None and not isinstance(request, RequestWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: RequestWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/bulk/v2.1/write' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.action_response import ActionResponse except Exception: from .action_response import ActionResponse return handler_instance.api_call(ActionResponse.__module__, 'application/json') def get_bulk_write_job_details(self, job_id): """ The method to get bulk write job details Parameters: job_id (int) : An int representing the job_id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(job_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: job_id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/bulk/v2.1/write/' api_path = api_path + str(job_id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.response_wrapper import ResponseWrapper except Exception: from .response_wrapper import ResponseWrapper return handler_instance.api_call(ResponseWrapper.__module__, 'application/json') def download_bulk_write_result(self, download_url): """ The method to download bulk write result Parameters: download_url (string) : A string representing the download_url Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(download_url, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: download_url EXPECTED TYPE: str', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/' api_path = api_path + str(download_url) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/octet-stream') class UploadFileHeader(object): feature = Header('feature', 'com.zoho.crm.api.BulkWrite.UploadFileHeader') x_crm_org = Header('X-CRM-ORG', 'com.zoho.crm.api.BulkWrite.UploadFileHeader')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/bulk_write_operations.py
bulk_write_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import StreamWrapper, Constants from zcrmsdk.src.com.zoho.crm.api.bulk_write.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import StreamWrapper, Constants from .response_handler import ResponseHandler class FileBodyWrapper(ResponseHandler): def __init__(self): """Creates an instance of FileBodyWrapper""" super().__init__() self.__file = None self.__key_modified = dict() def get_file(self): """ The method to get the file Returns: StreamWrapper: An instance of StreamWrapper """ return self.__file def set_file(self, file): """ The method to set the value to file Parameters: file (StreamWrapper) : An instance of StreamWrapper """ if file is not None and not isinstance(file, StreamWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file EXPECTED TYPE: StreamWrapper', None, None) self.__file = file self.__key_modified['file'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/file_body_wrapper.py
file_body_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class FieldMapping(object): def __init__(self): """Creates an instance of FieldMapping""" self.__api_name = None self.__index = None self.__format = None self.__find_by = None self.__default_value = None self.__module = None self.__key_modified = dict() def get_api_name(self): """ The method to get the api_name Returns: string: A string representing the api_name """ return self.__api_name def set_api_name(self, api_name): """ The method to set the value to api_name Parameters: api_name (string) : A string representing the api_name """ if api_name is not None and not isinstance(api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: api_name EXPECTED TYPE: str', None, None) self.__api_name = api_name self.__key_modified['api_name'] = 1 def get_index(self): """ The method to get the index Returns: int: An int representing the index """ return self.__index def set_index(self, index): """ The method to set the value to index Parameters: index (int) : An int representing the index """ if index is not None and not isinstance(index, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: index EXPECTED TYPE: int', None, None) self.__index = index self.__key_modified['index'] = 1 def get_format(self): """ The method to get the format Returns: string: A string representing the format """ return self.__format def set_format(self, format): """ The method to set the value to format Parameters: format (string) : A string representing the format """ if format is not None and not isinstance(format, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: format EXPECTED TYPE: str', None, None) self.__format = format self.__key_modified['format'] = 1 def get_find_by(self): """ The method to get the find_by Returns: string: A string representing the find_by """ return self.__find_by def set_find_by(self, find_by): """ The method to set the value to find_by Parameters: find_by (string) : A string representing the find_by """ if find_by is not None and not isinstance(find_by, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: find_by EXPECTED TYPE: str', None, None) self.__find_by = find_by self.__key_modified['find_by'] = 1 def get_default_value(self): """ The method to get the default_value Returns: dict: An instance of dict """ return self.__default_value def set_default_value(self, default_value): """ The method to set the value to default_value Parameters: default_value (dict) : An instance of dict """ if default_value is not None and not isinstance(default_value, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: default_value EXPECTED TYPE: dict', None, None) self.__default_value = default_value self.__key_modified['default_value'] = 1 def get_module(self): """ The method to get the module Returns: string: A string representing the module """ return self.__module def set_module(self, module): """ The method to set the value to module Parameters: module (string) : A string representing the module """ if module is not None and not isinstance(module, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module EXPECTED TYPE: str', None, None) self.__module = module self.__key_modified['module'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/field_mapping.py
field_mapping.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants except Exception: from ..exception import SDKException from ..util import Choice, Constants class RequestWrapper(object): def __init__(self): """Creates an instance of RequestWrapper""" self.__character_encoding = None self.__operation = None self.__callback = None self.__resource = None self.__key_modified = dict() def get_character_encoding(self): """ The method to get the character_encoding Returns: string: A string representing the character_encoding """ return self.__character_encoding def set_character_encoding(self, character_encoding): """ The method to set the value to character_encoding Parameters: character_encoding (string) : A string representing the character_encoding """ if character_encoding is not None and not isinstance(character_encoding, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: character_encoding EXPECTED TYPE: str', None, None) self.__character_encoding = character_encoding self.__key_modified['character_encoding'] = 1 def get_operation(self): """ The method to get the operation Returns: Choice: An instance of Choice """ return self.__operation def set_operation(self, operation): """ The method to set the value to operation Parameters: operation (Choice) : An instance of Choice """ if operation is not None and not isinstance(operation, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: operation EXPECTED TYPE: Choice', None, None) self.__operation = operation self.__key_modified['operation'] = 1 def get_callback(self): """ The method to get the callback Returns: CallBack: An instance of CallBack """ return self.__callback def set_callback(self, callback): """ The method to set the value to callback Parameters: callback (CallBack) : An instance of CallBack """ try: from zcrmsdk.src.com.zoho.crm.api.bulk_write.call_back import CallBack except Exception: from .call_back import CallBack if callback is not None and not isinstance(callback, CallBack): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: callback EXPECTED TYPE: CallBack', None, None) self.__callback = callback self.__key_modified['callback'] = 1 def get_resource(self): """ The method to get the resource Returns: list: An instance of list """ return self.__resource def set_resource(self, resource): """ The method to set the value to resource Parameters: resource (list) : An instance of list """ if resource is not None and not isinstance(resource, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: resource EXPECTED TYPE: list', None, None) self.__resource = resource self.__key_modified['resource'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/request_wrapper.py
request_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.bulk_write.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Result(object): def __init__(self): """Creates an instance of Result""" self.__download_url = None self.__key_modified = dict() def get_download_url(self): """ The method to get the download_url Returns: string: A string representing the download_url """ return self.__download_url def set_download_url(self, download_url): """ The method to set the value to download_url Parameters: download_url (string) : A string representing the download_url """ if download_url is not None and not isinstance(download_url, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: download_url EXPECTED TYPE: str', None, None) self.__download_url = download_url self.__key_modified['download_url'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/bulk_write/result.py
result.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.file.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__data = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/file/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.file.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.file.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.file.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .action_handler import ActionHandler class APIException(ActionResponse, ActionHandler, ResponseHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/file/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class FileOperations(object): def __init__(self): """Creates an instance of FileOperations""" pass def upload_files(self, request, param_instance=None): """ The method to upload files Parameters: request (BodyWrapper) : An instance of BodyWrapper param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.file.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/files' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('multipart/form-data') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.file.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_file(self, param_instance=None): """ The method to get file Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/files' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.file.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/x-download') class UploadFilesParam(object): type = Param('type', 'com.zoho.crm.api.File.UploadFilesParam') class GetFileParam(object): id = Param('id', 'com.zoho.crm.api.File.GetFileParam')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/file/file_operations.py
file_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import StreamWrapper, Constants from zcrmsdk.src.com.zoho.crm.api.file.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import StreamWrapper, Constants from .response_handler import ResponseHandler class FileBodyWrapper(ResponseHandler): def __init__(self): """Creates an instance of FileBodyWrapper""" super().__init__() self.__file = None self.__key_modified = dict() def get_file(self): """ The method to get the file Returns: StreamWrapper: An instance of StreamWrapper """ return self.__file def set_file(self, file): """ The method to set the value to file Parameters: file (StreamWrapper) : An instance of StreamWrapper """ if file is not None and not isinstance(file, StreamWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file EXPECTED TYPE: StreamWrapper', None, None) self.__file = file self.__key_modified['file'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/file/file_body_wrapper.py
file_body_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.file.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/file/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.share_records.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__share = None self.__key_modified = dict() def get_share(self): """ The method to get the share Returns: list: An instance of list """ return self.__share def set_share(self, share): """ The method to set the value to share Parameters: share (list) : An instance of list """ if share is not None and not isinstance(share, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: share EXPECTED TYPE: list', None, None) self.__share = share self.__key_modified['share'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.share_records.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__share = None self.__shareable_user = None self.__key_modified = dict() def get_share(self): """ The method to get the share Returns: list: An instance of list """ return self.__share def set_share(self, share): """ The method to set the value to share Parameters: share (list) : An instance of list """ if share is not None and not isinstance(share, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: share EXPECTED TYPE: list', None, None) self.__share = share self.__key_modified['share'] = 1 def get_shareable_user(self): """ The method to get the shareable_user Returns: list: An instance of list """ return self.__shareable_user def set_shareable_user(self, shareable_user): """ The method to set the value to shareable_user Parameters: shareable_user (list) : An instance of list """ if shareable_user is not None and not isinstance(shareable_user, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: shareable_user EXPECTED TYPE: list', None, None) self.__shareable_user = shareable_user self.__key_modified['shareable_user'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class SharedThrough(object): def __init__(self): """Creates an instance of SharedThrough""" self.__module = None self.__id = None self.__entity_name = None self.__key_modified = dict() def get_module(self): """ The method to get the module Returns: Module: An instance of Module """ return self.__module def set_module(self, module): """ The method to set the value to module Parameters: module (Module) : An instance of Module """ try: from zcrmsdk.src.com.zoho.crm.api.modules import Module except Exception: from ..modules import Module if module is not None and not isinstance(module, Module): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module EXPECTED TYPE: Module', None, None) self.__module = module self.__key_modified['module'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_entity_name(self): """ The method to get the entity_name Returns: string: A string representing the entity_name """ return self.__entity_name def set_entity_name(self, entity_name): """ The method to set the value to entity_name Parameters: entity_name (string) : A string representing the entity_name """ if entity_name is not None and not isinstance(entity_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: entity_name EXPECTED TYPE: str', None, None) self.__entity_name = entity_name self.__key_modified['entity_name'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/shared_through.py
shared_through.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.share_records.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.share_records.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.share_records.delete_action_handler import DeleteActionHandler from zcrmsdk.src.com.zoho.crm.api.share_records.action_handler import ActionHandler from zcrmsdk.src.com.zoho.crm.api.share_records.delete_action_response import DeleteActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .delete_action_handler import DeleteActionHandler from .action_handler import ActionHandler from .delete_action_response import DeleteActionResponse class APIException(ResponseHandler, ActionResponse, ActionHandler, DeleteActionResponse, DeleteActionHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class ShareRecord(object): def __init__(self): """Creates an instance of ShareRecord""" self.__share_related_records = None self.__shared_through = None self.__shared_time = None self.__permission = None self.__shared_by = None self.__user = None self.__key_modified = dict() def get_share_related_records(self): """ The method to get the share_related_records Returns: bool: A bool representing the share_related_records """ return self.__share_related_records def set_share_related_records(self, share_related_records): """ The method to set the value to share_related_records Parameters: share_related_records (bool) : A bool representing the share_related_records """ if share_related_records is not None and not isinstance(share_related_records, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: share_related_records EXPECTED TYPE: bool', None, None) self.__share_related_records = share_related_records self.__key_modified['share_related_records'] = 1 def get_shared_through(self): """ The method to get the shared_through Returns: SharedThrough: An instance of SharedThrough """ return self.__shared_through def set_shared_through(self, shared_through): """ The method to set the value to shared_through Parameters: shared_through (SharedThrough) : An instance of SharedThrough """ try: from zcrmsdk.src.com.zoho.crm.api.share_records.shared_through import SharedThrough except Exception: from .shared_through import SharedThrough if shared_through is not None and not isinstance(shared_through, SharedThrough): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: shared_through EXPECTED TYPE: SharedThrough', None, None) self.__shared_through = shared_through self.__key_modified['shared_through'] = 1 def get_shared_time(self): """ The method to get the shared_time Returns: datetime: An instance of datetime """ return self.__shared_time def set_shared_time(self, shared_time): """ The method to set the value to shared_time Parameters: shared_time (datetime) : An instance of datetime """ from datetime import datetime if shared_time is not None and not isinstance(shared_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: shared_time EXPECTED TYPE: datetime', None, None) self.__shared_time = shared_time self.__key_modified['shared_time'] = 1 def get_permission(self): """ The method to get the permission Returns: string: A string representing the permission """ return self.__permission def set_permission(self, permission): """ The method to set the value to permission Parameters: permission (string) : A string representing the permission """ if permission is not None and not isinstance(permission, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: permission EXPECTED TYPE: str', None, None) self.__permission = permission self.__key_modified['permission'] = 1 def get_shared_by(self): """ The method to get the shared_by Returns: User: An instance of User """ return self.__shared_by def set_shared_by(self, shared_by): """ The method to set the value to shared_by Parameters: shared_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if shared_by is not None and not isinstance(shared_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: shared_by EXPECTED TYPE: User', None, None) self.__shared_by = shared_by self.__key_modified['shared_by'] = 1 def get_user(self): """ The method to get the user Returns: User: An instance of User """ return self.__user def set_user(self, user): """ The method to set the value to user Parameters: user (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if user is not None and not isinstance(user, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: user EXPECTED TYPE: User', None, None) self.__user = user self.__key_modified['user'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/share_record.py
share_record.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class ShareRecordsOperations(object): def __init__(self, record_id, module_api_name): """ Creates an instance of ShareRecordsOperations with the given parameters Parameters: record_id (int) : An int representing the record_id module_api_name (string) : A string representing the module_api_name """ if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if not isinstance(module_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module_api_name EXPECTED TYPE: str', None, None) self.__record_id = record_id self.__module_api_name = module_api_name def get_shared_record_details(self, param_instance=None): """ The method to get shared record details Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/actions/share' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.share_records.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def share_record(self, request): """ The method to share record Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.share_records.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/actions/share' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.share_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def update_share_permissions(self, request): """ The method to update share permissions Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.share_records.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/actions/share' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.share_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def revoke_shared_record(self): """ The method to revoke shared record Returns: APIResponse: An instance of APIResponse Raises: SDKException """ handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(self.__record_id) api_path = api_path + '/actions/share' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) try: from zcrmsdk.src.com.zoho.crm.api.share_records.delete_action_handler import DeleteActionHandler except Exception: from .delete_action_handler import DeleteActionHandler return handler_instance.api_call(DeleteActionHandler.__module__, 'application/json') class GetSharedRecordDetailsParam(object): sharedto = Param('sharedTo', 'com.zoho.crm.api.ShareRecords.GetSharedRecordDetailsParam') view = Param('view', 'com.zoho.crm.api.ShareRecords.GetSharedRecordDetailsParam')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/share_records_operations.py
share_records_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.share_records.delete_action_handler import DeleteActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .delete_action_handler import DeleteActionHandler class DeleteActionWrapper(DeleteActionHandler): def __init__(self): """Creates an instance of DeleteActionWrapper""" super().__init__() self.__share = None self.__key_modified = dict() def get_share(self): """ The method to get the share Returns: DeleteActionResponse: An instance of DeleteActionResponse """ return self.__share def set_share(self, share): """ The method to set the value to share Parameters: share (DeleteActionResponse) : An instance of DeleteActionResponse """ try: from zcrmsdk.src.com.zoho.crm.api.share_records.delete_action_response import DeleteActionResponse except Exception: from .delete_action_response import DeleteActionResponse if share is not None and not isinstance(share, DeleteActionResponse): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: share EXPECTED TYPE: DeleteActionResponse', None, None) self.__share = share self.__key_modified['share'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/delete_action_wrapper.py
delete_action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.share_records.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.share_records.delete_action_response import DeleteActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .delete_action_response import DeleteActionResponse class SuccessResponse(ActionResponse, DeleteActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/share_records/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__data = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/related_records/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.related_records.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__data = None self.__info = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def get_info(self): """ The method to get the info Returns: Info: An instance of Info """ return self.__info def set_info(self, info): """ The method to set the value to info Parameters: info (Info) : An instance of Info """ try: from zcrmsdk.src.com.zoho.crm.api.record import Info except Exception: from ..record import Info if info is not None and not isinstance(info, Info): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Info', None, None) self.__info = info self.__key_modified['info'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/related_records/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.related_records.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.related_records.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .action_handler import ActionHandler class APIException(ResponseHandler, ActionResponse, ActionHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/related_records/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import StreamWrapper, Constants from zcrmsdk.src.com.zoho.crm.api.related_records.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import StreamWrapper, Constants from .response_handler import ResponseHandler class FileBodyWrapper(ResponseHandler): def __init__(self): """Creates an instance of FileBodyWrapper""" super().__init__() self.__file = None self.__key_modified = dict() def get_file(self): """ The method to get the file Returns: StreamWrapper: An instance of StreamWrapper """ return self.__file def set_file(self, file): """ The method to set the value to file Parameters: file (StreamWrapper) : An instance of StreamWrapper """ if file is not None and not isinstance(file, StreamWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: file EXPECTED TYPE: StreamWrapper', None, None) self.__file = file self.__key_modified['file'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/related_records/file_body_wrapper.py
file_body_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.related_records.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__code = None self.__details = None self.__message = None self.__status = None self.__key_modified = dict() def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/related_records/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Utility, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param from zcrmsdk.src.com.zoho.crm.api.header import Header from zcrmsdk.src.com.zoho.crm.api.header_map import HeaderMap except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Utility, Constants from ..param import Param from ..header import Header from ..header_map import HeaderMap class RelatedRecordsOperations(object): def __init__(self, related_list_api_name, module_api_name, x_external=None): """ Creates an instance of RelatedRecordsOperations with the given parameters Parameters: related_list_api_name (string) : A string representing the related_list_api_name module_api_name (string) : A string representing the module_api_name x_external (string) : A string representing the x_external """ if not isinstance(related_list_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: related_list_api_name EXPECTED TYPE: str', None, None) if not isinstance(module_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module_api_name EXPECTED TYPE: str', None, None) if x_external is not None and not isinstance(x_external, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: x_external EXPECTED TYPE: str', None, None) self.__related_list_api_name = related_list_api_name self.__module_api_name = module_api_name self.__x_external = x_external def get_related_records(self, record_id, param_instance=None, header_instance=None): """ The method to get related records Parameters: record_id (int) : An int representing the record_id param_instance (ParameterMap) : An instance of ParameterMap header_instance (HeaderMap) : An instance of HeaderMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) if header_instance is not None and not isinstance(header_instance, HeaderMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: header_instance EXPECTED TYPE: HeaderMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsHeader'), self.__x_external) handler_instance.set_param(param_instance) handler_instance.set_header(header_instance) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def update_related_records(self, record_id, request): """ The method to update related records Parameters: record_id (int) : An int representing the record_id request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.related_records.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.UpdateRelatedRecordsHeader'), self.__x_external) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delink_records(self, record_id, param_instance=None): """ The method to delink records Parameters: record_id (int) : An int representing the record_id param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.DelinkRecordsHeader'), self.__x_external) handler_instance.set_param(param_instance) Utility.get_fields(self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_related_records_using_external_id(self, external_value, param_instance=None, header_instance=None): """ The method to get related records using external id Parameters: external_value (string) : A string representing the external_value param_instance (ParameterMap) : An instance of ParameterMap header_instance (HeaderMap) : An instance of HeaderMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(external_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_value EXPECTED TYPE: str', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) if header_instance is not None and not isinstance(header_instance, HeaderMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: header_instance EXPECTED TYPE: HeaderMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(external_value) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsUsingExternalIDHeader'), self.__x_external) handler_instance.set_param(param_instance) handler_instance.set_header(header_instance) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def update_related_records_using_external_id(self, external_value, request): """ The method to update related records using external id Parameters: external_value (string) : A string representing the external_value request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.related_records.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if not isinstance(external_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_value EXPECTED TYPE: str', None, None) if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(external_value) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.UpdateRelatedRecordsUsingExternalIDHeader'), self.__x_external) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delete_related_records_using_external_id(self, external_value, param_instance=None): """ The method to delete related records using external id Parameters: external_value (string) : A string representing the external_value param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(external_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_value EXPECTED TYPE: str', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(external_value) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.DeleteRelatedRecordsUsingExternalIDHeader'), self.__x_external) handler_instance.set_param(param_instance) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_related_record(self, related_record_id, record_id, header_instance=None): """ The method to get related record Parameters: related_record_id (int) : An int representing the related_record_id record_id (int) : An int representing the record_id header_instance (HeaderMap) : An instance of HeaderMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(related_record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: related_record_id EXPECTED TYPE: int', None, None) if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if header_instance is not None and not isinstance(header_instance, HeaderMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: header_instance EXPECTED TYPE: HeaderMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) api_path = api_path + '/' api_path = api_path + str(related_record_id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordHeader'), self.__x_external) handler_instance.set_header(header_instance) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def update_related_record(self, related_record_id, record_id, request): """ The method to update related record Parameters: related_record_id (int) : An int representing the related_record_id record_id (int) : An int representing the record_id request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.related_records.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if not isinstance(related_record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: related_record_id EXPECTED TYPE: int', None, None) if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) api_path = api_path + '/' api_path = api_path + str(related_record_id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.UpdateRelatedRecordHeader'), self.__x_external) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delink_record(self, related_record_id, record_id): """ The method to delink record Parameters: related_record_id (int) : An int representing the related_record_id record_id (int) : An int representing the record_id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(related_record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: related_record_id EXPECTED TYPE: int', None, None) if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) api_path = api_path + '/' api_path = api_path + str(related_record_id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.DelinkRecordHeader'), self.__x_external) Utility.get_fields(self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_related_record_using_external_id(self, external_field_value, external_value, header_instance=None): """ The method to get related record using external id Parameters: external_field_value (string) : A string representing the external_field_value external_value (string) : A string representing the external_value header_instance (HeaderMap) : An instance of HeaderMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(external_field_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_field_value EXPECTED TYPE: str', None, None) if not isinstance(external_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_value EXPECTED TYPE: str', None, None) if header_instance is not None and not isinstance(header_instance, HeaderMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: header_instance EXPECTED TYPE: HeaderMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(external_value) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) api_path = api_path + '/' api_path = api_path + str(external_field_value) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordUsingExternalIDHeader'), self.__x_external) handler_instance.set_header(header_instance) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def update_related_record_using_external_id(self, external_field_value, external_value, request): """ The method to update related record using external id Parameters: external_field_value (string) : A string representing the external_field_value external_value (string) : A string representing the external_value request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.related_records.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if not isinstance(external_field_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_field_value EXPECTED TYPE: str', None, None) if not isinstance(external_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_value EXPECTED TYPE: str', None, None) if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(external_value) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) api_path = api_path + '/' api_path = api_path + str(external_field_value) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.UpdateRelatedRecordUsingExternalIDHeader'), self.__x_external) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delete_related_record_using_external_id(self, external_field_value, external_value): """ The method to delete related record using external id Parameters: external_field_value (string) : A string representing the external_field_value external_value (string) : A string representing the external_value Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(external_field_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_field_value EXPECTED TYPE: str', None, None) if not isinstance(external_value, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: external_value EXPECTED TYPE: str', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(self.__module_api_name) api_path = api_path + '/' api_path = api_path + str(external_value) api_path = api_path + '/' api_path = api_path + str(self.__related_list_api_name) api_path = api_path + '/' api_path = api_path + str(external_field_value) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.add_header(Header('X-EXTERNAL', 'com.zoho.crm.api.RelatedRecords.DeleteRelatedRecordUsingExternalIDHeader'), self.__x_external) Utility.get_related_lists(self.__related_list_api_name, self.__module_api_name, handler_instance) try: from zcrmsdk.src.com.zoho.crm.api.related_records.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') class GetRelatedRecordsHeader(object): if_modified_since = Header('If-Modified-Since', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsHeader') class GetRelatedRecordsParam(object): page = Param('page', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsParam') per_page = Param('per_page', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsParam') class UpdateRelatedRecordsHeader(object): pass class DelinkRecordsHeader(object): pass class DelinkRecordsParam(object): ids = Param('ids', 'com.zoho.crm.api.RelatedRecords.DelinkRecordsParam') class GetRelatedRecordsUsingExternalIDHeader(object): if_modified_since = Header('If-Modified-Since', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsUsingExternalIDHeader') class GetRelatedRecordsUsingExternalIDParam(object): page = Param('page', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsUsingExternalIDParam') per_page = Param('per_page', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordsUsingExternalIDParam') class UpdateRelatedRecordsUsingExternalIDHeader(object): pass class DeleteRelatedRecordsUsingExternalIDHeader(object): pass class DeleteRelatedRecordsUsingExternalIDParam(object): ids = Param('ids', 'com.zoho.crm.api.RelatedRecords.DeleteRelatedRecordsUsingExternalIDParam') class GetRelatedRecordHeader(object): if_modified_since = Header('If-Modified-Since', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordHeader') class UpdateRelatedRecordHeader(object): pass class DelinkRecordHeader(object): pass class GetRelatedRecordUsingExternalIDHeader(object): if_modified_since = Header('If-Modified-Since', 'com.zoho.crm.api.RelatedRecords.GetRelatedRecordUsingExternalIDHeader') class UpdateRelatedRecordUsingExternalIDHeader(object): pass class DeleteRelatedRecordUsingExternalIDHeader(object): pass
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/related_records/related_records_operations.py
related_records_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.layouts.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__layouts = None self.__key_modified = dict() def get_layouts(self): """ The method to get the layouts Returns: list: An instance of list """ return self.__layouts def set_layouts(self, layouts): """ The method to set the value to layouts Parameters: layouts (list) : An instance of list """ if layouts is not None and not isinstance(layouts, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: layouts EXPECTED TYPE: list', None, None) self.__layouts = layouts self.__key_modified['layouts'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/layouts/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Section(object): def __init__(self): """Creates an instance of Section""" self.__display_label = None self.__sequence_number = None self.__issubformsection = None self.__tab_traversal = None self.__api_name = None self.__column_count = None self.__name = None self.__generated_type = None self.__fields = None self.__properties = None self.__type = None self.__key_modified = dict() def get_display_label(self): """ The method to get the display_label Returns: string: A string representing the display_label """ return self.__display_label def set_display_label(self, display_label): """ The method to set the value to display_label Parameters: display_label (string) : A string representing the display_label """ if display_label is not None and not isinstance(display_label, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: display_label EXPECTED TYPE: str', None, None) self.__display_label = display_label self.__key_modified['display_label'] = 1 def get_sequence_number(self): """ The method to get the sequence_number Returns: int: An int representing the sequence_number """ return self.__sequence_number def set_sequence_number(self, sequence_number): """ The method to set the value to sequence_number Parameters: sequence_number (int) : An int representing the sequence_number """ if sequence_number is not None and not isinstance(sequence_number, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: sequence_number EXPECTED TYPE: int', None, None) self.__sequence_number = sequence_number self.__key_modified['sequence_number'] = 1 def get_issubformsection(self): """ The method to get the issubformsection Returns: bool: A bool representing the issubformsection """ return self.__issubformsection def set_issubformsection(self, issubformsection): """ The method to set the value to issubformsection Parameters: issubformsection (bool) : A bool representing the issubformsection """ if issubformsection is not None and not isinstance(issubformsection, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: issubformsection EXPECTED TYPE: bool', None, None) self.__issubformsection = issubformsection self.__key_modified['isSubformSection'] = 1 def get_tab_traversal(self): """ The method to get the tab_traversal Returns: int: An int representing the tab_traversal """ return self.__tab_traversal def set_tab_traversal(self, tab_traversal): """ The method to set the value to tab_traversal Parameters: tab_traversal (int) : An int representing the tab_traversal """ if tab_traversal is not None and not isinstance(tab_traversal, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: tab_traversal EXPECTED TYPE: int', None, None) self.__tab_traversal = tab_traversal self.__key_modified['tab_traversal'] = 1 def get_api_name(self): """ The method to get the api_name Returns: string: A string representing the api_name """ return self.__api_name def set_api_name(self, api_name): """ The method to set the value to api_name Parameters: api_name (string) : A string representing the api_name """ if api_name is not None and not isinstance(api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: api_name EXPECTED TYPE: str', None, None) self.__api_name = api_name self.__key_modified['api_name'] = 1 def get_column_count(self): """ The method to get the column_count Returns: int: An int representing the column_count """ return self.__column_count def set_column_count(self, column_count): """ The method to set the value to column_count Parameters: column_count (int) : An int representing the column_count """ if column_count is not None and not isinstance(column_count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: column_count EXPECTED TYPE: int', None, None) self.__column_count = column_count self.__key_modified['column_count'] = 1 def get_name(self): """ The method to get the name Returns: string: A string representing the name """ return self.__name def set_name(self, name): """ The method to set the value to name Parameters: name (string) : A string representing the name """ if name is not None and not isinstance(name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: name EXPECTED TYPE: str', None, None) self.__name = name self.__key_modified['name'] = 1 def get_generated_type(self): """ The method to get the generated_type Returns: string: A string representing the generated_type """ return self.__generated_type def set_generated_type(self, generated_type): """ The method to set the value to generated_type Parameters: generated_type (string) : A string representing the generated_type """ if generated_type is not None and not isinstance(generated_type, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: generated_type EXPECTED TYPE: str', None, None) self.__generated_type = generated_type self.__key_modified['generated_type'] = 1 def get_fields(self): """ The method to get the fields Returns: list: An instance of list """ return self.__fields def set_fields(self, fields): """ The method to set the value to fields Parameters: fields (list) : An instance of list """ if fields is not None and not isinstance(fields, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: fields EXPECTED TYPE: list', None, None) self.__fields = fields self.__key_modified['fields'] = 1 def get_properties(self): """ The method to get the properties Returns: Properties: An instance of Properties """ return self.__properties def set_properties(self, properties): """ The method to set the value to properties Parameters: properties (Properties) : An instance of Properties """ try: from zcrmsdk.src.com.zoho.crm.api.layouts.properties import Properties except Exception: from .properties import Properties if properties is not None and not isinstance(properties, Properties): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: properties EXPECTED TYPE: Properties', None, None) self.__properties = properties self.__key_modified['properties'] = 1 def get_type(self): """ The method to get the type Returns: string: A string representing the type """ return self.__type def set_type(self, type): """ The method to set the value to type Parameters: type (string) : A string representing the type """ if type is not None and not isinstance(type, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: type EXPECTED TYPE: str', None, None) self.__type = type self.__key_modified['type'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/layouts/section.py
section.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.layouts.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .response_handler import ResponseHandler class APIException(ResponseHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/layouts/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class LayoutsOperations(object): def __init__(self, module=None): """ Creates an instance of LayoutsOperations with the given parameters Parameters: module (string) : A string representing the module """ if module is not None and not isinstance(module, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module EXPECTED TYPE: str', None, None) self.__module = module def get_layouts(self): """ The method to get layouts Returns: APIResponse: An instance of APIResponse Raises: SDKException """ handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/layouts' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_param(Param('module', 'com.zoho.crm.api.Layouts.GetLayoutsParam'), self.__module) try: from zcrmsdk.src.com.zoho.crm.api.layouts.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def get_layout(self, id): """ The method to get layout Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/layouts/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.add_param(Param('module', 'com.zoho.crm.api.Layouts.GetLayoutParam'), self.__module) try: from zcrmsdk.src.com.zoho.crm.api.layouts.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') class GetLayoutsParam(object): pass class GetLayoutParam(object): pass
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/layouts/layouts_operations.py
layouts_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Properties(object): def __init__(self): """Creates an instance of Properties""" self.__reorder_rows = None self.__tooltip = None self.__maximum_rows = None self.__key_modified = dict() def get_reorder_rows(self): """ The method to get the reorder_rows Returns: bool: A bool representing the reorder_rows """ return self.__reorder_rows def set_reorder_rows(self, reorder_rows): """ The method to set the value to reorder_rows Parameters: reorder_rows (bool) : A bool representing the reorder_rows """ if reorder_rows is not None and not isinstance(reorder_rows, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: reorder_rows EXPECTED TYPE: bool', None, None) self.__reorder_rows = reorder_rows self.__key_modified['reorder_rows'] = 1 def get_tooltip(self): """ The method to get the tooltip Returns: ToolTip: An instance of ToolTip """ return self.__tooltip def set_tooltip(self, tooltip): """ The method to set the value to tooltip Parameters: tooltip (ToolTip) : An instance of ToolTip """ try: from zcrmsdk.src.com.zoho.crm.api.fields import ToolTip except Exception: from ..fields import ToolTip if tooltip is not None and not isinstance(tooltip, ToolTip): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: tooltip EXPECTED TYPE: ToolTip', None, None) self.__tooltip = tooltip self.__key_modified['tooltip'] = 1 def get_maximum_rows(self): """ The method to get the maximum_rows Returns: int: An int representing the maximum_rows """ return self.__maximum_rows def set_maximum_rows(self, maximum_rows): """ The method to set the value to maximum_rows Parameters: maximum_rows (int) : An int representing the maximum_rows """ if maximum_rows is not None and not isinstance(maximum_rows, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: maximum_rows EXPECTED TYPE: int', None, None) self.__maximum_rows = maximum_rows self.__key_modified['maximum_rows'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/layouts/properties.py
properties.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Layout(object): def __init__(self): """Creates an instance of Layout""" self.__created_time = None self.__convert_mapping = None self.__modified_time = None self.__visible = None self.__created_for = None self.__name = None self.__modified_by = None self.__profiles = None self.__id = None self.__created_by = None self.__sections = None self.__status = None self.__display_type = None self.__show_business_card = None self.__key_modified = dict() def get_created_time(self): """ The method to get the created_time Returns: datetime: An instance of datetime """ return self.__created_time def set_created_time(self, created_time): """ The method to set the value to created_time Parameters: created_time (datetime) : An instance of datetime """ from datetime import datetime if created_time is not None and not isinstance(created_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_time EXPECTED TYPE: datetime', None, None) self.__created_time = created_time self.__key_modified['created_time'] = 1 def get_convert_mapping(self): """ The method to get the convert_mapping Returns: dict: An instance of dict """ return self.__convert_mapping def set_convert_mapping(self, convert_mapping): """ The method to set the value to convert_mapping Parameters: convert_mapping (dict) : An instance of dict """ if convert_mapping is not None and not isinstance(convert_mapping, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: convert_mapping EXPECTED TYPE: dict', None, None) self.__convert_mapping = convert_mapping self.__key_modified['convert_mapping'] = 1 def get_modified_time(self): """ The method to get the modified_time Returns: datetime: An instance of datetime """ return self.__modified_time def set_modified_time(self, modified_time): """ The method to set the value to modified_time Parameters: modified_time (datetime) : An instance of datetime """ from datetime import datetime if modified_time is not None and not isinstance(modified_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_time EXPECTED TYPE: datetime', None, None) self.__modified_time = modified_time self.__key_modified['modified_time'] = 1 def get_visible(self): """ The method to get the visible Returns: bool: A bool representing the visible """ return self.__visible def set_visible(self, visible): """ The method to set the value to visible Parameters: visible (bool) : A bool representing the visible """ if visible is not None and not isinstance(visible, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: visible EXPECTED TYPE: bool', None, None) self.__visible = visible self.__key_modified['visible'] = 1 def get_created_for(self): """ The method to get the created_for Returns: User: An instance of User """ return self.__created_for def set_created_for(self, created_for): """ The method to set the value to created_for Parameters: created_for (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_for is not None and not isinstance(created_for, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_for EXPECTED TYPE: User', None, None) self.__created_for = created_for self.__key_modified['created_for'] = 1 def get_name(self): """ The method to get the name Returns: string: A string representing the name """ return self.__name def set_name(self, name): """ The method to set the value to name Parameters: name (string) : A string representing the name """ if name is not None and not isinstance(name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: name EXPECTED TYPE: str', None, None) self.__name = name self.__key_modified['name'] = 1 def get_modified_by(self): """ The method to get the modified_by Returns: User: An instance of User """ return self.__modified_by def set_modified_by(self, modified_by): """ The method to set the value to modified_by Parameters: modified_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if modified_by is not None and not isinstance(modified_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_by EXPECTED TYPE: User', None, None) self.__modified_by = modified_by self.__key_modified['modified_by'] = 1 def get_profiles(self): """ The method to get the profiles Returns: list: An instance of list """ return self.__profiles def set_profiles(self, profiles): """ The method to set the value to profiles Parameters: profiles (list) : An instance of list """ if profiles is not None and not isinstance(profiles, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: profiles EXPECTED TYPE: list', None, None) self.__profiles = profiles self.__key_modified['profiles'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_created_by(self): """ The method to get the created_by Returns: User: An instance of User """ return self.__created_by def set_created_by(self, created_by): """ The method to set the value to created_by Parameters: created_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_by is not None and not isinstance(created_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_by EXPECTED TYPE: User', None, None) self.__created_by = created_by self.__key_modified['created_by'] = 1 def get_sections(self): """ The method to get the sections Returns: list: An instance of list """ return self.__sections def set_sections(self, sections): """ The method to set the value to sections Parameters: sections (list) : An instance of list """ if sections is not None and not isinstance(sections, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: sections EXPECTED TYPE: list', None, None) self.__sections = sections self.__key_modified['sections'] = 1 def get_status(self): """ The method to get the status Returns: int: An int representing the status """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (int) : An int representing the status """ if status is not None and not isinstance(status, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: int', None, None) self.__status = status self.__key_modified['status'] = 1 def get_display_type(self): """ The method to get the display_type Returns: int: An int representing the display_type """ return self.__display_type def set_display_type(self, display_type): """ The method to set the value to display_type Parameters: display_type (int) : An int representing the display_type """ if display_type is not None and not isinstance(display_type, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: display_type EXPECTED TYPE: int', None, None) self.__display_type = display_type self.__key_modified['display_type'] = 1 def get_show_business_card(self): """ The method to get the show_business_card Returns: bool: A bool representing the show_business_card """ return self.__show_business_card def set_show_business_card(self, show_business_card): """ The method to set the value to show_business_card Parameters: show_business_card (bool) : A bool representing the show_business_card """ if show_business_card is not None and not isinstance(show_business_card, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: show_business_card EXPECTED TYPE: bool', None, None) self.__show_business_card = show_business_card self.__key_modified['show_business_card'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/layouts/layout.py
layout.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.currencies.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__currencies = None self.__key_modified = dict() def get_currencies(self): """ The method to get the currencies Returns: list: An instance of list """ return self.__currencies def set_currencies(self, currencies): """ The method to set the value to currencies Parameters: currencies (list) : An instance of list """ if currencies is not None and not isinstance(currencies, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: currencies EXPECTED TYPE: list', None, None) self.__currencies = currencies self.__key_modified['currencies'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.currencies.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__currencies = None self.__key_modified = dict() def get_currencies(self): """ The method to get the currencies Returns: list: An instance of list """ return self.__currencies def set_currencies(self, currencies): """ The method to set the value to currencies Parameters: currencies (list) : An instance of list """ if currencies is not None and not isinstance(currencies, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: currencies EXPECTED TYPE: list', None, None) self.__currencies = currencies self.__key_modified['currencies'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants except Exception: from ..exception import SDKException from ..util import APIResponse, CommonAPIHandler, Constants class CurrenciesOperations(object): def __init__(self): """Creates an instance of CurrenciesOperations""" pass def get_currencies(self): """ The method to get currencies Returns: APIResponse: An instance of APIResponse Raises: SDKException """ handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/currencies' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) try: from zcrmsdk.src.com.zoho.crm.api.currencies.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def add_currencies(self, request): """ The method to add currencies Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/currencies' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.currencies.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def update_currencies(self, request): """ The method to update currencies Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/currencies' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.currencies.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def enable_multiple_currencies(self, request): """ The method to enable multiple currencies Parameters: request (BaseCurrencyWrapper) : An instance of BaseCurrencyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.base_currency_wrapper import BaseCurrencyWrapper except Exception: from .base_currency_wrapper import BaseCurrencyWrapper if request is not None and not isinstance(request, BaseCurrencyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BaseCurrencyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/currencies/actions/enable' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.currencies.base_currency_action_handler import BaseCurrencyActionHandler except Exception: from .base_currency_action_handler import BaseCurrencyActionHandler return handler_instance.api_call(BaseCurrencyActionHandler.__module__, 'application/json') def update_base_currency(self, request): """ The method to update base currency Parameters: request (BaseCurrencyWrapper) : An instance of BaseCurrencyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.base_currency_wrapper import BaseCurrencyWrapper except Exception: from .base_currency_wrapper import BaseCurrencyWrapper if request is not None and not isinstance(request, BaseCurrencyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BaseCurrencyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/currencies/actions/enable' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.currencies.base_currency_action_handler import BaseCurrencyActionHandler except Exception: from .base_currency_action_handler import BaseCurrencyActionHandler return handler_instance.api_call(BaseCurrencyActionHandler.__module__, 'application/json') def get_currency(self, id): """ The method to get currency Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/currencies/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) try: from zcrmsdk.src.com.zoho.crm.api.currencies.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def update_currency(self, id, request): """ The method to update currency Parameters: id (int) : An int representing the id request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/org/currencies/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) try: from zcrmsdk.src.com.zoho.crm.api.currencies.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/currencies_operations.py
currencies_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Currency(object): def __init__(self): """Creates an instance of Currency""" self.__symbol = None self.__created_time = None self.__is_active = None self.__exchange_rate = None self.__format = None self.__created_by = None self.__prefix_symbol = None self.__is_base = None self.__modified_time = None self.__name = None self.__modified_by = None self.__id = None self.__iso_code = None self.__key_modified = dict() def get_symbol(self): """ The method to get the symbol Returns: string: A string representing the symbol """ return self.__symbol def set_symbol(self, symbol): """ The method to set the value to symbol Parameters: symbol (string) : A string representing the symbol """ if symbol is not None and not isinstance(symbol, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: symbol EXPECTED TYPE: str', None, None) self.__symbol = symbol self.__key_modified['symbol'] = 1 def get_created_time(self): """ The method to get the created_time Returns: datetime: An instance of datetime """ return self.__created_time def set_created_time(self, created_time): """ The method to set the value to created_time Parameters: created_time (datetime) : An instance of datetime """ from datetime import datetime if created_time is not None and not isinstance(created_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_time EXPECTED TYPE: datetime', None, None) self.__created_time = created_time self.__key_modified['created_time'] = 1 def get_is_active(self): """ The method to get the is_active Returns: bool: A bool representing the is_active """ return self.__is_active def set_is_active(self, is_active): """ The method to set the value to is_active Parameters: is_active (bool) : A bool representing the is_active """ if is_active is not None and not isinstance(is_active, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: is_active EXPECTED TYPE: bool', None, None) self.__is_active = is_active self.__key_modified['is_active'] = 1 def get_exchange_rate(self): """ The method to get the exchange_rate Returns: string: A string representing the exchange_rate """ return self.__exchange_rate def set_exchange_rate(self, exchange_rate): """ The method to set the value to exchange_rate Parameters: exchange_rate (string) : A string representing the exchange_rate """ if exchange_rate is not None and not isinstance(exchange_rate, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: exchange_rate EXPECTED TYPE: str', None, None) self.__exchange_rate = exchange_rate self.__key_modified['exchange_rate'] = 1 def get_format(self): """ The method to get the format Returns: Format: An instance of Format """ return self.__format def set_format(self, format): """ The method to set the value to format Parameters: format (Format) : An instance of Format """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.format import Format except Exception: from .format import Format if format is not None and not isinstance(format, Format): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: format EXPECTED TYPE: Format', None, None) self.__format = format self.__key_modified['format'] = 1 def get_created_by(self): """ The method to get the created_by Returns: User: An instance of User """ return self.__created_by def set_created_by(self, created_by): """ The method to set the value to created_by Parameters: created_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_by is not None and not isinstance(created_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_by EXPECTED TYPE: User', None, None) self.__created_by = created_by self.__key_modified['created_by'] = 1 def get_prefix_symbol(self): """ The method to get the prefix_symbol Returns: bool: A bool representing the prefix_symbol """ return self.__prefix_symbol def set_prefix_symbol(self, prefix_symbol): """ The method to set the value to prefix_symbol Parameters: prefix_symbol (bool) : A bool representing the prefix_symbol """ if prefix_symbol is not None and not isinstance(prefix_symbol, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: prefix_symbol EXPECTED TYPE: bool', None, None) self.__prefix_symbol = prefix_symbol self.__key_modified['prefix_symbol'] = 1 def get_is_base(self): """ The method to get the is_base Returns: bool: A bool representing the is_base """ return self.__is_base def set_is_base(self, is_base): """ The method to set the value to is_base Parameters: is_base (bool) : A bool representing the is_base """ if is_base is not None and not isinstance(is_base, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: is_base EXPECTED TYPE: bool', None, None) self.__is_base = is_base self.__key_modified['is_base'] = 1 def get_modified_time(self): """ The method to get the modified_time Returns: datetime: An instance of datetime """ return self.__modified_time def set_modified_time(self, modified_time): """ The method to set the value to modified_time Parameters: modified_time (datetime) : An instance of datetime """ from datetime import datetime if modified_time is not None and not isinstance(modified_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_time EXPECTED TYPE: datetime', None, None) self.__modified_time = modified_time self.__key_modified['modified_time'] = 1 def get_name(self): """ The method to get the name Returns: string: A string representing the name """ return self.__name def set_name(self, name): """ The method to set the value to name Parameters: name (string) : A string representing the name """ if name is not None and not isinstance(name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: name EXPECTED TYPE: str', None, None) self.__name = name self.__key_modified['name'] = 1 def get_modified_by(self): """ The method to get the modified_by Returns: User: An instance of User """ return self.__modified_by def set_modified_by(self, modified_by): """ The method to set the value to modified_by Parameters: modified_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if modified_by is not None and not isinstance(modified_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_by EXPECTED TYPE: User', None, None) self.__modified_by = modified_by self.__key_modified['modified_by'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_iso_code(self): """ The method to get the iso_code Returns: string: A string representing the iso_code """ return self.__iso_code def set_iso_code(self, iso_code): """ The method to set the value to iso_code Parameters: iso_code (string) : A string representing the iso_code """ if iso_code is not None and not isinstance(iso_code, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: iso_code EXPECTED TYPE: str', None, None) self.__iso_code = iso_code self.__key_modified['iso_code'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/currency.py
currency.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants except Exception: from ..exception import SDKException from ..util import Choice, Constants class Format(object): def __init__(self): """Creates an instance of Format""" self.__decimal_separator = None self.__thousand_separator = None self.__decimal_places = None self.__key_modified = dict() def get_decimal_separator(self): """ The method to get the decimal_separator Returns: Choice: An instance of Choice """ return self.__decimal_separator def set_decimal_separator(self, decimal_separator): """ The method to set the value to decimal_separator Parameters: decimal_separator (Choice) : An instance of Choice """ if decimal_separator is not None and not isinstance(decimal_separator, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: decimal_separator EXPECTED TYPE: Choice', None, None) self.__decimal_separator = decimal_separator self.__key_modified['decimal_separator'] = 1 def get_thousand_separator(self): """ The method to get the thousand_separator Returns: Choice: An instance of Choice """ return self.__thousand_separator def set_thousand_separator(self, thousand_separator): """ The method to set the value to thousand_separator Parameters: thousand_separator (Choice) : An instance of Choice """ if thousand_separator is not None and not isinstance(thousand_separator, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: thousand_separator EXPECTED TYPE: Choice', None, None) self.__thousand_separator = thousand_separator self.__key_modified['thousand_separator'] = 1 def get_decimal_places(self): """ The method to get the decimal_places Returns: Choice: An instance of Choice """ return self.__decimal_places def set_decimal_places(self, decimal_places): """ The method to set the value to decimal_places Parameters: decimal_places (Choice) : An instance of Choice """ if decimal_places is not None and not isinstance(decimal_places, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: decimal_places EXPECTED TYPE: Choice', None, None) self.__decimal_places = decimal_places self.__key_modified['decimal_places'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/format.py
format.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.currencies.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.currencies.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.currencies.action_handler import ActionHandler from zcrmsdk.src.com.zoho.crm.api.currencies.base_currency_action_handler import BaseCurrencyActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .action_handler import ActionHandler from .base_currency_action_handler import BaseCurrencyActionHandler class APIException(ResponseHandler, ActionResponse, ActionHandler, BaseCurrencyActionHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class BaseCurrencyWrapper(object): def __init__(self): """Creates an instance of BaseCurrencyWrapper""" self.__base_currency = None self.__key_modified = dict() def get_base_currency(self): """ The method to get the base_currency Returns: Currency: An instance of Currency """ return self.__base_currency def set_base_currency(self, base_currency): """ The method to set the value to base_currency Parameters: base_currency (Currency) : An instance of Currency """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.currency import Currency except Exception: from .currency import Currency if base_currency is not None and not isinstance(base_currency, Currency): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: base_currency EXPECTED TYPE: Currency', None, None) self.__base_currency = base_currency self.__key_modified['base_currency'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/base_currency_wrapper.py
base_currency_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.currencies.base_currency_action_handler import BaseCurrencyActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .base_currency_action_handler import BaseCurrencyActionHandler class BaseCurrencyActionWrapper(BaseCurrencyActionHandler): def __init__(self): """Creates an instance of BaseCurrencyActionWrapper""" super().__init__() self.__base_currency = None self.__key_modified = dict() def get_base_currency(self): """ The method to get the base_currency Returns: ActionResponse: An instance of ActionResponse """ return self.__base_currency def set_base_currency(self, base_currency): """ The method to set the value to base_currency Parameters: base_currency (ActionResponse) : An instance of ActionResponse """ try: from zcrmsdk.src.com.zoho.crm.api.currencies.action_response import ActionResponse except Exception: from .action_response import ActionResponse if base_currency is not None and not isinstance(base_currency, ActionResponse): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: base_currency EXPECTED TYPE: ActionResponse', None, None) self.__base_currency = base_currency self.__key_modified['base_currency'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/base_currency_action_wrapper.py
base_currency_action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.currencies.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/currencies/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.tags.record_action_handler import RecordActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .record_action_handler import RecordActionHandler class RecordActionWrapper(RecordActionHandler): def __init__(self): """Creates an instance of RecordActionWrapper""" super().__init__() self.__data = None self.__wf_scheduler = None self.__success_count = None self.__locked_count = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def get_wf_scheduler(self): """ The method to get the wf_scheduler Returns: bool: A bool representing the wf_scheduler """ return self.__wf_scheduler def set_wf_scheduler(self, wf_scheduler): """ The method to set the value to wf_scheduler Parameters: wf_scheduler (bool) : A bool representing the wf_scheduler """ if wf_scheduler is not None and not isinstance(wf_scheduler, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: wf_scheduler EXPECTED TYPE: bool', None, None) self.__wf_scheduler = wf_scheduler self.__key_modified['wf_scheduler'] = 1 def get_success_count(self): """ The method to get the success_count Returns: string: A string representing the success_count """ return self.__success_count def set_success_count(self, success_count): """ The method to set the value to success_count Parameters: success_count (string) : A string representing the success_count """ if success_count is not None and not isinstance(success_count, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: success_count EXPECTED TYPE: str', None, None) self.__success_count = success_count self.__key_modified['success_count'] = 1 def get_locked_count(self): """ The method to get the locked_count Returns: int: An int representing the locked_count """ return self.__locked_count def set_locked_count(self, locked_count): """ The method to set the value to locked_count Parameters: locked_count (int) : An int representing the locked_count """ if locked_count is not None and not isinstance(locked_count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: locked_count EXPECTED TYPE: int', None, None) self.__locked_count = locked_count self.__key_modified['locked_count'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/record_action_wrapper.py
record_action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.tags.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__tags = None self.__key_modified = dict() def get_tags(self): """ The method to get the tags Returns: list: An instance of list """ return self.__tags def set_tags(self, tags): """ The method to set the value to tags Parameters: tags (list) : An instance of list """ if tags is not None and not isinstance(tags, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: tags EXPECTED TYPE: list', None, None) self.__tags = tags self.__key_modified['tags'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.tags.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__tags = None self.__info = None self.__key_modified = dict() def get_tags(self): """ The method to get the tags Returns: list: An instance of list """ return self.__tags def set_tags(self, tags): """ The method to set the value to tags Parameters: tags (list) : An instance of list """ if tags is not None and not isinstance(tags, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: tags EXPECTED TYPE: list', None, None) self.__tags = tags self.__key_modified['tags'] = 1 def get_info(self): """ The method to get the info Returns: Info: An instance of Info """ return self.__info def set_info(self, info): """ The method to set the value to info Parameters: info (Info) : An instance of Info """ try: from zcrmsdk.src.com.zoho.crm.api.tags.info import Info except Exception: from .info import Info if info is not None and not isinstance(info, Info): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Info', None, None) self.__info = info self.__key_modified['info'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class ConflictWrapper(object): def __init__(self): """Creates an instance of ConflictWrapper""" self.__conflict_id = None self.__key_modified = dict() def get_conflict_id(self): """ The method to get the conflict_id Returns: string: A string representing the conflict_id """ return self.__conflict_id def set_conflict_id(self, conflict_id): """ The method to set the value to conflict_id Parameters: conflict_id (string) : A string representing the conflict_id """ if conflict_id is not None and not isinstance(conflict_id, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: conflict_id EXPECTED TYPE: str', None, None) self.__conflict_id = conflict_id self.__key_modified['conflict_id'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/conflict_wrapper.py
conflict_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.tags.count_handler import CountHandler except Exception: from ..exception import SDKException from ..util import Constants from .count_handler import CountHandler class CountWrapper(CountHandler): def __init__(self): """Creates an instance of CountWrapper""" super().__init__() self.__count = None self.__key_modified = dict() def get_count(self): """ The method to get the count Returns: string: A string representing the count """ return self.__count def set_count(self, count): """ The method to set the value to count Parameters: count (string) : A string representing the count """ if count is not None and not isinstance(count, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: count EXPECTED TYPE: str', None, None) self.__count = count self.__key_modified['count'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/count_wrapper.py
count_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.tags.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.tags.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.tags.count_handler import CountHandler from zcrmsdk.src.com.zoho.crm.api.tags.action_handler import ActionHandler from zcrmsdk.src.com.zoho.crm.api.tags.record_action_response import RecordActionResponse from zcrmsdk.src.com.zoho.crm.api.tags.record_action_handler import RecordActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .count_handler import CountHandler from .action_handler import ActionHandler from .record_action_response import RecordActionResponse from .record_action_handler import RecordActionHandler class APIException(ResponseHandler, ActionResponse, ActionHandler, RecordActionResponse, RecordActionHandler, CountHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Info(object): def __init__(self): """Creates an instance of Info""" self.__count = None self.__allowed_count = None self.__key_modified = dict() def get_count(self): """ The method to get the count Returns: int: An int representing the count """ return self.__count def set_count(self, count): """ The method to set the value to count Parameters: count (int) : An int representing the count """ if count is not None and not isinstance(count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: count EXPECTED TYPE: int', None, None) self.__count = count self.__key_modified['count'] = 1 def get_allowed_count(self): """ The method to get the allowed_count Returns: int: An int representing the allowed_count """ return self.__allowed_count def set_allowed_count(self, allowed_count): """ The method to set the value to allowed_count Parameters: allowed_count (int) : An int representing the allowed_count """ if allowed_count is not None and not isinstance(allowed_count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: allowed_count EXPECTED TYPE: int', None, None) self.__allowed_count = allowed_count self.__key_modified['allowed_count'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/info.py
info.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param class TagsOperations(object): def __init__(self): """Creates an instance of TagsOperations""" pass def get_tags(self, param_instance=None): """ The method to get tags Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/tags' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def create_tags(self, request, param_instance=None): """ The method to create tags Parameters: request (BodyWrapper) : An instance of BodyWrapper param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.tags.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/tags' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def update_tags(self, request, param_instance=None): """ The method to update tags Parameters: request (BodyWrapper) : An instance of BodyWrapper param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.tags.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/tags' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def update_tag(self, id, request, param_instance=None): """ The method to update tag Parameters: id (int) : An int representing the id request (BodyWrapper) : An instance of BodyWrapper param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.tags.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/tags/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delete_tag(self, id): """ The method to delete tag Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/tags/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) try: from zcrmsdk.src.com.zoho.crm.api.tags.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def merge_tags(self, id, request): """ The method to merge tags Parameters: id (int) : An int representing the id request (MergeWrapper) : An instance of MergeWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.tags.merge_wrapper import MergeWrapper except Exception: from .merge_wrapper import MergeWrapper if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) if request is not None and not isinstance(request, MergeWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: MergeWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/tags/' api_path = api_path + str(id) api_path = api_path + '/actions/merge' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.tags.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def add_tags_to_record(self, record_id, module_api_name, param_instance=None): """ The method to add tags to record Parameters: record_id (int) : An int representing the record_id module_api_name (string) : A string representing the module_api_name param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if not isinstance(module_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module_api_name EXPECTED TYPE: str', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/actions/add_tags' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.record_action_handler import RecordActionHandler except Exception: from .record_action_handler import RecordActionHandler return handler_instance.api_call(RecordActionHandler.__module__, 'application/json') def remove_tags_from_record(self, record_id, module_api_name, param_instance=None): """ The method to remove tags from record Parameters: record_id (int) : An int representing the record_id module_api_name (string) : A string representing the module_api_name param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(record_id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: record_id EXPECTED TYPE: int', None, None) if not isinstance(module_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module_api_name EXPECTED TYPE: str', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(module_api_name) api_path = api_path + '/' api_path = api_path + str(record_id) api_path = api_path + '/actions/remove_tags' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.record_action_handler import RecordActionHandler except Exception: from .record_action_handler import RecordActionHandler return handler_instance.api_call(RecordActionHandler.__module__, 'application/json') def add_tags_to_multiple_records(self, module_api_name, param_instance=None): """ The method to add tags to multiple records Parameters: module_api_name (string) : A string representing the module_api_name param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(module_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module_api_name EXPECTED TYPE: str', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(module_api_name) api_path = api_path + '/actions/add_tags' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.record_action_handler import RecordActionHandler except Exception: from .record_action_handler import RecordActionHandler return handler_instance.api_call(RecordActionHandler.__module__, 'application/json') def remove_tags_from_multiple_records(self, module_api_name, param_instance=None): """ The method to remove tags from multiple records Parameters: module_api_name (string) : A string representing the module_api_name param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(module_api_name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: module_api_name EXPECTED TYPE: str', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/' api_path = api_path + str(module_api_name) api_path = api_path + '/actions/remove_tags' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_mandatory_checker(True) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.record_action_handler import RecordActionHandler except Exception: from .record_action_handler import RecordActionHandler return handler_instance.api_call(RecordActionHandler.__module__, 'application/json') def get_record_count_for_tag(self, id, param_instance=None): """ The method to get record count for tag Parameters: id (int) : An int representing the id param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/settings/tags/' api_path = api_path + str(id) api_path = api_path + '/actions/records_count' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.tags.count_handler import CountHandler except Exception: from .count_handler import CountHandler return handler_instance.api_call(CountHandler.__module__, 'application/json') class GetTagsParam(object): module = Param('module', 'com.zoho.crm.api.Tags.GetTagsParam') my_tags = Param('my_tags', 'com.zoho.crm.api.Tags.GetTagsParam') class CreateTagsParam(object): module = Param('module', 'com.zoho.crm.api.Tags.CreateTagsParam') class UpdateTagsParam(object): module = Param('module', 'com.zoho.crm.api.Tags.UpdateTagsParam') class UpdateTagParam(object): module = Param('module', 'com.zoho.crm.api.Tags.UpdateTagParam') class AddTagsToRecordParam(object): tag_names = Param('tag_names', 'com.zoho.crm.api.Tags.AddTagsToRecordParam') over_write = Param('over_write', 'com.zoho.crm.api.Tags.AddTagsToRecordParam') class RemoveTagsFromRecordParam(object): tag_names = Param('tag_names', 'com.zoho.crm.api.Tags.RemoveTagsFromRecordParam') class AddTagsToMultipleRecordsParam(object): tag_names = Param('tag_names', 'com.zoho.crm.api.Tags.AddTagsToMultipleRecordsParam') ids = Param('ids', 'com.zoho.crm.api.Tags.AddTagsToMultipleRecordsParam') over_write = Param('over_write', 'com.zoho.crm.api.Tags.AddTagsToMultipleRecordsParam') class RemoveTagsFromMultipleRecordsParam(object): tag_names = Param('tag_names', 'com.zoho.crm.api.Tags.RemoveTagsFromMultipleRecordsParam') ids = Param('ids', 'com.zoho.crm.api.Tags.RemoveTagsFromMultipleRecordsParam') class GetRecordCountForTagParam(object): module = Param('module', 'com.zoho.crm.api.Tags.GetRecordCountForTagParam')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/tags_operations.py
tags_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Tag(object): def __init__(self): """Creates an instance of Tag""" self.__created_time = None self.__modified_time = None self.__name = None self.__modified_by = None self.__color_code = None self.__id = None self.__created_by = None self.__key_modified = dict() def get_created_time(self): """ The method to get the created_time Returns: datetime: An instance of datetime """ return self.__created_time def set_created_time(self, created_time): """ The method to set the value to created_time Parameters: created_time (datetime) : An instance of datetime """ from datetime import datetime if created_time is not None and not isinstance(created_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_time EXPECTED TYPE: datetime', None, None) self.__created_time = created_time self.__key_modified['created_time'] = 1 def get_modified_time(self): """ The method to get the modified_time Returns: datetime: An instance of datetime """ return self.__modified_time def set_modified_time(self, modified_time): """ The method to set the value to modified_time Parameters: modified_time (datetime) : An instance of datetime """ from datetime import datetime if modified_time is not None and not isinstance(modified_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_time EXPECTED TYPE: datetime', None, None) self.__modified_time = modified_time self.__key_modified['modified_time'] = 1 def get_name(self): """ The method to get the name Returns: string: A string representing the name """ return self.__name def set_name(self, name): """ The method to set the value to name Parameters: name (string) : A string representing the name """ if name is not None and not isinstance(name, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: name EXPECTED TYPE: str', None, None) self.__name = name self.__key_modified['name'] = 1 def get_modified_by(self): """ The method to get the modified_by Returns: User: An instance of User """ return self.__modified_by def set_modified_by(self, modified_by): """ The method to set the value to modified_by Parameters: modified_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if modified_by is not None and not isinstance(modified_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_by EXPECTED TYPE: User', None, None) self.__modified_by = modified_by self.__key_modified['modified_by'] = 1 def get_color_code(self): """ The method to get the color_code Returns: string: A string representing the color_code """ return self.__color_code def set_color_code(self, color_code): """ The method to set the value to color_code Parameters: color_code (string) : A string representing the color_code """ if color_code is not None and not isinstance(color_code, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: color_code EXPECTED TYPE: str', None, None) self.__color_code = color_code self.__key_modified['color_code'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_created_by(self): """ The method to get the created_by Returns: User: An instance of User """ return self.__created_by def set_created_by(self, created_by): """ The method to set the value to created_by Parameters: created_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_by is not None and not isinstance(created_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_by EXPECTED TYPE: User', None, None) self.__created_by = created_by self.__key_modified['created_by'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/tag.py
tag.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.tags.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.tags.record_action_response import RecordActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .record_action_response import RecordActionResponse class SuccessResponse(ActionResponse, RecordActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__code = None self.__status = None self.__message = None self.__details = None self.__key_modified = dict() def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/tags/success_response.py
success_response.py
try: from dateutil.tz import tz import dateutil.parser from zcrmsdk.src.com.zoho.crm.api.util.constants import Constants from datetime import date, datetime except Exception: from dateutil.tz import tz import dateutil.parser from .constants import Constants from datetime import date, datetime class DataTypeConverter(object): """ This class converts JSON value to the expected object type and vice versa. """ pre_converter_map = {} post_converter_map = {} @staticmethod def init(): """ The method to initialize the PreConverter and PostConverter lambda functions. """ if len(DataTypeConverter.pre_converter_map) != 0 and len(DataTypeConverter.post_converter_map) != 0: return DataTypeConverter.add_to_map("String", lambda obj: str(obj), lambda obj: str(obj)) DataTypeConverter.add_to_map("Integer", lambda obj: int(obj), lambda obj: int(obj)) DataTypeConverter.add_to_map("Long", lambda obj: int(obj) if str(obj) != Constants.NULL_VALUE else None, lambda obj: int(obj)) DataTypeConverter.add_to_map("Boolean", lambda obj: bool(obj), lambda obj: bool(obj)) DataTypeConverter.add_to_map("Float", lambda obj: float(obj), lambda obj: float(obj)) DataTypeConverter.add_to_map("Double", lambda obj: float(obj), lambda obj: float(obj)) DataTypeConverter.add_to_map("Date", lambda obj: dateutil.parser.isoparse(obj).date(), lambda obj: obj.isoformat()) DataTypeConverter.add_to_map("DateTime", lambda obj: dateutil.parser.isoparse(obj).astimezone(tz.tzlocal()), lambda obj: obj.replace(microsecond=0).astimezone(tz.tzlocal()).isoformat()) DataTypeConverter.add_to_map("Object", lambda obj: DataTypeConverter.pre_convert_object_data(obj), lambda obj: DataTypeConverter.post_convert_object_data(obj)) @staticmethod def pre_convert_object_data(obj): return obj @staticmethod def post_convert_object_data(obj): if obj is None: return None if isinstance(obj, list): list_value = [] for data in obj: list_value.append(DataTypeConverter.post_convert_object_data(data)) return list_value elif isinstance(obj, dict): dict_value = {} for key, value in obj.items(): dict_value[key] = DataTypeConverter.post_convert_object_data(value) return dict_value elif isinstance(obj, date): return DataTypeConverter.post_convert(obj, Constants.DATE_NAMESPACE) elif isinstance(obj, datetime): return DataTypeConverter.post_convert(obj, Constants.DATETIME_NAMESPACE) else: return obj @staticmethod def add_to_map(name, pre_converter, post_converter): """ This method to add PreConverter and PostConverter instance. :param name: A str containing the data type class name. :param pre_converter: A pre_converter instance. :param post_converter: A post_converter instance. """ DataTypeConverter.pre_converter_map[name] = pre_converter DataTypeConverter.post_converter_map[name] = post_converter @staticmethod def pre_convert(obj, data_type): """ The method to convert JSON value to expected data value. :param obj: An object containing the JSON value. :param data_type: A str containing the expected method return type. :return: An object containing the expected data value. """ DataTypeConverter.init() if data_type in DataTypeConverter.pre_converter_map: return DataTypeConverter.pre_converter_map[data_type](obj) @staticmethod def post_convert(obj, data_type): """ The method to convert python data to JSON data value. :param obj: A object containing the python data value. :param data_type: A str containing the expected method return type. :return: An object containing the expected data value. """ DataTypeConverter.init() if data_type in DataTypeConverter.post_converter_map: return DataTypeConverter.post_converter_map[data_type](obj)
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/datatype_converter.py
datatype_converter.py
import datetime class Constants(object): """ This class uses the SDK constants name reference. """ DATA_TYPE_ERROR = "DATA TYPE ERROR" ERROR = "error" REQUEST_METHOD_GET = "GET" REQUEST_METHOD_POST = "POST" REQUEST_METHOD_PUT = "PUT" REQUEST_METHOD_DELETE = "DELETE" GIVEN_VALUE = "given-value" REQUEST_METHOD_PATCH = 'PATCH' OAUTH_HEADER_PREFIX = "Zoho-oauthtoken " AUTHORIZATION = "Authorization" API_NAME = "api_name" PHOTO = "photo" API_VERSION = "v2.1" CRM = "crm" INPUT_ERROR = "INPUT_ERROR" LOGGER_LEVELS = { "CRITICAL": "CRITICAL", "ERROR": "ERROR", "WARNING": "WARNING", "INFO": "INFO", "DEBUG": "DEBUG", "NOTSET": "NOTSET" } INVENTORY_MODULES_ITEMS = ["invoiced_items", "quoted_items", "purchase_items", "ordered_items"] DEFAULT_MODULE_NAME_VS_API_NAME = { "leads": "Leads", "contacts": "Contacts", "accounts": "Accounts", "deals": "Deals", "tasks": "Tasks", "events": "Events", "activities": "Activities", "calls": "Calls", "products": "Products", "quotes": "Quotes", "sales_orders": "Sales_Orders", "purchase_orders": "Purchase_Orders", "invoices": "Invoices", "campaigns": "Campaigns", "vendors": "Vendors", "price_books": "Price_Books", "cases": "Cases", "solutions": "Solutions", "visits": "Visits", "approvals": "Approvals", "notes": "Notes", "attachments": "Attachments", "actions_performed": "Actions_Performed", } PROXY_SETTINGS = "Proxy settings - " PROXY_HOST = "Host: " PROXY_PORT = "Port: " PROXY_USER = "User: " PROXY_DOMAIN = "Domain: " GET_TOKEN_BY_ID_DB_ERROR = "Exception in getTokenById - DBStore : Given ID is invalid" GET_TOKEN_BY_ID_FILE_ERROR = "Exception in getTokenById - FileStore : Given ID is invalid" MYSQL_TABLE_NAME = "oauthtoken" SWITCH_USER_ERROR = "SWITCH USER ERROR" LOGGER_INITIALIZATION_ERROR = "Exception in Logger Initialization : " INVALID_ID_MSG = "The given id seems to be invalid." RESOURCE_PATH_INVALID_ERROR_MESSAGE = "Resource Path MUST be a valid directory." API_MAX_RECORDS_MSG = "Cannot process more than 100 records at a time." INVALID_DATA = "INVALID_DATA" CODE_SUCCESS = "SUCCESS" STATUS_SUCCESS = "success" STATUS_ERROR = "error" GRANT_TYPE = "grant_type" GRANT_TYPE_AUTH_CODE = "authorization_code" ACCESS_TOKEN = "access_token" EXPIRES_IN = "expires_in" EXPIRES_IN_SEC = "expires_in_sec" REFRESH_TOKEN = "refresh_token" CLIENT_ID = "client_id" CLIENT_SECRET = "client_secret" REDIRECT_URI = "redirect_uri" REDIRECT_URL = "redirect_url" OBJECT = "Object" DATA_TYPE = { "String": str, "List": list, "Integer": int, "HashMap": dict, "Map": dict, "Long": int, "Double": float, "Float": float, "DateTime": datetime.datetime, "Date": datetime.date, "Boolean": bool } OBJECT_KEY = "object" PHOTO_SUPPORTED_MODULES = ["leads", "contacts", "accounts", "products", "vendors"] GIVEN_LENGTH = "given-length" ZOHO_SDK = "X-ZOHO-SDK" SDK_VERSION = "2.0.0" CONTENT_DISPOSITION = "Content-Disposition" TOKEN_ERROR = "TOKEN ERROR" SAVE_TOKEN_ERROR = "Exception in saving tokens" INVALID_CLIENT_ERROR = "INVALID CLIENT ERROR" ERROR_KEY = 'error' GET_TOKEN_ERROR = "Exception in getting access token" MYSQL_HOST = "localhost" MYSQL_DATABASE_NAME = "zohooauth" MYSQL_USER_NAME = "root" MYSQL_PORT_NUMBER = "3306" GET_TOKEN_DB_ERROR = "Exception in getToken - DBStore" TOKEN_STORE = "TOKEN_STORE" DELETE_TOKEN_DB_ERROR = "Exception in delete_token - DBStore" SAVE_TOKEN_DB_ERROR = "Exception in save_token - DBStore" USER_MAIL = "user_mail" GRANT_TOKEN = "grant_token" EXPIRY_TIME = "expiry_time" GET_TOKEN_FILE_ERROR = "Exception in get_token - FileStore" SAVE_TOKEN_FILE_ERROR = "Exception in save_token - FileStore" DELETE_TOKEN_FILE_ERROR = "Exception in delete_token - FileStore" TYPE = "type" STREAM_WRAPPER_CLASS_PATH = 'zcrmsdk.src.com.zoho.crm.api.util.StreamWrapper' FIELD = "field" NAME = "name" INDEX = "index" CLASS = "class" ACCEPTED_TYPE = "accepted_type" GIVEN_TYPE = "given_type" TYPE_ERROR = "TYPE ERROR" VALUES = "values" ACCEPTED_VALUES = "accepted_values" UNACCEPTED_VALUES_ERROR = "UNACCEPTED VALUES ERROR" MIN_LENGTH = "min-length" MINIMUM_LENGTH = "minimum-length" MINIMUM_LENGTH_ERROR = "MINIMUM LENGTH ERROR" UNIQUE = "unique" FIRST_INDEX = "first-index" NEXT_INDEX = "next-index" UNIQUE_KEY_ERROR = "UNIQUE KEY ERROR" MAX_LENGTH = "max-length" MAXIMUM_LENGTH = "maximum-length" MAXIMUM_LENGTH_ERROR = "MAXIMUM LENGTH ERROR" REGEX = "regex" INSTANCE_NUMBER = "instance-number" REGEX_MISMATCH_ERROR = "REGEX MISMATCH ERROR" READ_ONLY = "read-only" IS_KEY_MODIFIED = 'is_key_modified' REQUIRED = "required" REQUIRED_IN_UPDATE = "required-in-update" PRIMARY = "primary" MANDATORY_VALUE_ERROR = "MANDATORY VALUE ERROR" MANDATORY_VALUE_NULL_ERROR = "MANDATORY VALUE NULL ERROR" MANDATORY_KEY_ERROR = "Value missing or None for mandatory key(s): " MANDATORY_KEY_NULL_ERROR = "Null Value for mandatory key : " SET_KEY_MODIFIED = "set_key_modified" LIST_NAMESPACE = "List" MAP_NAMESPACE = "Map" HASH_MAP = "HashMap" STRUCTURE_NAME = "structure_name" KEYS = "keys" INTERFACE = "interface" RECORD_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.Record" RECORD_TYPE = "zcrmsdk.src.com.zoho.crm.api.record.record.Record" INVENTORY_LINE_ITEMS = "zcrmsdk.src.com.zoho.crm.api.record.InventoryLineItems" PRICING_DETAILS_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.PricingDetails" COMMENT_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.Comment" FIELD_FILE_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.FileDetails" REMIND_AT_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.RemindAt" CONSENT_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.Consent" LINE_TAX_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.LineTax" TAX_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.Tax" PRODUCTS = "Products" TAX = "TAX" TERRITORY = "Territory" REMINDER_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.Reminder" TERRITORY_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.Territory" IMAGE_UPLOAD_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.ImageUpload" ATTACHMENTS_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.attachments.Attachment" RECURRING_ACTIVITY_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.record.RecurringActivity" PARTICIPANTS = "zcrmsdk.src.com.zoho.crm.api.record.Participants" PACKAGE_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api." USER_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.users.User" MODULE_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.modules.Module" LAYOUT_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.layouts.Layout" CHOICE_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.util.Choice" KEY_VALUES = "key_values" RECORD_CLASS_NAME = "Record" KEY_MODIFIED = "key_modified" COMMENTS = "Comments" CLASSES = "classes" LOGFILE_NAME = "sdk_logs.log" USER = "user" EXPECTED_TYPE = "expected-type" USER_AGENT = "Mozilla/5.0" USER_AGENT_KEY = "user-agent" AT = '@' EXPECTED_TOKEN_TYPES = 'REFRESH, GRANT' INITIALIZATION_ERROR = "INITIALIZATION ERROR" ENVIRONMENT = "environment" STORE = "store" TOKEN = "token" SDK_CONFIG = "sdk_config" USER_PROXY = "proxy" JSON_DETAILS_FILE_PATH = 'json_details.json' EMAIL = "email" USER_SIGNATURE_ERROR = "USERSIGNATURE ERROR" USER_INITIALIZATION_ERROR = "Error during User Initialization" EMAIL_REGEX = '^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$' STRING = "String" TOKEN_TYPE = "token_type" GRANT = "GRANT" REFRESH = "REFRESH" CONTENT_TYPE = 'Content-Type' STRING_NAMESPACE = 'String' BOOLEAN_NAMESPACE = 'Boolean' INTEGER_NAMESPACE = 'Integer' LONG_NAMESPACE = 'Long' DOUBLE_NAMESPACE = 'Float' DATE_NAMESPACE = 'Date' DATETIME_NAMESPACE = 'DateTime' DISCOUNT = "DISCOUNT" LINEITEM_PRODUCT = "zcrmsdk.src.com.zoho.crm.api.record.LineItemProduct" FILE_NAMESPACE = "zcrmsdk.src.com.zoho.crm.api.util.StreamWrapper" KEYS_TO_SKIP = ['Created_Time', 'Modified_Time', 'Created_By', 'Modified_By', 'Tag'] PRODUCT_DETAILS = "Product_Details" PRICING_DETAILS = "Pricing_Details" PARTICIPANT_API_NAME = "Participants" INVENTORY_MODULES = ['invoices', 'sales_orders', 'purchase_orders', 'quotes'] PRICE_BOOKS = "price_books" EVENTS = "events" CALLS = "calls" CALL_DURATION = "call_duration" SOLUTIONS = "solutions" CASES = "cases" ACTIVITIES = "activities" LAYOUT = "Layout" SUBFORM = "subform" LOOKUP = "lookup" SE_MODULE = "se_module" MODULEDETAILS = 'moduleDetails' MODULEPACKAGENAME = "modulePackageName" UNDERSCORE = "_" RELATED_LISTS = "Related_Lists" FIELD_DETAILS_DIRECTORY = "resources" NO_CONTENT_STATUS_CODE = 204 NOT_MODIFIED_STATUS_CODE = 304 HREF = "href" API_EXCEPTION = "API_EXCEPTION" FIELDS_LAST_MODIFIED_TIME = "FIELDS-LAST-MODIFIED-TIME" LINE_TAX = "$line_tax" CANT_DISCLOSE = " ## can't disclose ## " URL = "URL" HEADERS = "HEADERS" PARAMS = "PARAMS" INITIALIZATION_SUCCESSFUL = "Initialization successful " INITIALIZATION_SWITCHED = "Initialization switched " IN_ENVIRONMENT = " in Environment : " FOR_EMAIL_ID = "for Email Id : " REFRESH_TOKEN_MESSAGE = "Access Token has expired. Hence refreshing." RESOURCE_PATH_ERROR = "EMPTY_RESOURCE_PATH" RESOURCE_PATH_ERROR_MESSAGE = "Resource Path MUST NOT be None/empty." SET_CONTENT_TYPE_HEADER = ["/crm/bulk/v2.1/read", "/crm/bulk/v2.1/write"] CONTENT_TYPE_HEADER = "Content-Type" LIST_KEY = "List" ATTACHMENT_ID = "attachment_id" FILE_ID = "file_id" PHOTO_UPLOAD_ERROR_MESSAGE = "The given module is not supported in API." INVALID_MODULE = "INVALID_MODULE" MULTI_SELECT_LOOKUP = "multiselectlookup" MULTI_USER_LOOKUP = "multiuserlookup" TERRITORIES = "territories" GENERATED_TYPE = "generated_type" GENERATED_TYPE_CUSTOM = "custom" UPLOAD_PHOTO_UNSUPPORTED_MESSAGE = "Photo Upload Operation is not supported by the module: " SDK_MODULE_METADATA = "SDK-MODULE-METADATA" INVALID_MODULE_API_NAME_ERROR = "INVALID MODULE API NAME ERROR" PROVIDE_VALID_MODULE_API_NAME = "PROVIDE VALID MODULE API NAME: " UPLOAD_PHOTO_UNSUPPORTED_ERROR = "UPLOAD PHOTO UNSUPPORTED MODULE" DELETE_FIELD_FILE_ERROR = "Exception in deleting Current User Fields file : " DELETE_FIELD_FILES_ERROR = "Exception in deleting all Fields files : " DELETE_MODULE_FROM_FIELDFILE_ERROR = "Exception in deleting module from Fields file : " FILE_BODY_WRAPPER = 'FileBodyWrapper' EXCEPTION_IS_KEY_MODIFIED = "Exception in calling is_key_modified : " EXCEPTION_SET_KEY_MODIFIED = "Exception in calling set_key_modified : " SET_API_URL_EXCEPTION = "Exception in setting API URL : " AUTHENTICATION_EXCEPTION = "Exception in authenticating current request : " FORM_REQUEST_EXCEPTION = "Exception in forming request body : " API_CALL_EXCEPTION = "Exception in current API call execution : " HTTP = "http" HTTPS = "https" CONTENT_API_URL = "content.zohoapis.com" EXCEPTION = "Exception" MODULE = "module" REQUEST_CATEGORY_READ = "READ" REQUEST_CATEGORY_CREATE = "CREATE" REQUEST_CATEGORY_UPDATE = "UPDATE" ID = "id" CODE = "code" STATUS = "status" MESSAGE = "message" INVALID_URL_ERROR = "Invalid URL Error" REQUEST_CATEGORY_ACTION = "ACTION" SKIP_MANDATORY = "skip-mandatory" FORMULA = "formula" PICKLIST = "picklist" ACCOUNTS = "accounts" PRIMARY_KEY_ERROR = "Value missing or None for required key(s) : " REFRESH_SINGLE_MODULE_FIELDS_ERROR = "Exception in refreshing fields of module : " REFRESH_ALL_MODULE_FIELDS_ERROR = "Exception in refreshing fields of all modules : " GET_TOKENS_DB_ERROR = "Exception in get_tokens - DBStore" DELETE_TOKENS_DB_ERROR = "Exception in delete_tokens - DBStore" GET_TOKENS_FILE_ERROR = "Exception in get_tokens - FileStore" DELETE_TOKENS_FILE_ERROR = "Exception in delete_tokens - FileStore" SDK_UNINITIALIZATION_ERROR = "SDK UNINITIALIZED ERROR" SDK_UNINITIALIZATION_MESSAGE = "SDK is UnInitialized" INITIALIZATION_EXCEPTION = "Exception in initialization" SWITCH_USER_EXCEPTION = "Exception in switching user" AUTO_REFRESH_FIELDS_ERROR_MESSAGE = "auto_refresh_fields MUST NOT be None." HEADER_NONE_ERROR = "NONE HEADER ERROR" PRODUCT_NAME = "Product_Name" HEADER_INSTANCE_NONE_ERROR = "Header Instance MUST NOT be None" PARAM_INSTANCE_NONE_ERROR = "Param Instance MUST NOT be None" HEADER_NAME_NONE_ERROR = "NONE HEADER NAME ERROR" HEADER_NAME_NULL_ERROR_MESSAGE = "Header Name MUST NOT be null" NONE_VALUE_ERROR_MESSAGE = " MUST NOT be None" PARAMETER_NONE_ERROR = "NONE PARAMETER ERROR" PARAM_NAME_NONE_ERROR = "NONE PARAM NAME ERROR" PARAM_NAME_NONE_ERROR_MESSAGE = "Param Name MUST NOT be None" USER_PROXY_ERROR = "USERPROXY ERROR" HOST_ERROR_MESSAGE = "Host MUST NOT be None" PORT_ERROR_MESSAGE = "Port MUST NOT be None" USER_ERROR_MESSAGE = "User MUST NOT be None/empty" UNSUPPORTED_IN_API = "API UNSUPPORTED OPERATION" UNSUPPORTED_IN_API_MESSAGE = " Operation is not supported by API" NULL_VALUE = "null" NOTES = "notes" ATTACHMENTS = "$attachments" JSON_FILE_EXTENSION = ".json" FILE_ERROR = "file_error" FILE_DOES_NOT_EXISTS = "file does not exists" CONSENT_LOOKUP = "consent_lookup" USER_MAIL_NULL_ERROR = "USER MAIL NONE ERROR" USER_MAIL_NULL_ERROR_MESSAGE = "User Mail MUST NOT be None. Set value to user_mail." JSON_DETAILS_ERROR = "ERROR IN READING JSONDETAILS FILE" INVALID_TOKEN_ERROR = "INVALID TOKEN ERROR" NO_ACCESS_TOKEN_ERROR = "ACCESS TOKEN IS NOT PRESENT IN RESPONSE" CLIENT_ID_NULL_ERROR_MESSAGE = "ClientID MUST NOT be null" CLIENT_SECRET_NULL_ERROR_MESSAGE = "ClientSecret MUST NOT be null" REQUEST_PROXY_ERROR_MESSAGE = "request_proxy must be instance of Request Proxy" USER_SIGNATURE_ERROR_MESSAGE = "user must be instance of userSignature." ENVIRONMENT_ERROR_MESSAGE = "environment must be instance of Environment." SDK_CONFIG_ERROR_MESSAGE = "sdk_config must be instance of sdkConfig." TOKEN_ERROR_MESSAGE = "token must be instance of Token." STORE_ERROR_MESSAGE = "store must be instance of Store." COUNT = "count" OWNER_LOOKUP = "ownerlookup" TOKEN_FILE = "sdk_tokens.txt" LOG_FILE_NAME = "sdk_logs.log" SKIP_MODULES = ["deals"] PYTHON = "python_" OAUTH_MANDATORY_KEYS = ["grant_token", "refresh_token", "id", "access_token"]
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/constants.py
constants.py
try: from abc import ABC, abstractmethod import logging import sys import zlib import base64 import re import os import importlib from zcrmsdk.src.com.zoho.crm.api.util import Utility, Choice except Exception: from abc import ABC, abstractmethod import logging import sys import zlib import base64 import re import os import importlib from .utility import Utility from .choice import Choice class Converter(ABC): """ This abstract class is to construct API request and response. """ logger = logging.getLogger('SDKLogger') def __init__(self, common_api_handler): """ Creates a Converter class instance with the CommonAPIHandler class instance. :param common_api_handler: A CommonAPIHandler class instance. """ self.common_api_handler = common_api_handler @abstractmethod def get_response(self, response, pack): """ This abstract method to process the API response. :param response: A object containing the API response contents or response. :param pack: A str containing the expected method return type. :return: A object representing the POJO class instance. """ pass @abstractmethod def form_request(self, request_instance, pack, instance_number, class_member_detail): """ This abstract method to construct the API request. :param request_instance: A Object containing the POJO class instance. :param pack: A str containing the expected method return type. :param instance_number: An int containing the POJO class instance list number. :param class_member_detail : A dict representing the member details :return: A object representing the API request body object. """ pass @abstractmethod def append_to_request(self, request_base, request_object): """ This abstract method to construct the API request body. :param request_base: A HttpEntityEnclosingRequestBase class instance. :param request_object: A object containing the API request body object. """ pass @abstractmethod def get_wrapped_response(self, response, pack): """ This abstract method to process the API response. :param response: A object containing the HttpResponse class instance. :param pack: A str containing the expected method return type. :return: A object representing the POJO class instance. """ pass def value_checker(self, class_name, member_name, key_details, value, unique_values_map, instance_number): """ This method is to validate if the input values satisfy the constraints for the respective fields. :param class_name: A str containing the class name. :param member_name: A str containing the member name. :param key_details: A JSON object containing the key JSON details. :param value: A object containing the key value. :param unique_values_map: A list containing the construct objects. :param instance_number: An int containing the POJO class instance list number. :return: A bool representing the key value is expected pattern, unique, length, and values. """ try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util.constants import Constants from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..exception import SDKException from .constants import Constants from ..initializer import Initializer details_jo = {} name = key_details[Constants.NAME] data_type = key_details[Constants.TYPE] check = True given_type = None if value is not None: if Constants.INTERFACE in key_details and key_details[Constants.INTERFACE]: interface_details = Initializer.get_initializer().json_details[key_details[Constants.STRUCTURE_NAME]] classes = interface_details[Constants.CLASSES] check = False for each_class in classes: path_split = str(value.__class__.__module__).rpartition(".") class_name = self.module_to_class(path_split[-1]) pack = path_split[0] + "." + class_name if pack == each_class: check = True break else: given_type = value.__class__.__module__ if data_type in Constants.DATA_TYPE: if isinstance(value, list) and Constants.STRUCTURE_NAME in key_details: structure_name = key_details[Constants.STRUCTURE_NAME] index = 0 path_split = str(structure_name).rpartition('.') imported_module = importlib.import_module(path_split[0]) class_holder = getattr(imported_module, path_split[-1]) for each_instance in value: if not isinstance(each_instance, class_holder): check = False instance_number = index data_type = Constants.LIST_KEY + '[' + structure_name + ']' given_type = each_instance.__module__ break index = index + 1 else: check = Utility.check_data_type(value=value, type=data_type) elif value is not None and data_type.lower() != Constants.OBJECT_KEY: path_split = str(data_type).rpartition('.') imported_module = importlib.import_module(path_split[0]) class_holder = getattr(imported_module, path_split[-1]) if not isinstance(value, class_holder): check = False if not check: details_jo[Constants.FIELD] = name details_jo[Constants.CLASS] = class_name details_jo[Constants.ACCEPTED_TYPE] = data_type details_jo[Constants.GIVEN_TYPE] = given_type if instance_number is not None: details_jo[Constants.INDEX] = instance_number raise SDKException(code=Constants.TYPE_ERROR, details=details_jo) if Constants.VALUES in key_details and \ (Constants.PICKLIST not in key_details or (key_details[Constants.PICKLIST] and Initializer.get_initializer().sdk_config.get_pick_list_validation())): values_ja = key_details[Constants.VALUES] if isinstance(value, Choice): value = value.get_value() if value not in values_ja: details_jo[Constants.FIELD] = member_name details_jo[Constants.CLASS] = class_name details_jo[Constants.GIVEN_VALUE] = value details_jo[Constants.ACCEPTED_VALUES] = values_ja if instance_number is not None: details_jo[Constants.INDEX] = instance_number raise SDKException(code=Constants.UNACCEPTED_VALUES_ERROR, details=details_jo) if Constants.UNIQUE in key_details: if name not in unique_values_map: unique_values_map[name] = [] values_array = unique_values_map[name] if value in values_array: details_jo[Constants.FIELD] = member_name details_jo[Constants.CLASS] = class_name details_jo[Constants.FIRST_INDEX] = values_array.index(value) + 1 details_jo[Constants.NEXT_INDEX] = instance_number raise SDKException(code=Constants.UNIQUE_KEY_ERROR, details=details_jo) else: unique_values_map[name].append(value) if Constants.MIN_LENGTH in key_details or Constants.MAX_LENGTH in key_details: count = len(str(value)) if isinstance(value, list): count = len(value) if Constants.MAX_LENGTH in key_details and count > key_details[Constants.MAX_LENGTH]: details_jo[Constants.FIELD] = member_name details_jo[Constants.CLASS] = class_name details_jo[Constants.GIVEN_LENGTH] = count details_jo[Constants.MAXIMUM_LENGTH] = key_details[Constants.MAX_LENGTH] raise SDKException(code=Constants.MAXIMUM_LENGTH_ERROR, details=details_jo) if Constants.MIN_LENGTH in key_details and count < key_details[Constants.MIN_LENGTH]: details_jo[Constants.FIELD] = member_name details_jo[Constants.CLASS] = class_name details_jo[Constants.GIVEN_LENGTH] = count details_jo[Constants.MINIMUM_LENGTH] = key_details[Constants.MIN_LENGTH] raise SDKException(code=Constants.MINIMUM_LENGTH_ERROR, details=details_jo) if Constants.REGEX in key_details: if re.search(value, key_details[Constants.REGEX]) is None: details_jo[Constants.FIELD] = member_name details_jo[Constants.CLASS] = class_name details_jo[Constants.INSTANCE_NUMBER] = instance_number raise SDKException(code=Constants.REGEX_MISMATCH_ERROR, details=details_jo) return True def module_to_class(self, module_name): class_name = module_name if "_" in module_name: class_name = '' module_split = str(module_name).split('_') for each_name in module_split: each_name = each_name.capitalize() class_name += each_name return class_name @classmethod def get_encoded_file_name(cls): """ The method to get the module field JSON details file name. :return: A str representing the module field JSON details file name. """ try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer file_name = Initializer.get_initializer().user.get_email() file_name = file_name.split("@", 1)[0] + Initializer.get_initializer().environment.url input_bytes = file_name.encode("UTF-8") encoded_string = base64.b64encode(input_bytes) encoded_string = str(encoded_string.decode("UTF-8")) return encoded_string + '.json'
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/converter.py
converter.py
try: import importlib import logging import re import json from zcrmsdk.src.com.zoho.crm.api.util import Utility,Converter, Constants, StreamWrapper from zcrmsdk.src.com.zoho.crm.api.exception.sdk_exception import SDKException except Exception: import importlib import logging import re from .converter import Converter from .constants import Constants from .utility import Utility from .stream_wrapper import StreamWrapper from ..exception import SDKException class FormDataConverter(Converter): """ This class to process the upload file and stream. """ logger = logging.getLogger('SDKLogger') def __init__(self, common_api_handler): super().__init__(common_api_handler) self.unique_dict = {} self.common_api_handler = common_api_handler def append_to_request(self, request_base, request_object): form_data_request_body = [] self.add_file_body(request_object, form_data_request_body) request_base.file = True return form_data_request_body def add_file_body(self, request_object, request_body): for key_name, key_value in request_object.items(): if isinstance(key_value, list): for each_object in key_value: if isinstance(each_object, StreamWrapper): request_body.append((key_name, each_object.get_stream())) else: request_body.append((key_name, key_value)) elif isinstance(key_value, StreamWrapper): entry = (key_name, key_value.get_stream()) request_body.append(entry) else: entry = (key_name, key_value) request_body.append(entry) def form_request(self, request_instance, pack, instance_number, class_member_detail): path_split = str(pack).rpartition(".") class_name = self.module_to_class(path_split[-1]) pack = path_split[0] + "." + class_name try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer class_detail = dict(Initializer.json_details[str(pack)]) request = dict() if Constants.INTERFACE in class_detail and class_detail[Constants.INTERFACE] is not None: request_object_class_name = request_instance.__class__.__module__ request_object_class_name = str(request_object_class_name) path_split = str(request_object_class_name).rpartition(".") request_class_name = self.module_to_class(path_split[-1]) request_object_class_name = path_split[0] + "." + request_class_name classes = class_detail[Constants.CLASSES] for class_name in classes: class_name_interface_lower = str(class_name).lower() request_class_path_lower = request_object_class_name.lower() if class_name_interface_lower == request_class_path_lower: class_detail = dict(Initializer.json_details[str(class_name)]) class_name = str(class_name).rpartition(".") class_name = self.module_to_class(class_name[-1]) break for member_name, member_detail in class_detail.items(): modification = None if (Constants.READ_ONLY in member_detail and bool( member_detail[Constants.READ_ONLY])) or Constants.NAME not in member_detail: continue try: modification = getattr(request_instance, Constants.IS_KEY_MODIFIED)(member_name) except Exception as e: raise SDKException(code=Constants.EXCEPTION_IS_KEY_MODIFIED, cause=e) if (modification is None or modification == 0) and Constants.REQUIRED in member_detail and bool( member_detail[Constants.REQUIRED]): raise SDKException(Constants.MANDATORY_VALUE_ERROR, Constants.MANDATORY_KEY_ERROR + member_name) field_value = getattr(request_instance, self.construct_private_member(class_name=class_name, member_name=member_name)) if modification is not None and modification != 0 and field_value is not None and self.value_checker( class_name=class_name, member_name=member_name, key_details=member_detail, value=field_value, unique_values_map=self.unique_dict, instance_number=instance_number) is True: key_name = member_detail.get(Constants.NAME) data_type = member_detail.get(Constants.TYPE) if data_type == Constants.LIST_NAMESPACE: request[key_name] = self.set_json_array(field_value, member_detail) elif data_type == Constants.MAP_NAMESPACE: request[key_name] = self.set_json_object(field_value, member_detail) elif Constants.STRUCTURE_NAME in member_detail: request[key_name] = \ self.form_request(field_value, member_detail.get(Constants.STRUCTURE_NAME), 0, member_detail) else: request[key_name] = field_value return request def set_json_object(self, field_value, member_detail): json_object = {} request_object = dict(field_value) if member_detail is None: for key, value in request_object.items(): json_object[key] = self.redirector_for_object_to_json(value) else: keys_detail = member_detail[Constants.KEYS] for key_detail in keys_detail: key_name = key_detail[Constants.NAME] key_value = None if key_name in request_object and request_object[key_name] is not None: if Constants.STRUCTURE_NAME in key_detail: key_value = self.form_request(field_value[key_name], key_detail[Constants.STRUCTURE_NAME], 0, member_detail) else: key_value = self.redirector_for_object_to_json(field_value[key_name]) json_object[key_name] = key_value return json_object def set_json_array(self, field_value, member_detail): json_array = [] request_objects = list(field_value) if member_detail is None: for request in request_objects: json_array.append(self.redirector_for_object_to_json(request)) else: if Constants.STRUCTURE_NAME in member_detail: instance_count = 0 pack = member_detail[Constants.STRUCTURE_NAME] for request in request_objects: json_array.append(self.form_request(request, pack, instance_count, member_detail)) instance_count += 1 else: for request in field_value: json_array.append(self.redirector_for_object_to_json(request)) return json_array def redirector_for_object_to_json(self, request): if isinstance(request, list): return self.set_json_array(request, None) if isinstance(request, dict): return self.set_json_object(request, None) else: return request def get_wrapped_response(self, response, pack): return None def get_response(self, response, pack): return None @staticmethod def construct_private_member(class_name, member_name): return '_' + class_name + '__' + member_name
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/form_data_converter.py
form_data_converter.py
try: import json import platform import urllib3 import logging from zcrmsdk.src.com.zoho.crm.api.util.api_http_connector import APIHTTPConnector from zcrmsdk.src.com.zoho.crm.api.util.json_converter import JSONConverter from zcrmsdk.src.com.zoho.crm.api.util.xml_converter import XMLConverter from zcrmsdk.src.com.zoho.crm.api.util.form_data_converter import FormDataConverter from zcrmsdk.src.com.zoho.crm.api.util.downloader import Downloader from zcrmsdk.src.com.zoho.crm.api.util.constants import Constants from zcrmsdk.src.com.zoho.crm.api.util.api_response import APIResponse from zcrmsdk.src.com.zoho.crm.api.header_map import HeaderMap from zcrmsdk.src.com.zoho.crm.api.header import Header from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.param import Param from zcrmsdk.src.com.zoho.crm.api.exception import SDKException except Exception: import json import platform import urllib3 import logging from .api_http_connector import APIHTTPConnector from .json_converter import JSONConverter from .constants import Constants from .api_response import APIResponse from ..header_map import HeaderMap from ..header import Header from ..parameter_map import ParameterMap from ..param import Param from ..exception import SDKException class CommonAPIHandler(object): """ This class to process the API request and its response. Construct the objects that are to be sent as parameters or request body with the API. The Request parameter, header and body objects are constructed here. Process the response JSON and converts it to relevant objects in the library. """ logger = logging.getLogger('SDKLogger') def __init__(self): self.__api_path = None self.__header = HeaderMap() self.__param = ParameterMap() self.__request = None self.__http_method = None self.__module_api_name = None self.__content_type = None self.__category_method = None self.__mandatory_checker = None def set_content_type(self, content_type): """ The method to set the Content Type Parameters: content_type(str): A string containing the Content Type """ self.__content_type = content_type def set_api_path(self, api_path): """ The method to set the API Path Parameters: api_path(str) : A string containing the API Path """ self.__api_path = api_path def add_param(self, param_instance, param_value): """ The method to add an API request parameter. Parameters: param_instance (Param) : A Param instance containing the API request parameter. param_value (object) : An object containing the API request parameter value. """ if param_value is None: return if self.__param is None: self.__param = ParameterMap() self.__param.add(param_instance, param_value) def add_header(self, header_instance, header_value): """ The method to add an API request header. Parameters: header_instance (Header) : A Header instance containing the API request header. header_value (object) : An object containing the API request header value. """ if header_value is None: return if self.__header is None: self.__header = HeaderMap() self.__header.add(header_instance, header_value) def set_param(self, param): """ The method to set the API request parameter map. Parameters: param(ParameterMap) : A ParameterMap class instance containing the API request parameters """ if param is None: return if self.__param.request_parameters is not None and self.__param.request_parameters: self.__param.request_parameters.update(param.request_parameters) else: self.__param = param def get_module_api_name(self): """ The method to get the Module API Name Returns: string: A string representing the Module API Name """ return self.__module_api_name def set_module_api_name(self, module_api_name): """ The method to set the Module API Name Parameters: module_api_name(str): A string containing the Module API Name """ self.__module_api_name = module_api_name def set_header(self, header): """ The method to set the API request header map. Parameters: header(HeaderMap): A HeaderMap class instance containing the API request headers """ if header is None: return if self.__header.request_headers is not None and self.__header.request_headers: self.__header.request_headers.update(header.request_headers) else: self.__header = header def set_request(self, request): """ The method to set the request instance. Parameters: request(object): An object containing the request body """ self.__request = request def set_http_method(self, http_method): """ The method to set the HTTP Method Parameters: http_method(str): A string containing the HTTP method. """ self.__http_method = http_method def api_call(self, class_name, encode_type): """ The method to construct API request and response details. To make the Zoho CRM API calls. Parameters: class_name(str): A str containing the method return type. encode_type(str): A str containing the expected API response content type. Returns: APIResponse: An instance of APIResponse representing the Zoho CRM API response instance Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer if Initializer.get_initializer() is None: raise SDKException(code=Constants.SDK_UNINITIALIZATION_ERROR, message=Constants.SDK_UNINITIALIZATION_MESSAGE) connector = APIHTTPConnector() try: self.set_api_url(connector) except SDKException as e: CommonAPIHandler.logger.error(Constants.SET_API_URL_EXCEPTION + e.__str__()) raise e except Exception as e: sdk_exception = SDKException(cause=e) CommonAPIHandler.logger.error(Constants.SET_API_URL_EXCEPTION + sdk_exception.__str__()) raise sdk_exception connector.request_method = self.__http_method connector.content_type = self.__content_type if self.__header is not None and len(self.__header.request_headers) > 0: connector.headers = self.__header.request_headers if self.__param is not None and len(self.__param.request_parameters) > 0: connector.parameters = self.__param.request_parameters try: Initializer.get_initializer().token.authenticate(connector) except SDKException as e: CommonAPIHandler.logger.info(Constants.AUTHENTICATION_EXCEPTION + e.__str__()) raise e except Exception as e: sdk_exception = SDKException(cause=e) CommonAPIHandler.logger.error(Constants.AUTHENTICATION_EXCEPTION + sdk_exception.__str__()) raise sdk_exception convert_instance = None if self.__content_type is not None and \ self.__http_method in [Constants.REQUEST_METHOD_PATCH, Constants.REQUEST_METHOD_POST, Constants.REQUEST_METHOD_PUT]: try: convert_instance = self.get_converter_class_instance(self.__content_type.lower()) request = convert_instance.form_request(self.__request, self.__request.__class__.__module__, None, None) except SDKException as e: CommonAPIHandler.logger.info(Constants.FORM_REQUEST_EXCEPTION + e.__str__()) raise e except Exception as e: sdk_exception = SDKException(cause=e) CommonAPIHandler.logger.error(Constants.FORM_REQUEST_EXCEPTION + sdk_exception.__str__()) raise sdk_exception connector.request_body = request try: connector.headers[ Constants.ZOHO_SDK] = platform.system() + "/" + \ platform.release() + "/python-2.1/" + platform.python_version() + ":" + \ Constants.SDK_VERSION response = connector.fire_request(convert_instance) return_object = None if Constants.CONTENT_TYPE in response.headers: content_type = response.headers[Constants.CONTENT_TYPE] if ";" in content_type: content_type = content_type.rpartition(";")[0] convert_instance = self.get_converter_class_instance(str(content_type).lower()) return_object = convert_instance.get_wrapped_response(response, class_name) else: CommonAPIHandler.logger.info(response.__str__()) return APIResponse(response.headers, response.status_code, return_object) except SDKException as e: CommonAPIHandler.logger.info(Constants.API_CALL_EXCEPTION + e.__str__()) except Exception as e: sdk_exception = SDKException(cause=e) CommonAPIHandler.logger.error(Constants.API_CALL_EXCEPTION + sdk_exception.__str__()) raise sdk_exception def get_converter_class_instance(self, encode_type): """ This method to get a Converter class instance. :param encode_type: A str containing the API response content type. :return: A Converter class instance. """ switcher = { "application/json": JSONConverter(self), "text/plain": JSONConverter(self), "application/ld+json": JSONConverter(self), "application/xml": XMLConverter(self), "text/xml": XMLConverter(self), "multipart/form-data": FormDataConverter(self), "application/x-download": Downloader(self), "image/png": Downloader(self), "image/jpeg": Downloader(self), "image/gif": Downloader(self), "image/tiff": Downloader(self), "image/svg+xml": Downloader(self), "image/bmp": Downloader(self), "image/webp": Downloader(self), "text/html": Downloader(self), "text/css": Downloader(self), "text/javascript": Downloader(self), "text/calendar": Downloader(self), "application/zip": Downloader(self), "application/pdf": Downloader(self), "application/java-archive": Downloader(self), "application/javascript": Downloader(self), "application/xhtml+xml": Downloader(self), "application/x-bzip": Downloader(self), "application/msword": Downloader(self), "application/vnd.openxmlformats-officedocument.wordprocessingml.document": Downloader(self), "application/gzip": Downloader(self), "application/x-httpd-php": Downloader(self), "application/vnd.ms-powerpoint": Downloader(self), "application/vnd.rar": Downloader(self), "application/x-sh": Downloader(self), "application/x-tar": Downloader(self), "application/vnd.ms-excel": Downloader(self), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": Downloader(self), "application/x-7z-compressed": Downloader(self), "audio/mpeg": Downloader(self), "audio/x-ms-wma": Downloader(self), "audio/vnd.rn-realaudio": Downloader(self), "audio/x-wav": Downloader(self), "audio/3gpp": Downloader(self), "audio/3gpp2": Downloader(self), "video/mpeg": Downloader(self), "video/mp4": Downloader(self), "video/webm": Downloader(self), "video/3gpp": Downloader(self), "video/3gpp2": Downloader(self), "font/ttf": Downloader(self), "text/csv": Downloader(self), "application/octet-stream": Downloader(self), } return switcher.get(encode_type, None) def set_api_url(self, connector): try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer api_path = '' if Constants.HTTP in self.__api_path: if Constants.CONTENT_API_URL in self.__api_path: api_path = Initializer.get_initializer().environment.file_upload_url try: url_parse = urllib3.util.parse_url(self.__api_path) path = url_parse.path except Exception as ex: raise SDKException(code=Constants.INVALID_URL_ERROR, cause=ex) api_path = api_path + path else: if str(self.__api_path)[:1].__eq__('/'): self.__api_path = self.__api_path[1:] api_path = api_path + self.__api_path else: api_path = Initializer.get_initializer().environment.url api_path = api_path + self.__api_path connector.url = api_path def get_mandatory_checker(self): """ The method to get the Mandatory Checker Returns: bool: A boolean representing the Mandatory Checker. """ return self.__mandatory_checker def set_mandatory_checker(self, mandatory_checker): """ The method to set the Mandatory Checker Parameters: mandatory_checker(bool): A boolean containing the Mandatory Checker. """ self.__mandatory_checker = mandatory_checker def get_http_method(self): """ The method to get the HTTP Method Returns: string: A string representing the HTTP Method """ return self.__http_method def get_category_method(self): """ The method to get the Category Method Returns: string: A string representing the Category method. """ return self.__category_method def set_category_method(self, category_method): """ The method to set the Category Method Parameters: category_method(str): A string containing the Category method. """ self.__category_method = category_method def get_api_path(self): """ The method to get the API Path Returns: string: A string representing the API Path """ return self.__api_path
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/common_api_handler.py
common_api_handler.py
try: import logging import threading import datetime import time import os import json import zlib import base64 import re from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.header_map import HeaderMap except Exception: import logging import threading import os import json import time import datetime import zlib import base64 import re from .constants import Constants from ..initializer import Initializer from ..exception import SDKException from ..header_map import HeaderMap class Utility(object): """ This class handles module field details. """ apitype_vs_datatype = {} apitype_vs_structurename = {} new_file = False get_modified_modules = False force_refresh = False module_api_name = None api_supported_modules = {} lock = threading.RLock() logger = logging.getLogger('SDKLogger') @staticmethod def file_exists_flow(module_api_name, record_field_details_path, last_modified_time): with Utility.lock: record_field_details_json = Initializer.get_json(record_field_details_path) initializer = Initializer.get_initializer() if initializer.sdk_config.get_auto_refresh_fields() and not Utility.new_file and not Utility.get_modified_modules and (Constants.FIELDS_LAST_MODIFIED_TIME not in record_field_details_json or Utility.force_refresh or (time.time() * 1000 - record_field_details_json[Constants.FIELDS_LAST_MODIFIED_TIME]) > 3600000): Utility.get_modified_modules = True last_modified_time = record_field_details_json[Constants.FIELDS_LAST_MODIFIED_TIME] if not Utility.force_refresh and Constants.FIELDS_LAST_MODIFIED_TIME in record_field_details_json else None Utility.modify_fields(record_field_details_path, last_modified_time) Utility.get_modified_modules = False elif not Initializer.get_initializer().sdk_config.get_auto_refresh_fields() and Utility.force_refresh and not Utility.get_modified_modules: Utility.get_modified_modules = True Utility.modify_fields(record_field_details_path, last_modified_time) Utility.get_modified_modules = False record_field_details_json = Initializer.get_json(record_field_details_path) if module_api_name is None or (module_api_name.lower() in record_field_details_json and record_field_details_json[module_api_name.lower()] is not None): return else: Utility.fill_data_type() record_field_details_json[module_api_name.lower()] = {} Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) field_details = Utility.get_fields_details(module_api_name) record_field_details_json = Initializer.get_json(record_field_details_path) record_field_details_json[module_api_name.lower()] = field_details Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) @staticmethod def verify_module_api_name(module_api_name): if module_api_name is not None and module_api_name.lower() in Constants.DEFAULT_MODULE_NAME_VS_API_NAME and Constants.DEFAULT_MODULE_NAME_VS_API_NAME.get(module_api_name.lower()) is not None: return Constants.DEFAULT_MODULE_NAME_VS_API_NAME.get(module_api_name.lower()) record_field_details_path = Utility.get_file_name() if os.path.exists(record_field_details_path): fields_json = Initializer.get_json(record_field_details_path) if Constants.SDK_MODULE_METADATA in fields_json and module_api_name.lower() in fields_json[Constants.SDK_MODULE_METADATA]: return fields_json[Constants.SDK_MODULE_METADATA][module_api_name.lower()][Constants.API_NAME] return module_api_name @staticmethod def set_handler_api_path(module_api_name, handler_instance): if handler_instance is None: return api_path = handler_instance.get_api_path() if module_api_name.lower() in api_path.lower(): api_path_split = api_path.split("/") for i in range(len(api_path_split)): split_lower = api_path_split[i].lower() if split_lower == module_api_name.lower(): api_path_split[i] = module_api_name elif split_lower in Constants.DEFAULT_MODULE_NAME_VS_API_NAME and \ Constants.DEFAULT_MODULE_NAME_VS_API_NAME.get(split_lower) is not None: api_path_split[i] = Constants.DEFAULT_MODULE_NAME_VS_API_NAME.get(split_lower) api_path = "/".join(api_path_split) handler_instance.set_api_path(api_path) @staticmethod def get_fields(module_api_name, handler_instance=None): with Utility.lock: Utility.module_api_name = module_api_name Utility.get_fields_info(module_api_name, handler_instance) @staticmethod def get_fields_info(module_api_name, handler_instance=None): """ This method to fetch field details of the current module for the current user and store the result in a JSON file. Parameters: module_api_name (str) : A string containing the CRM module API name. handler_instance (CommonAPIHandler) : A CommonAPIHandler instance. """ try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer last_modified_time = None record_field_details_path = None try: with Utility.lock: if module_api_name is not None and Utility.search_json_details(module_api_name) is not None: return initializer = Initializer.get_initializer() resources_path = os.path.join(initializer.resource_path, Constants.FIELD_DETAILS_DIRECTORY) if not os.path.exists(resources_path): os.makedirs(resources_path) if module_api_name is not None: module_api_name = Utility.verify_module_api_name(module_api_name) Utility.set_handler_api_path(module_api_name, handler_instance) if handler_instance is not None and handler_instance.get_module_api_name() is None and module_api_name.lower() not in Constants.SKIP_MODULES: return record_field_details_path = Utility.get_file_name() if os.path.exists(record_field_details_path): Utility.file_exists_flow(module_api_name, record_field_details_path, last_modified_time) elif initializer.sdk_config.get_auto_refresh_fields(): Utility.new_file = True Utility.fill_data_type() if len(Utility.api_supported_modules) == 0: Utility.api_supported_modules = Utility.get_modules(None) record_field_details_json = Initializer.get_json(record_field_details_path) if os.path.exists(record_field_details_path) else {} record_field_details_json[Constants.FIELDS_LAST_MODIFIED_TIME] = time.time() * 1000 if len(Utility.api_supported_modules) > 0: for module in Utility.api_supported_modules: if module.lower() not in record_field_details_json: module_data = Utility.api_supported_modules[module] record_field_details_json[module.lower()] = {} Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) field_details = Utility.get_fields_details(module_data[Constants.API_NAME]) record_field_details_json = Initializer.get_json(record_field_details_path) record_field_details_json[module.lower()] = field_details Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) Utility.new_file = False elif Utility.force_refresh and not Utility.get_modified_modules: Utility.get_modified_modules = True record_field_details_json = {} Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) Utility.modify_fields(record_field_details_path, last_modified_time) Utility.get_modified_modules = False else: Utility.fill_data_type() record_field_details_json = {module_api_name.lower(): {}} Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) field_details = Utility.get_fields_details(module_api_name) record_field_details_json = Initializer.get_json(record_field_details_path) record_field_details_json[module_api_name.lower()] = field_details Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) except Exception as e: if record_field_details_path is not None and os.path.exists(record_field_details_path): try: record_field_details_json = Initializer.get_json(record_field_details_path) if module_api_name is not None and module_api_name.lower() in record_field_details_json: del record_field_details_json[module_api_name.lower()] if Utility.new_file: if Constants.FIELDS_LAST_MODIFIED_TIME in record_field_details_json: del record_field_details_json[Constants.FIELDS_LAST_MODIFIED_TIME] Utility.new_file = False if Utility.get_modified_modules or Utility.force_refresh: Utility.get_modified_modules = False Utility.force_refresh = False if last_modified_time is not None: record_field_details_json[Constants.FIELDS_LAST_MODIFIED_TIME] = last_modified_time Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) except Exception as ex: sdk_exception = SDKException(cause=ex) Utility.logger.error(Constants.EXCEPTION + sdk_exception.__str__()) raise sdk_exception if not isinstance(e, SDKException): e = SDKException(cause=e) Utility.logger.info(Constants.EXCEPTION + e.__str__()) raise e @staticmethod def modify_fields(record_field_details_path, modified_time): modified_modules = Utility.get_modules(modified_time) record_field_details_json = Initializer.get_json(record_field_details_path) record_field_details_json[Constants.FIELDS_LAST_MODIFIED_TIME] = time.time() * 1000 Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) if len(modified_modules) > 0: for module in modified_modules.keys(): if module.lower() in record_field_details_json: Utility.delete_fields(record_field_details_json, module) Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) for module in modified_modules.keys(): module_data = modified_modules[module] Utility.get_fields_info(module_data[Constants.API_NAME]) @staticmethod def delete_fields(record_field_details_json, module): subform_modules = [] fields_json = record_field_details_json[module.lower()] for key, value in fields_json.items(): if Constants.SUBFORM in value and value[Constants.SUBFORM] and (value[Constants.MODULE]).lower() in record_field_details_json: subform_modules.append(value[Constants.MODULE]) del record_field_details_json[module.lower()] if len(subform_modules) > 0: for subform_module in subform_modules: Utility.delete_fields(record_field_details_json, subform_module) @staticmethod def get_file_name(): import zcrmsdk.src.com.zoho.crm.api.util.converter as Converter return os.path.join(Initializer.get_initializer().resource_path, Constants.FIELD_DETAILS_DIRECTORY, Converter.Converter.get_encoded_file_name()) @staticmethod def get_related_lists(related_module_name, module_api_name, common_api_handler): with Utility.lock: try: is_new_data = False key = (module_api_name + Constants.UNDERSCORE + Constants.RELATED_LISTS).lower() resources_path = os.path.join(Initializer.get_initializer().resource_path,Constants.FIELD_DETAILS_DIRECTORY) if not os.path.exists(resources_path): os.makedirs(resources_path) record_field_details_path = Utility.get_file_name() if not os.path.exists(record_field_details_path) or ( os.path.exists(record_field_details_path) and (key not in Initializer.get_json(record_field_details_path) or (Initializer.get_json(record_field_details_path)[key] == None or len(Initializer.get_json(record_field_details_path)[key]) <= 0))): is_new_data = True module_api_name = Utility.verify_module_api_name(module_api_name) related_list_values = Utility.get_related_list_details(module_api_name) record_field_details_json = Initializer.get_json(record_field_details_path) if os.path.exists(record_field_details_path) else {} record_field_details_json[key] = related_list_values Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) record_field_details_json = Initializer.get_json(record_field_details_path) module_related_list = record_field_details_json[key] if key in record_field_details_json else {} if not Utility.check_related_list_exists(related_module_name, module_related_list,common_api_handler) and not is_new_data: del record_field_details_json[key] Utility.write_to_file(file_path=record_field_details_path, file_contents=record_field_details_json) Utility.get_related_lists(related_module_name, module_api_name, common_api_handler) except SDKException as e: Utility.logger.error(Constants.EXCEPTION + e.__str__()) raise e except Exception as e: sdk_exception = SDKException(cause=e) Utility.logger.error(Constants.EXCEPTION + sdk_exception.__str__()) raise sdk_exception @staticmethod def check_related_list_exists(related_module_name, module_related_list_array, common_api_handler): for related_list_jo in module_related_list_array: if related_list_jo[Constants.API_NAME] is not None and related_list_jo[Constants.API_NAME].lower() == related_module_name.lower(): if related_list_jo[Constants.HREF] == Constants.NULL_VALUE: raise SDKException(code=Constants.UNSUPPORTED_IN_API, message=common_api_handler.get_http_method() + ' ' + common_api_handler.get_api_path() + Constants.UNSUPPORTED_IN_API_MESSAGE) if related_list_jo[Constants.MODULE] != Constants.NULL_VALUE: common_api_handler.set_module_api_name(related_list_jo[Constants.MODULE]) Utility.get_fields_info(related_list_jo[Constants.MODULE], common_api_handler) return True return False @staticmethod def get_related_list_details(module_api_name): import zcrmsdk.src.com.zoho.crm.api.related_lists as RelatedLists related_list_array = [] response = RelatedLists.RelatedListsOperations(module_api_name).get_related_lists() if response is not None: if response.get_status_code() == Constants.NO_CONTENT_STATUS_CODE: return related_list_array data_object = response.get_object() if data_object is not None: if isinstance(data_object, RelatedLists.ResponseWrapper): related_lists = data_object.get_related_lists() for related_list in related_lists: related_list_detail = { Constants.API_NAME: related_list.get_api_name(), Constants.MODULE: related_list.get_module() if related_list.get_module() is not None else Constants.NULL_VALUE, Constants.NAME: related_list.get_name(), Constants.HREF: related_list.get_href() if related_list.get_href() is not None else Constants.NULL_VALUE } related_list_array.append(related_list_detail) elif isinstance(data_object, RelatedLists.APIException): error_response = { Constants.CODE: data_object.get_code().get_value(), Constants.STATUS: data_object.get_status().get_value(), Constants.MESSAGE: data_object.get_message().get_value() } raise SDKException(code=Constants.API_EXCEPTION, details=error_response) else: error_response = { Constants.CODE: response.get_status_code() } raise SDKException(code=Constants.API_EXCEPTION, details=error_response) else: error_response = { Constants.CODE: response.get_status_code() } raise SDKException(code=Constants.API_EXCEPTION, details=error_response) return related_list_array @staticmethod def get_fields_details(module_api_name): """ This method to get module field data from Zoho CRM. :param module_api_name: A str containing the CRM module API name. :return: A object representing the Zoho CRM module field details. """ import zcrmsdk.src.com.zoho.crm.api.fields as Field fields_details = {} response = Field.FieldsOperations(module_api_name).get_fields() if response is not None: if response.get_status_code() == Constants.NO_CONTENT_STATUS_CODE: return fields_details response_object = response.get_object() if isinstance(response_object, Field.ResponseWrapper): fields = response_object.get_fields() for field in fields: if field.get_api_name() in Constants.KEYS_TO_SKIP: continue field_detail = {} Utility.set_data_type(field_detail, field, module_api_name) fields_details[field.get_api_name()] = field_detail if module_api_name.lower() in Constants.INVENTORY_MODULES: field_detail = { Constants.NAME: Constants.LINE_TAX, Constants.TYPE: Constants.LIST_NAMESPACE, Constants.STRUCTURE_NAME: Constants.LINE_TAX_NAMESPACE } fields_details[Constants.LINE_TAX] = field_detail if module_api_name.lower() == Constants.NOTES: field_detail = { Constants.NAME: Constants.ATTACHMENTS, Constants.TYPE: Constants.LIST_NAMESPACE, Constants.STRUCTURE_NAME: Constants.ATTACHMENTS_NAMESPACE } fields_details[Constants.ATTACHMENTS] = field_detail elif isinstance(response_object, Field.APIException): error_response = { Constants.CODE: response_object.get_code().get_value(), Constants.STATUS: response_object.get_status().get_value(), Constants.MESSAGE: response_object.get_message().get_value() } exception = SDKException(code=Constants.API_EXCEPTION, details=error_response) if Utility.module_api_name.lower() == module_api_name.lower(): raise Utility.logger.error(Constants.API_EXCEPTION, exception.__str__()) else: error_response = { Constants.CODE: response.get_status_code() } raise SDKException(code=Constants.API_EXCEPTION, details=error_response) return fields_details @staticmethod def search_json_details(key): package_name = Constants.PACKAGE_NAMESPACE + 'record.' + key from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer for class_key in Initializer.json_details.keys(): if class_key == package_name: return_json = { Constants.MODULEPACKAGENAME: class_key, Constants.MODULEDETAILS: Initializer.json_details[class_key] } return return_json return None @staticmethod def verify_photo_support(module_api_name): with Utility.lock: try: module_api_name = Utility.verify_module_api_name(module_api_name) if module_api_name.lower() in Constants.PHOTO_SUPPORTED_MODULES: return True modules = Utility.get_module_names() if module_api_name.lower() in modules and modules[module_api_name.lower()] is not None: module_meta_data = modules[module_api_name.lower()] if Constants.GENERATED_TYPE in module_meta_data and module_meta_data[Constants.GENERATED_TYPE] != Constants.GENERATED_TYPE_CUSTOM: raise SDKException(code=Constants.UPLOAD_PHOTO_UNSUPPORTED_ERROR, message=Constants.UPLOAD_PHOTO_UNSUPPORTED_MESSAGE + module_api_name) except SDKException as e: raise e except Exception as e: sdk_exception = SDKException(message=Constants.EXCEPTION, cause=e) raise sdk_exception return True @staticmethod def get_module_names(): module_data = {} resources_path = os.path.join(Initializer.get_initializer().resource_path, Constants.FIELD_DETAILS_DIRECTORY) if not os.path.exists(resources_path): os.makedirs(resources_path) record_field_details_path = Utility.get_file_name() is_null = False if os.path.exists(record_field_details_path): json = Initializer.get_json(record_field_details_path) if Constants.SDK_MODULE_METADATA not in json: is_null = True elif json[Constants.SDK_MODULE_METADATA] is None or len(json[Constants.SDK_MODULE_METADATA])==0: is_null = True if not os.path.exists(record_field_details_path) or is_null: module_data = Utility.get_modules(None) Utility.write_module_meta_data(record_field_details_path, module_data) return module_data record_field_details_json = Initializer.get_json(record_field_details_path) module_data = record_field_details_json[Constants.SDK_MODULE_METADATA] return module_data @staticmethod def write_module_meta_data(record_field_details_path, module_data): field_details_json = Initializer.get_json(record_field_details_path) if os.path.exists( record_field_details_path) else {} field_details_json[Constants.SDK_MODULE_METADATA] = module_data Utility.write_to_file(record_field_details_path, field_details_json) @staticmethod def get_modules(header): import zcrmsdk.src.com.zoho.crm.api.modules as Modules api_names = {} header_map = HeaderMap() if header is not None: header_value = datetime.datetime.fromtimestamp(header / 1000.0) header_map.add(Modules.GetModulesHeader.if_modified_since, header_value) response = Modules.ModulesOperations().get_modules(header_map) if response is not None: if response.get_status_code() in [Constants.NO_CONTENT_STATUS_CODE, Constants.NOT_MODIFIED_STATUS_CODE]: return api_names response_object = response.get_object() if isinstance(response_object, Modules.ResponseWrapper): modules = response_object.get_modules() for module in modules: if module.get_api_supported(): module_details = dict() module_details[Constants.API_NAME] = module.get_api_name() module_details[Constants.GENERATED_TYPE] = module.get_generated_type().get_value() api_names[module.get_api_name().lower()] = module_details elif isinstance(response_object, Modules.APIException): error_response = { Constants.CODE: response_object.get_code().get_value(), Constants.STATUS: response_object.get_status().get_value(), Constants.MESSAGE: response_object.get_message().get_value() } raise SDKException(code=Constants.API_EXCEPTION, details=error_response) if header is None: try: Utility.write_module_meta_data(Utility.get_file_name(), api_names) except Exception as e: raise SDKException(message=Constants.EXCEPTION, cause=e) return api_names @staticmethod def refresh_modules(): Utility.force_refresh = True Utility.get_fields_info(None) Utility.force_refresh = False @staticmethod def get_json_object(json, key): for key_in_json in json.keys(): if key_in_json.lower() == key.lower(): return json[key_in_json] return None @staticmethod def set_data_type(field_detail, field, module_api_name): api_type = field.get_data_type() module = '' key_name = field.get_api_name() if field.get_system_mandatory() is not None and field.get_system_mandatory() and not ( module_api_name.lower() == Constants.CALLS and key_name.lower() == Constants.CALL_DURATION): field_detail[Constants.REQUIRED] = True if key_name.lower() == Constants.PRICING_DETAILS.lower() and module_api_name.lower() == Constants.PRICE_BOOKS: field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.LIST_NAMESPACE field_detail[Constants.STRUCTURE_NAME] = Constants.PRICING_DETAILS_NAMESPACE field_detail[Constants.SKIP_MANDATORY] = True return elif key_name.lower() == Constants.PARTICIPANT_API_NAME.lower() and ( module_api_name.lower() == Constants.EVENTS or module_api_name.lower() == Constants.ACTIVITIES): field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.LIST_NAMESPACE field_detail[Constants.STRUCTURE_NAME] = Constants.PARTICIPANTS field_detail[Constants.SKIP_MANDATORY] = True return elif key_name.lower() == Constants.COMMENTS.lower() and \ (module_api_name.lower() == Constants.SOLUTIONS or module_api_name.lower() == Constants.CASES): field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.LIST_NAMESPACE field_detail[Constants.STRUCTURE_NAME] = Constants.COMMENT_NAMESPACE field_detail[Constants.LOOKUP] = True return elif key_name.lower() == Constants.LAYOUT.lower(): field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.LAYOUT_NAMESPACE field_detail[Constants.STRUCTURE_NAME] = Constants.LAYOUT_NAMESPACE field_detail[Constants.LOOKUP] = True return elif (key_name.lower() == Constants.TERRITORIES.lower() or key_name.lower() == Constants.TERRITORY.lower()) and field.get_custom_field() is not None and field.get_custom_field() == False : field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.LIST_NAMESPACE field_detail[Constants.STRUCTURE_NAME] = Constants.TERRITORY_NAMESPACE field_detail[Constants.LOOKUP] = True return elif key_name.lower() == Constants.PRODUCT_NAME.lower() and module_api_name.lower() in Constants.INVENTORY_MODULES_ITEMS: field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.LINEITEM_PRODUCT field_detail[Constants.STRUCTURE_NAME] = Constants.LINEITEM_PRODUCT field_detail[Constants.SKIP_MANDATORY] = True return elif key_name.lower() == Constants.DISCOUNT.lower() and module_api_name.lower() in Constants.INVENTORY_MODULES_ITEMS: field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.STRING_NAMESPACE return elif key_name.lower() == Constants.TAX.lower() and module_api_name.lower() == Constants.PRODUCTS.lower() : field_detail[Constants.NAME] = key_name field_detail[Constants.TYPE] = Constants.LIST_NAMESPACE field_detail[Constants.STRUCTURE_NAME] = Constants.TAX_NAMESPACE return elif api_type in Utility.apitype_vs_datatype: field_detail[Constants.TYPE] = Utility.apitype_vs_datatype.get(api_type) elif api_type.lower() == Constants.FORMULA.lower(): if field.get_formula() is not None: return_type = field.get_formula().get_return_type() if return_type is not None and return_type in Utility.apitype_vs_datatype and Utility.apitype_vs_datatype.get(return_type) is not None: field_detail[Constants.TYPE] = Utility.apitype_vs_datatype.get(return_type) field_detail[Constants.READ_ONLY] = True else: return if Constants.LOOKUP in api_type.lower(): field_detail[Constants.LOOKUP] = True if Constants.CONSENT_LOOKUP in api_type.lower() or Constants.OWNER_LOOKUP in api_type.lower(): field_detail[Constants.SKIP_MANDATORY] = True if Constants.MULTI_SELECT_LOOKUP in api_type.lower(): field_detail[Constants.SKIP_MANDATORY] = True if field.get_multiselectlookup() is not None and field.get_multiselectlookup().get_linking_module() is not None: linking_module = field.get_multiselectlookup().get_linking_module() field_detail[Constants.MODULE] = linking_module module = linking_module field_detail[Constants.SUBFORM] = True if Constants.MULTI_USER_LOOKUP in api_type.lower(): field_detail[Constants.SKIP_MANDATORY] = True if field.get_multiuserlookup() is not None and field.get_multiuserlookup().get_linking_module() is not None: linking_module = field.get_multiuserlookup().get_linking_module() field_detail[Constants.MODULE] = linking_module module = linking_module field_detail[Constants.SUBFORM] = True if api_type in Utility.apitype_vs_structurename: field_detail[Constants.STRUCTURE_NAME] = Utility.apitype_vs_structurename.get(api_type) if api_type.lower() == Constants.PICKLIST and field.get_pick_list_values() is not None and len( field.get_pick_list_values()) > 0: field_detail[Constants.PICKLIST] = True values = list(map(lambda x: x.get_display_value(), field.get_pick_list_values())) field_detail[Constants.VALUES] = values if api_type == Constants.SUBFORM and field.get_subform() is not None: module = field.get_subform().get_module() field_detail[Constants.MODULE] = module field_detail[Constants.SKIP_MANDATORY] = True field_detail[Constants.SUBFORM] = True if api_type == Constants.LOOKUP and field.get_lookup() is not None: module = field.get_lookup().get_module() if module is not None and not module == Constants.SE_MODULE: field_detail[Constants.MODULE] = module if module.lower() == Constants.ACCOUNTS and not (field.get_custom_field() and not field.get_custom_field()): field_detail[Constants.SKIP_MANDATORY] = True else: module = '' field_detail[Constants.LOOKUP] = True if len(module) > 0: Utility.get_fields_info(module) field_detail[Constants.NAME] = key_name @staticmethod def fill_data_type(): if len(Utility.apitype_vs_datatype) > 0: return field_api_names_string = ["textarea", "text", "website", "email", "phone", "mediumtext", "profileimage", "autonumber"] field_api_names_integer = ['integer'] field_api_names_boolean = ['boolean'] field_api_names_long = ['long', 'bigint'] field_api_names_double = ['double', 'percent', 'lookup', 'currency'] field_api_names_field_file = ['fileupload'] field_api_names_datetime = ['datetime', 'event_reminder'] field_api_names_date = ['date'] field_api_names_lookup = ['lookup'] field_api_names_picklist = ['picklist'] field_api_names_multiselect_picklist = ['multiselectpicklist'] field_api_names_subform = ['subform'] field_api_names_owner_lookup = ['ownerlookup', 'userlookup'] field_api_names_multiuser_lookup = ['multiuserlookup'] field_api_names_multimodule_lookup = ['multimodulelookup'] field_api_name_task_remind_at = ['ALARM'] field_api_name_recurring_activity = ['RRULE'] field_api_name_reminder = ['multireminder'] field_api_name_consent_lookup = ['consent_lookup'] field_api_name_image_upload = ["imageupload"] field_api_name_multiselect_lookup = ["multiselectlookup"] field_api_name_line_tax = ["linetax"] for field_api_name in field_api_names_string: Utility.apitype_vs_datatype[field_api_name] = Constants.STRING_NAMESPACE for field_api_name in field_api_names_integer: Utility.apitype_vs_datatype[field_api_name] = Constants.INTEGER_NAMESPACE for field_api_name in field_api_names_boolean: Utility.apitype_vs_datatype[field_api_name] = Constants.BOOLEAN_NAMESPACE for field_api_name in field_api_names_double: Utility.apitype_vs_datatype[field_api_name] = Constants.DOUBLE_NAMESPACE for field_api_name in field_api_names_long: Utility.apitype_vs_datatype[field_api_name] = Constants.INTEGER_NAMESPACE for field_api_name in field_api_names_datetime: Utility.apitype_vs_datatype[field_api_name] = Constants.DATETIME_NAMESPACE for field_api_name in field_api_names_date: Utility.apitype_vs_datatype[field_api_name] = Constants.DATE_NAMESPACE for field_api_name in field_api_names_lookup: Utility.apitype_vs_datatype[field_api_name] = Constants.RECORD_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.RECORD_NAMESPACE for field_api_name in field_api_names_owner_lookup: Utility.apitype_vs_datatype[field_api_name] = Constants.USER_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.USER_NAMESPACE for field_api_name in field_api_names_multiuser_lookup: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.RECORD_NAMESPACE for field_api_name in field_api_names_multimodule_lookup: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.MODULE_NAMESPACE for field_api_name in field_api_names_picklist: Utility.apitype_vs_datatype[field_api_name] = Constants.CHOICE_NAMESPACE for field_api_name in field_api_names_multiselect_picklist: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.CHOICE_NAMESPACE for field_api_name in field_api_names_subform: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.RECORD_NAMESPACE for field_api_name in field_api_names_field_file: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.FIELD_FILE_NAMESPACE for field_api_name in field_api_name_task_remind_at: Utility.apitype_vs_datatype[field_api_name] = Constants.REMIND_AT_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.REMIND_AT_NAMESPACE for field_api_name in field_api_name_recurring_activity: Utility.apitype_vs_datatype[field_api_name] = Constants.RECURRING_ACTIVITY_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.RECURRING_ACTIVITY_NAMESPACE for field_api_name in field_api_name_reminder: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.REMINDER_NAMESPACE for field_api_name in field_api_name_consent_lookup: Utility.apitype_vs_datatype[field_api_name] = Constants.CONSENT_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.CONSENT_NAMESPACE for field_api_name in field_api_name_image_upload: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.IMAGE_UPLOAD_NAMESPACE for field_api_name in field_api_name_multiselect_lookup: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.RECORD_NAMESPACE for field_api_name in field_api_name_line_tax: Utility.apitype_vs_datatype[field_api_name] = Constants.LIST_NAMESPACE Utility.apitype_vs_structurename[field_api_name] = Constants.LINE_TAX_NAMESPACE @staticmethod def check_data_type(value, type): if value is None: return False if type.lower() == Constants.OBJECT.lower(): return True type = Constants.DATA_TYPE.get(type) class_name = value.__class__ if class_name == type: return True else: return False @staticmethod def write_to_file(file_path, file_contents): with open(file_path, mode="w") as file: json.dump(file_contents, file) file.flush() file.close()
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/utility.py
utility.py
try: import threading import os import json import logging import shutil from zcrmsdk.src.com.zoho.crm.api.util import Constants, Converter, Utility from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer from zcrmsdk.src.com.zoho.crm.api.exception import SDKException except Exception: import threading import os import json import logging import shutil from .constants import Constants from .converter import Converter from .utility import Utility from ..initializer import Initializer from ..exception import SDKException class ModuleFieldsHandler(object): logger = logging.getLogger('SDKLogger') lock = threading.Lock() @staticmethod def __get_directory(): """ The method to obtain resources directory path. Returns: str: A String representing the directory's absolute path. """ return os.path.join(Initializer.get_initializer().resource_path, Constants.FIELD_DETAILS_DIRECTORY) @staticmethod def delete_fields_file(): """ The method to delete fields JSON File of the current user. Raises: SDKException """ with ModuleFieldsHandler.lock: try: record_field_details_path = os.path.join(ModuleFieldsHandler.__get_directory(), Converter.get_encoded_file_name()) if os.path.exists(record_field_details_path): os.remove(record_field_details_path) except Exception as e: sdk_exception = SDKException(cause=e) ModuleFieldsHandler.logger.info(Constants.DELETE_FIELD_FILE_ERROR + sdk_exception.__str__()) raise sdk_exception @staticmethod def delete_all_field_files(): """ The method to delete all the field JSON files under resources directory. Raises: SDKException """ with ModuleFieldsHandler.lock: try: record_field_details_directory = ModuleFieldsHandler.__get_directory() if os.path.exists(record_field_details_directory): files_list = [os.path.join(record_field_details_directory, file) for file in os.listdir(record_field_details_directory) if os.path.isfile(os.path.join(record_field_details_directory, file))] for each_file in files_list: if Constants.JSON_FILE_EXTENSION in each_file: os.remove(each_file) except Exception as e: sdk_exception = SDKException(cause=e) ModuleFieldsHandler.logger.info(Constants.DELETE_FIELD_FILES_ERROR + sdk_exception.__str__()) raise sdk_exception @staticmethod def delete_fields(module): """ The method to delete fields of the given module from the current user's fields JSON file. Parameters: module(str): A string representing the module. Raises: SDKException """ try: if module is None: raise Exception("module should not be None") record_field_details_path = os.path.join(ModuleFieldsHandler.__get_directory(), Converter.get_encoded_file_name()) if os.path.exists(record_field_details_path): record_field_details_json = Initializer.get_json(record_field_details_path) if module in record_field_details_json: Utility.delete_fields(record_field_details_json, module) with open(record_field_details_path, mode="w") as file: json.dump(record_field_details_json, file) file.flush() file.close() except Exception as e: sdk_exception = SDKException(cause=e) ModuleFieldsHandler.logger.info(Constants.DELETE_MODULE_FROM_FIELDFILE_ERROR + sdk_exception.__str__()) raise sdk_exception @staticmethod def refresh_fields(module): """ The method to force-refresh fields of a module. Parameters: module(str): A string representing the module. Raises: SDKException """ with ModuleFieldsHandler.lock: try: if module is None: raise Exception("module should not be None") ModuleFieldsHandler.delete_fields(module) Utility.get_fields_info(module) except SDKException as ex: ModuleFieldsHandler.logger.info(Constants.REFRESH_SINGLE_MODULE_FIELDS_ERROR + module + ex.__str__()) raise ex except Exception as e: sdk_exception = SDKException(cause=e) ModuleFieldsHandler.logger.info(Constants.REFRESH_SINGLE_MODULE_FIELDS_ERROR + sdk_exception.__str__()) raise sdk_exception @staticmethod def refresh_all_modules(): """ The method to force-refresh fields of all the available modules. Raises: SDKException """ with ModuleFieldsHandler.lock: try: Utility.refresh_modules() except SDKException as ex: ModuleFieldsHandler.logger.info(Constants.REFRESH_ALL_MODULE_FIELDS_ERROR + ex.__str__()) raise ex except Exception as e: sdk_exception = SDKException(cause=e) ModuleFieldsHandler.logger.info(Constants.REFRESH_ALL_MODULE_FIELDS_ERROR + sdk_exception.__str__()) raise sdk_exception
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/module_fields_handler.py
module_fields_handler.py
try: import importlib import logging import re import json from zcrmsdk.src.com.zoho.crm.api.util import Converter, Constants, JSONConverter except Exception: import importlib import logging import re from .converter import Converter from .constants import Constants from .json_converter import JSONConverter class Downloader(Converter): """ This class to process the download file and stream response. """ logger = logging.getLogger('SDKLogger') def __init__(self, common_api_handler): super().__init__(common_api_handler) self.unique_dict = {} self.common_api_handler = common_api_handler def form_request(self, request_instance, pack, instance_number, class_member_detail): return None def append_to_request(self, request_base, request_object): return def get_wrapped_response(self, response, pack): return self.get_response(response, pack) def get_response(self, response, pack): try: from zcrmsdk.src.com.zoho.crm.api import Initializer except Exception: from ..initializer import Initializer path_split = str(pack).rpartition(".") class_name = self.module_to_class(path_split[-1]) pack = path_split[0] + "." + class_name class_detail = dict(Initializer.json_details[str(pack)]) if Constants.INTERFACE in class_detail and class_detail[Constants.INTERFACE] is not None: classes = class_detail[Constants.CLASSES] for each_class in classes: if Constants.FILE_BODY_WRAPPER in each_class: return self.get_response(response, each_class) else: instance = self.get_class(class_name, path_split[0])() for member_name, member_detail in class_detail.items(): data_type = member_detail[Constants.TYPE] instance_value = None if data_type == Constants.STREAM_WRAPPER_CLASS_PATH: file_name = '' content_disposition = response.headers[Constants.CONTENT_DISPOSITION] if "'" in content_disposition: start_index = content_disposition.rindex("'") file_name = content_disposition[start_index + 1:] elif '"' in content_disposition: start_index = content_disposition.rindex('=') file_name = content_disposition[start_index + 1:].replace('"', '') stream_path_split = str(data_type).rpartition(".") stream_class_name = self.module_to_class(stream_path_split[-1]) instance_value = self.get_class(stream_class_name, stream_path_split[0])(file_name, response) setattr(instance, self.construct_private_member(class_name=class_name, member_name=member_name), instance_value) return instance @staticmethod def construct_private_member(class_name, member_name): return '_' + class_name + '__' + member_name @staticmethod def get_class(class_name, class_path): imported_module = importlib.import_module(class_path) class_holder = getattr(imported_module, class_name) return class_holder
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/downloader.py
downloader.py
try: import os import re import json from zcrmsdk.src.com.zoho.crm.api.util.datatype_converter import DataTypeConverter from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util.constants import Constants except Exception: import os import re import json from .datatype_converter import DataTypeConverter from ..exception import SDKException from .constants import Constants class HeaderParamValidator(object): """ This class validates the Header and Parameter values with the type accepted by the CRM APIs. """ def validate(self, header_param, value): name = header_param.name class_name = header_param.class_name json_details = self.get_json_details() json_class_name = self.get_file_name(class_name) type_detail = None if json_class_name in json_details: type_detail = self.get_key_json_details(name, json_details[json_class_name]) if type_detail is not None: try: from zcrmsdk.src.com.zoho.crm.api.util.utility import Utility except Exception: from ..util.utility import Utility if not Utility.check_data_type(value, type_detail[Constants.TYPE]): param_or_header = 'PARAMETER' if json_class_name is not None and json_class_name.endswith('Param') else 'HEADER' error_details = { param_or_header: name, Constants.CLASS: json_class_name, Constants.ACCEPTED_TYPE: Constants.DATA_TYPE.get(type_detail[Constants.TYPE]).__name__ if type_detail[Constants.TYPE] in Constants.DATA_TYPE else type_detail[Constants.TYPE] } raise SDKException(code=Constants.TYPE_ERROR, details=error_details) else: value = DataTypeConverter.post_convert(value, type_detail[Constants.TYPE]) return value def get_key_json_details(self, name, json_details): for key_name in json_details.keys(): detail = json_details[key_name] if Constants.NAME in detail: if detail[Constants.NAME].lower() == name.lower(): return detail def get_file_name(self, name): sdk_name = 'zcrmsdk.src.' name_split = str(name).split('.') class_name = name_split.pop() package_name = name_split.pop() pack_split = re.findall('[A-Z][^A-Z]*', package_name) sdk_package_name = pack_split[0].lower() if len(pack_split) > 1: for i in range(1, len(pack_split)): sdk_package_name += '_' + pack_split[i].lower() name_split = list(map(lambda x: x.lower(), name_split)) sdk_name = sdk_name + '.'.join(name_split) + '.' + sdk_package_name + '.' + class_name return sdk_name def get_json_details(self): try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer if Initializer.json_details is None: dir_name = os.path.dirname(__file__) filename = os.path.join(dir_name, '..', '..', '..', '..', '..', Constants.JSON_DETAILS_FILE_PATH) with open(filename, mode='r') as JSON: Initializer.json_details = json.load(JSON) return Initializer.json_details
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/header_param_validator.py
header_param_validator.py
try: import requests import logging import json from zcrmsdk.src.com.zoho.crm.api.util.constants import Constants from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from .constants import Constants import requests import logging import json from ..initializer import Initializer class APIHTTPConnector(object): """ This module is to make HTTP connections, trigger the requests and receive the response. """ def __init__(self): """ Creates an APIHTTPConnector class instance with the specified parameters. """ self.url = None self.request_method = None self.headers = dict() self.parameters = dict() self.request_body = None self.content_type = None self.file = False def add_header(self, header_name, header_value): """ The method to add API request header name and value. Parameters: header_name (str) : A String containing the API request header name. header_value (str) : A String containing the API request header value. """ self.headers[header_name] = header_value def add_param(self, param_name, param_value): """ The method to add API request parameter name and value. Parameters: param_name (str) : A String containing the API request parameter name. param_value (str) : A String containing the API request parameter value. """ self.parameters[param_name] = param_value def fire_request(self, converter_instance): """ This method makes a request to the Zoho CRM Rest API Parameters: converter_instance (Converter) : A Converter class instance to call append_to_request method. Returns: requests.Response : An object of requests.Response """ response = None proxies = None logger = logging.getLogger('SDKLogger') initializer = Initializer.get_initializer() sdk_config = initializer.sdk_config read_timeout = sdk_config.get_read_timeout() connect_timeout = sdk_config.get_connect_timeout() if read_timeout is None and connect_timeout is None: timeout = None elif read_timeout is None: timeout = connect_timeout elif connect_timeout is None: timeout = read_timeout else: timeout = (connect_timeout, read_timeout) if self.content_type is not None: self.set_content_type_header() if initializer.request_proxy is not None: request_proxy = initializer.request_proxy auth = "" if request_proxy is not None: auth = request_proxy.get_user() + ':' + request_proxy.get_password() + '@' if Constants.HTTP in request_proxy.get_host(): host_split = request_proxy.get_host().split('://') scheme = host_split[0] proxies = { scheme: scheme + '://' + auth + host_split[1] + ':' + str(request_proxy.get_port()) } else: proxies = { Constants.HTTP: Constants.HTTP + '://' + auth + request_proxy.get_host() + ':' + str( request_proxy.get_port()), Constants.HTTPS: Constants.HTTPS + '://' + auth + request_proxy.get_host() + ':' + str( request_proxy.get_port()) } logger.info(self.proxy_log(request_proxy)) logger.info(self.__str__()) if self.request_method == Constants.REQUEST_METHOD_GET: response = requests.get(url=self.url, headers=self.headers, params=self.parameters, allow_redirects=False, proxies=proxies, timeout=timeout) elif self.request_method == Constants.REQUEST_METHOD_PUT: data = None if self.request_body is not None: data = converter_instance.append_to_request(self, self.request_body) response = requests.put(url=self.url, data=data, params=self.parameters, headers=self.headers, allow_redirects=False, proxies=proxies) elif self.request_method == Constants.REQUEST_METHOD_POST: data = None if self.request_body is not None: data = converter_instance.append_to_request(self, self.request_body) if self.file: response = requests.post(url=self.url, files=data, headers=self.headers, allow_redirects=False, data={}, proxies=proxies) else: response = requests.post(url=self.url, data=data, params=self.parameters, headers=self.headers, allow_redirects=False, proxies=proxies) elif self.request_method == Constants.REQUEST_METHOD_PATCH: data = None if self.request_body is not None: data = converter_instance.append_to_request(self, self.request_body) response = requests.patch(url=self.url, data=data, headers=self.headers, params=self.parameters, allow_redirects=False, proxies=proxies) elif self.request_method == Constants.REQUEST_METHOD_DELETE: response = requests.delete(url=self.url, headers=self.headers, params=self.parameters, allow_redirects=False, proxies=proxies) return response def __str__(self): request_headers = self.headers.copy() request_headers[Constants.AUTHORIZATION] = Constants.CANT_DISCLOSE return self.request_method + ' - ' + Constants.URL + ' = ' + self.url + ' , ' + Constants.HEADERS + ' = ' + \ json.dumps(request_headers) \ + ' , ' + Constants.PARAMS + ' = ' + json.dumps(self.parameters) + '.' @staticmethod def proxy_log(request_proxy): proxy_details = Constants.PROXY_SETTINGS + Constants.PROXY_HOST + str( request_proxy.get_host()) + ', ' + Constants.PROXY_PORT + str(request_proxy.get_port()) if request_proxy.user is not None: proxy_details = proxy_details + ', ' + Constants.PROXY_USER + str(request_proxy.get_user()) return proxy_details def set_content_type_header(self): for url in Constants.SET_CONTENT_TYPE_HEADER: if url in self.url: self.headers[Constants.CONTENT_TYPE_HEADER] = self.content_type return
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/api_http_connector.py
api_http_connector.py
try: import importlib import re import json from zcrmsdk.src.com.zoho.crm.api.util import Converter, Constants, DataTypeConverter, Utility from zcrmsdk.src.com.zoho.crm.api.exception.sdk_exception import SDKException except Exception: import importlib import re from ..exception import SDKException from .converter import Converter from .constants import Constants from .datatype_converter import DataTypeConverter from .utility import Utility class JSONConverter(Converter): """ This class processes the API response to the object and an object to a JSON object, containing the request body. """ def __init__(self, common_api_handler): super().__init__(common_api_handler) self.unique_dict = {} self.common_api_handler = common_api_handler def append_to_request(self, request_base, request_object): return json.dumps(request_object).encode('utf-8') def form_request(self, request_instance, pack, instance_number, class_member_detail): path_split = str(pack).rpartition(".") class_name = self.module_to_class(path_split[-1]) pack = path_split[0] + "." + class_name try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer class_detail = dict(Initializer.json_details[str(pack)]) if Constants.INTERFACE in class_detail and class_detail[Constants.INTERFACE] is not None: request_object_class_name = request_instance.__class__.__module__ request_object_class_name = str(request_object_class_name) path_split = str(request_object_class_name).rpartition(".") request_class_name = self.module_to_class(path_split[-1]) request_object_class_name = path_split[0] + "." + request_class_name classes = class_detail[Constants.CLASSES] for class_name in classes: class_name_interface_lower = str(class_name).lower() request_class_path_lower = request_object_class_name.lower() if class_name_interface_lower == request_class_path_lower: class_detail = dict(Initializer.json_details[str(class_name)]) class_name = str(class_name).rpartition(".") class_name = self.module_to_class(class_name[-1]) break try: from zcrmsdk.src.com.zoho.crm.api.record import Record except Exception: from ..record import Record if isinstance(request_instance, Record): module_api_name = self.common_api_handler.get_module_api_name() return_json = self.is_record_request(request_instance, class_detail, instance_number, class_member_detail) self.common_api_handler.set_module_api_name(module_api_name) return return_json else: return self.is_not_record_request(request_instance, class_name, class_detail, instance_number, class_member_detail) def is_not_record_request(self, request_instance, class_name, class_detail, instance_number, class_member_detail): try: from zcrmsdk.src.com.zoho.crm.api.record import FileDetails except Exception: from ..record import FileDetails lookup = False skip_mandatory = False class_member_name = None if class_member_detail is not None: lookup = class_member_detail[Constants.LOOKUP] if Constants.LOOKUP in class_member_detail else False skip_mandatory = class_member_detail[Constants.SKIP_MANDATORY] \ if Constants.SKIP_MANDATORY in class_member_detail else False class_member_name = class_member_detail[Constants.NAME] request_json = {} required_keys, primary_keys, required_in_update_keys = {}, {}, {} for member_name, member_detail in class_detail.items(): if Constants.READ_ONLY in member_name or (Constants.NAME not in member_detail): continue key_name = member_detail[Constants.NAME] try: modification = getattr(request_instance, Constants.IS_KEY_MODIFIED)(key_name) except Exception as e: raise SDKException(code=Constants.EXCEPTION_IS_KEY_MODIFIED, cause=e) if Constants.REQUIRED in member_detail and member_detail[Constants.REQUIRED]: required_keys[key_name] = True if Constants.PRIMARY in member_detail and member_detail[Constants.PRIMARY] and \ (Constants.REQUIRED_IN_UPDATE not in member_detail or member_detail[Constants.REQUIRED_IN_UPDATE]): primary_keys[key_name] = True if Constants.REQUIRED_IN_UPDATE in member_detail and member_detail[Constants.REQUIRED_IN_UPDATE]: required_in_update_keys[key_name] = True field_value = None if modification is not None and modification != 0: field_value = getattr(request_instance, self.construct_private_member(class_name=class_name, member_name=member_name)) if self.value_checker(class_name=class_name, member_name=member_name, key_details=member_detail, value=field_value, unique_values_map=self.unique_dict, instance_number=instance_number) is True: if field_value is not None: required_keys.pop(key_name, None) primary_keys.pop(key_name, None) required_in_update_keys.pop(key_name, None) if isinstance(request_instance, FileDetails): if field_value is None or (isinstance(field_value, str) and field_value == "null"): request_json[key_name.lower()] = None if field_value is None else field_value else: request_json[key_name.lower()] = field_value else: request_json[key_name] = self.set_data(member_detail, field_value) if skip_mandatory or self.check_exception(class_member_name, request_instance, instance_number, lookup, required_keys, primary_keys, required_in_update_keys) is True: return request_json def check_exception(self, member_name, request_instance, instance_number, lookup, required_keys, primary_keys, required_in_update_keys): if bool(required_in_update_keys) and self.common_api_handler.get_category_method() is not None and \ self.common_api_handler.get_category_method().upper() == Constants.REQUEST_CATEGORY_UPDATE: error = { Constants.FIELD: member_name, Constants.TYPE: request_instance.__module__, Constants.KEYS: str(list(required_in_update_keys.keys())) } if instance_number is not None: error[Constants.INSTANCE_NUMBER] = instance_number raise SDKException(Constants.MANDATORY_VALUE_ERROR, Constants.MANDATORY_KEY_ERROR, error) if self.common_api_handler.get_mandatory_checker() is not None and \ self.common_api_handler.get_mandatory_checker(): if self.common_api_handler.get_category_method().upper() == Constants.REQUEST_CATEGORY_CREATE: if lookup: if bool(primary_keys): error = { Constants.FIELD: member_name, Constants.TYPE: request_instance.__module__, Constants.KEYS: str(list(primary_keys.keys())) } if instance_number is not None: error[Constants.INSTANCE_NUMBER] = instance_number raise SDKException(Constants.MANDATORY_VALUE_ERROR, Constants.MANDATORY_KEY_ERROR, error) elif bool(required_keys): error = { Constants.FIELD: member_name, Constants.TYPE: request_instance.__module__, Constants.KEYS: str(list(required_keys.keys())) } if instance_number is not None: error[Constants.INSTANCE_NUMBER] = instance_number raise SDKException(Constants.MANDATORY_VALUE_ERROR, Constants.MANDATORY_KEY_ERROR, error) if self.common_api_handler.get_category_method().upper() == Constants.REQUEST_CATEGORY_UPDATE and \ bool(primary_keys): error = { Constants.FIELD: member_name, Constants.TYPE: request_instance.__module__, Constants.KEYS: str(list(primary_keys.keys())) } if instance_number is not None: error[Constants.INSTANCE_NUMBER] = instance_number raise SDKException(Constants.MANDATORY_VALUE_ERROR, Constants.PRIMARY_KEY_ERROR, error) elif lookup and self.common_api_handler.get_category_method().upper() == Constants.REQUEST_CATEGORY_UPDATE: if bool(primary_keys): error = { Constants.FIELD: member_name, Constants.TYPE: request_instance.__module__, Constants.KEYS: str(list(primary_keys.keys())) } if instance_number is not None: error[Constants.INSTANCE_NUMBER] = instance_number raise SDKException(Constants.MANDATORY_VALUE_ERROR, Constants.PRIMARY_KEY_ERROR, error) return True def is_record_request(self, record_instance, class_detail, instance_number, member_detail): try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer lookup = False skip_mandatory = False class_member_name = None if member_detail is not None: lookup = member_detail[Constants.LOOKUP] if Constants.LOOKUP in member_detail else False skip_mandatory = member_detail[ Constants.SKIP_MANDATORY] if Constants.SKIP_MANDATORY in member_detail else False class_member_name = member_detail[Constants.NAME] request_json, module_detail = {}, {} module_api_name = self.common_api_handler.get_module_api_name() class_name = record_instance.__class__.__name__ if module_api_name is not None: self.common_api_handler.set_module_api_name(None) full_detail = Utility.search_json_details(module_api_name) if full_detail is not None: module_detail = full_detail[Constants.MODULEDETAILS] else: module_detail = self.__get_module_detail_from_user_spec_json(module_api_name) else: module_detail = class_detail class_detail = Initializer.json_details[Constants.RECORD_NAMESPACE] class_list = record_instance.__class__.mro() for each_class in class_list: if Constants.RECORD_TYPE in str(each_class): class_name = Constants.RECORD_CLASS_NAME break key_values = getattr(record_instance, self.construct_private_member(class_name, Constants.KEY_VALUES)) key_modified = getattr(record_instance, self.construct_private_member(class_name, Constants.KEY_MODIFIED)) required_keys, primary_keys = {}, {} if not skip_mandatory: for key_name, key_detail in module_detail.items(): name = key_detail[Constants.NAME] if key_detail is not None and Constants.REQUIRED in key_detail and key_detail[Constants.REQUIRED]: required_keys[name] = True if key_detail is not None and Constants.PRIMARY in key_detail and key_detail[Constants.PRIMARY]: primary_keys[name] = True for key_name, key_detail in class_detail.items(): name = key_detail[Constants.NAME] if Constants.REQUIRED in key_detail and key_detail[Constants.REQUIRED]: required_keys[name] = True if Constants.PRIMARY in key_detail and key_detail[Constants.PRIMARY]: primary_keys[name] = True for key_name in key_modified.keys(): if key_modified.get(key_name) != 1: continue key_detail = {} key_value = key_values.get(key_name) if key_name in key_values else None json_value = None member_name = self.build_name(key_name) if len(module_detail) > 0 and (member_name in module_detail or key_name in module_detail): key_detail = module_detail[key_name] if key_name in module_detail else module_detail[member_name] elif member_name in class_detail: key_detail = class_detail[member_name] if len(key_detail) > 0: if (Constants.READ_ONLY in key_detail and bool(key_detail[Constants.READ_ONLY])) or \ (Constants.NAME not in key_detail): continue if self.value_checker(class_name, key_name, key_detail, key_value, self.unique_dict, instance_number): json_value = self.set_data(key_detail, key_value) else: json_value = self.redirector_for_object_to_json(key_value) if key_value is not None: required_keys.pop(key_name, None) primary_keys.pop(key_name, None) request_json[key_name] = json_value if skip_mandatory or self.check_exception(class_member_name, record_instance, instance_number, lookup, required_keys, primary_keys, {}) is True: return request_json def set_data(self, member_detail, field_value): if field_value is not None: data_type = member_detail[Constants.TYPE] if data_type == Constants.LIST_NAMESPACE: return self.set_json_array(field_value, member_detail) elif data_type == Constants.MAP_NAMESPACE: return self.set_json_object(field_value, member_detail) elif data_type == Constants.CHOICE_NAMESPACE or \ (Constants.STRUCTURE_NAME in member_detail and member_detail[Constants.STRUCTURE_NAME] == Constants.CHOICE_NAMESPACE): return field_value.get_value() elif Constants.STRUCTURE_NAME in member_detail and Constants.MODULE in member_detail: return self.is_record_request( field_value, self.__get_module_detail_from_user_spec_json( member_detail[Constants.MODULE]), None, member_detail) elif Constants.STRUCTURE_NAME in member_detail: return self.form_request(field_value, member_detail[Constants.STRUCTURE_NAME], None, member_detail) else: return DataTypeConverter.post_convert(field_value, data_type) return None def set_json_object(self, field_value, member_detail): json_object = {} request_object = dict(field_value) if len(request_object) > 0: if member_detail is None or (member_detail is not None and Constants.KEYS not in member_detail): for key, value in request_object.items(): json_object[key] = self.redirector_for_object_to_json(value) else: if Constants.KEYS in member_detail: keys_detail = member_detail[Constants.KEYS] for key_detail in keys_detail: key_name = key_detail[Constants.NAME] if key_name in request_object and request_object[key_name] is not None: key_value = self.set_data(key_detail, request_object[key_name]) json_object[key_name] = key_value return json_object def set_json_array(self, field_value, member_detail): json_array = [] request_objects = list(field_value) if len(request_objects) > 0: if member_detail is None or (member_detail is not None and Constants.STRUCTURE_NAME not in member_detail): for request in request_objects: json_array.append(self.redirector_for_object_to_json(request)) else: pack = member_detail[Constants.STRUCTURE_NAME] if pack == Constants.CHOICE_NAMESPACE: for request in request_objects: json_array.append(request.get_value()) elif Constants.MODULE in member_detail and member_detail[Constants.MODULE] is not None: instance_count = 0 for request in request_objects: json_array.append( self.is_record_request(request, self.__get_module_detail_from_user_spec_json( member_detail[Constants.MODULE]), instance_count, member_detail)) instance_count += 1 else: instance_count = 0 for request in request_objects: json_array.append(self.form_request(request, pack, instance_count, member_detail)) instance_count += 1 return json_array def redirector_for_object_to_json(self, request): if isinstance(request, list): return self.set_json_array(request, None) elif isinstance(request, dict): return self.set_json_object(request, None) else: return request def get_wrapped_response(self, response, pack): try: return self.get_response(response.json(), pack) except ValueError: return None def get_response(self, response, package_name): try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer if response is None or response == '' or response == "None" or response == "null": return None response_json = dict(response) path_split = str(package_name).rpartition(".") class_name = self.module_to_class(path_split[-1]) package_name = path_split[0] + "." + class_name class_detail = dict(Initializer.json_details[str(package_name)]) instance = None if Constants.INTERFACE in class_detail and class_detail[Constants.INTERFACE] is not None: classes = class_detail[Constants.CLASSES] instance = self.find_match(classes, response_json) else: imported_module = importlib.import_module(path_split[0]) class_holder = getattr(imported_module, class_name) instance = class_holder() try: from zcrmsdk.src.com.zoho.crm.api.record import Record except Exception: from ..record import Record if isinstance(instance, Record): module_api_name = self.common_api_handler.get_module_api_name() instance = self.is_record_response(response_json, class_detail, package_name) self.common_api_handler.set_module_api_name(module_api_name) else: instance = self.not_record_response(instance=instance, class_name=class_name, response_json=response_json, class_detail=class_detail) return instance def not_record_response(self, instance, class_name, response_json, class_detail): for member_name, key_detail in class_detail.items(): key_name = key_detail[Constants.NAME] if Constants.NAME in key_detail else None if key_name is not None and key_name in response_json and response_json.get(key_name) is not None: key_data = response_json[key_name] member_value = self.get_data(key_data, key_detail) setattr(instance, self.construct_private_member(class_name=class_name, member_name=member_name), member_value) return instance def is_record_response(self, response_json, class_detail, pack): try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer response_json = dict(response_json) record_instance = JSONConverter.__get_instance_from_name(pack) module_api_name = self.common_api_handler.get_module_api_name() module_detail = {} class_name = Constants.RECORD_NAMESPACE.rpartition('.')[-1] if module_api_name is not None: self.common_api_handler.set_module_api_name(None) full_detail = Utility.search_json_details(module_api_name) if full_detail is not None: module_detail = full_detail[Constants.MODULEDETAILS] class_name = str(full_detail[Constants.MODULEPACKAGENAME]).rpartition('.')[-1] record_instance = JSONConverter.__get_instance_from_name(full_detail[Constants.MODULEPACKAGENAME]) else: module_detail = self.__get_module_detail_from_user_spec_json(module_api_name) for key, value in class_detail.items(): module_detail[key] = value record_detail = Initializer.json_details[Constants.RECORD_NAMESPACE] class_list = record_instance.__class__.mro() for each_class in class_list: if Constants.RECORD_TYPE in str(each_class): class_name = Constants.RECORD_CLASS_NAME break key_values = {} for key_name in response_json.keys(): member_name = self.build_name(key_name) key_detail = {} if len(module_detail) > 0 and (key_name in module_detail or member_name in module_detail): key_detail = module_detail[key_name] if key_name in module_detail.keys() else module_detail[member_name] elif member_name in record_detail: key_detail = record_detail[member_name] key_data = response_json[key_name] key_value = None if len(key_detail) > 0: key_name = key_detail[Constants.NAME] key_value = self.get_data(key_data, key_detail) else: key_value = self.redirector_for_json_to_object(key_data) key_values[key_name] = key_value setattr(record_instance, self.construct_private_member(class_name, Constants.KEY_VALUES), key_values) return record_instance def get_data(self, key_data, member_detail): member_value = None if key_data is not None: data_type = member_detail.get(Constants.TYPE) if data_type == Constants.LIST_NAMESPACE: member_value = self.get_collections_data(key_data, member_detail) elif data_type == Constants.MAP_NAMESPACE: member_value = self.get_map_data(key_data, member_detail) elif data_type == Constants.CHOICE_NAMESPACE or ( Constants.STRUCTURE_NAME in member_detail and member_detail[ Constants.STRUCTURE_NAME] == Constants.CHOICE_NAMESPACE): member_value = self.__get_choice_instance(key_data) elif Constants.STRUCTURE_NAME in member_detail and Constants.MODULE in member_detail: member_value = self.is_record_response(key_data, self.__get_module_detail_from_user_spec_json( member_detail[Constants.MODULE]), member_detail[Constants.STRUCTURE_NAME]) elif Constants.STRUCTURE_NAME in member_detail: member_value = self.get_response(key_data, member_detail[Constants.STRUCTURE_NAME]) else: member_value = DataTypeConverter.pre_convert(key_data, data_type) return member_value def get_map_data(self, response, member_detail): map_instance = {} if len(response) > 0: if member_detail is None or (member_detail is not None and Constants.KEYS not in member_detail): for key, value in response.items(): map_instance[key] = self.redirector_for_json_to_object(value) else: if Constants.KEYS in member_detail: keys_detail = member_detail[Constants.KEYS] for key_detail in keys_detail: key_name = key_detail[Constants.NAME] if key_name in response and response[key_name] is not None: key_value = self.get_data(response[key_name], key_detail) map_instance[key_name] = key_value return map_instance def get_collections_data(self, responses, member_detail): values = [] if len(responses) > 0: if member_detail is None or (member_detail is not None and Constants.STRUCTURE_NAME not in member_detail): for response in responses: values.append(self.redirector_for_json_to_object(response)) else: pack = member_detail[Constants.STRUCTURE_NAME] if pack == Constants.CHOICE_NAMESPACE: for response in responses: values.append(self.__get_choice_instance(response)) elif Constants.MODULE in member_detail and member_detail[Constants.MODULE] is not None: for response in responses: values.append(self.is_record_response(response, self.__get_module_detail_from_user_spec_json( member_detail[Constants.MODULE]), pack)) else: for response in responses: values.append(self.get_response(response, pack)) return values def __get_module_detail_from_user_spec_json(self, module): try: import os from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: import os from ..initializer import Initializer record_field_details_path = os.path.join(Initializer.get_initializer().resource_path, Constants.FIELD_DETAILS_DIRECTORY, Converter.get_encoded_file_name()) record_field_details = Initializer.get_json(record_field_details_path) module_detail = Utility.get_json_object(record_field_details, module) return module_detail def redirector_for_json_to_object(self, key_data): if isinstance(key_data, dict): return self.get_map_data(key_data, None) elif isinstance(key_data, list): return self.get_collections_data(key_data, None) else: return key_data def find_match(self, classes, response_json): pack = "" ratio = 0 for class_name in classes: match_ratio = self.find_ratio(class_name, response_json) if match_ratio == 1.0: pack = class_name ratio = 1 break elif match_ratio > ratio: ratio = match_ratio pack = class_name return self.get_response(response_json, pack) def find_ratio(self, class_name, response_json): try: from zcrmsdk.src.com.zoho.crm.api.initializer import Initializer except Exception: from ..initializer import Initializer class_detail = dict(Initializer.json_details[str(class_name)]) total_points = len(class_detail.keys()) matches = 0 if total_points == 0: return else: for member_name in class_detail: member_detail = class_detail[member_name] key_name = member_detail[Constants.NAME] if Constants.NAME in member_detail else None if key_name is not None and key_name in response_json and response_json.get(key_name) is not None: key_data = response_json[key_name] data_type = type(key_data).__name__ structure_name = member_detail[ Constants.STRUCTURE_NAME] if Constants.STRUCTURE_NAME in member_detail else None if isinstance(key_data, dict): data_type = Constants.MAP_NAMESPACE if isinstance(key_data, list): data_type = Constants.LIST_NAMESPACE if data_type == member_detail[Constants.TYPE] or ( member_detail[Constants.TYPE] in Constants.DATA_TYPE and isinstance(key_data, Constants.DATA_TYPE.get(member_detail[Constants.TYPE]))): matches += 1 elif key_name.lower() == Constants.COUNT.lower() and \ member_detail[Constants.TYPE].lower() == Constants.LONG_NAMESPACE.lower(): matches += 1 elif member_detail[Constants.TYPE] == Constants.CHOICE_NAMESPACE: values = list(member_detail[Constants.VALUES]) for value in values: if value == key_data: matches += 1 break if structure_name is not None and structure_name == member_detail[Constants.TYPE]: if Constants.VALUES in member_detail: for value in member_detail[Constants.VALUES]: if value == key_data: matches += 1 break else: matches += 1 return matches / total_points def build_name(self, key_name): name_split = str(key_name).split('_') sdk_name = name_split[0].lower() if len(name_split) > 1: for i in range(1, len(name_split)): if len(name_split[i]) > 0: sdk_name += '_' + name_split[i].lower() return sdk_name @staticmethod def __get_instance_from_name(class_path): path_split = str(class_path).rpartition('.') imported_module = importlib.import_module(path_split[0]) class_holder = getattr(imported_module, path_split[-1]) return class_holder() def construct_private_member(self, class_name, member_name): return '_' + class_name + '__' + member_name def __get_choice_instance(self, data): choice_split = Constants.CHOICE_NAMESPACE.rpartition('.') imported_module = importlib.import_module(choice_split[0]) class_holder = getattr(imported_module, choice_split[-1]) choice_instance = class_holder(data) return choice_instance
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/util/json_converter.py
json_converter.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.notes.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Constants from .action_handler import ActionHandler class ActionWrapper(ActionHandler): def __init__(self): """Creates an instance of ActionWrapper""" super().__init__() self.__data = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notes/action_wrapper.py
action_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.notes.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__data = None self.__info = None self.__key_modified = dict() def get_data(self): """ The method to get the data Returns: list: An instance of list """ return self.__data def set_data(self, data): """ The method to set the value to data Parameters: data (list) : An instance of list """ if data is not None and not isinstance(data, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: data EXPECTED TYPE: list', None, None) self.__data = data self.__key_modified['data'] = 1 def get_info(self): """ The method to get the info Returns: Info: An instance of Info """ return self.__info def set_info(self, info): """ The method to set the value to info Parameters: info (Info) : An instance of Info """ try: from zcrmsdk.src.com.zoho.crm.api.notes.info import Info except Exception: from .info import Info if info is not None and not isinstance(info, Info): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: info EXPECTED TYPE: Info', None, None) self.__info = info self.__key_modified['info'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notes/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Note(object): def __init__(self): """Creates an instance of Note""" self.__owner = None self.__modified_time = None self.__attachments = None self.__created_time = None self.__parent_id = None self.__editable = None self.__sharing_permission = None self.__se_module = None self.__is_shared_to_client = None self.__modified_by = None self.__size = None self.__state = None self.__voice_note = None self.__id = None self.__created_by = None self.__note_title = None self.__note_content = None self.__key_modified = dict() def get_owner(self): """ The method to get the owner Returns: User: An instance of User """ return self.__owner def set_owner(self, owner): """ The method to set the value to owner Parameters: owner (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if owner is not None and not isinstance(owner, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: owner EXPECTED TYPE: User', None, None) self.__owner = owner self.__key_modified['Owner'] = 1 def get_modified_time(self): """ The method to get the modified_time Returns: datetime: An instance of datetime """ return self.__modified_time def set_modified_time(self, modified_time): """ The method to set the value to modified_time Parameters: modified_time (datetime) : An instance of datetime """ from datetime import datetime if modified_time is not None and not isinstance(modified_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_time EXPECTED TYPE: datetime', None, None) self.__modified_time = modified_time self.__key_modified['Modified_Time'] = 1 def get_attachments(self): """ The method to get the attachments Returns: list: An instance of list """ return self.__attachments def set_attachments(self, attachments): """ The method to set the value to attachments Parameters: attachments (list) : An instance of list """ if attachments is not None and not isinstance(attachments, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: attachments EXPECTED TYPE: list', None, None) self.__attachments = attachments self.__key_modified['$attachments'] = 1 def get_created_time(self): """ The method to get the created_time Returns: datetime: An instance of datetime """ return self.__created_time def set_created_time(self, created_time): """ The method to set the value to created_time Parameters: created_time (datetime) : An instance of datetime """ from datetime import datetime if created_time is not None and not isinstance(created_time, datetime): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_time EXPECTED TYPE: datetime', None, None) self.__created_time = created_time self.__key_modified['Created_Time'] = 1 def get_parent_id(self): """ The method to get the parent_id Returns: Record: An instance of Record """ return self.__parent_id def set_parent_id(self, parent_id): """ The method to set the value to parent_id Parameters: parent_id (Record) : An instance of Record """ try: from zcrmsdk.src.com.zoho.crm.api.record import Record except Exception: from ..record import Record if parent_id is not None and not isinstance(parent_id, Record): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: parent_id EXPECTED TYPE: Record', None, None) self.__parent_id = parent_id self.__key_modified['Parent_Id'] = 1 def get_editable(self): """ The method to get the editable Returns: bool: A bool representing the editable """ return self.__editable def set_editable(self, editable): """ The method to set the value to editable Parameters: editable (bool) : A bool representing the editable """ if editable is not None and not isinstance(editable, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: editable EXPECTED TYPE: bool', None, None) self.__editable = editable self.__key_modified['$editable'] = 1 def get_sharing_permission(self): """ The method to get the sharing_permission Returns: string: A string representing the sharing_permission """ return self.__sharing_permission def set_sharing_permission(self, sharing_permission): """ The method to set the value to sharing_permission Parameters: sharing_permission (string) : A string representing the sharing_permission """ if sharing_permission is not None and not isinstance(sharing_permission, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: sharing_permission EXPECTED TYPE: str', None, None) self.__sharing_permission = sharing_permission self.__key_modified['$sharing_permission'] = 1 def get_se_module(self): """ The method to get the se_module Returns: string: A string representing the se_module """ return self.__se_module def set_se_module(self, se_module): """ The method to set the value to se_module Parameters: se_module (string) : A string representing the se_module """ if se_module is not None and not isinstance(se_module, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: se_module EXPECTED TYPE: str', None, None) self.__se_module = se_module self.__key_modified['$se_module'] = 1 def get_is_shared_to_client(self): """ The method to get the is_shared_to_client Returns: bool: A bool representing the is_shared_to_client """ return self.__is_shared_to_client def set_is_shared_to_client(self, is_shared_to_client): """ The method to set the value to is_shared_to_client Parameters: is_shared_to_client (bool) : A bool representing the is_shared_to_client """ if is_shared_to_client is not None and not isinstance(is_shared_to_client, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: is_shared_to_client EXPECTED TYPE: bool', None, None) self.__is_shared_to_client = is_shared_to_client self.__key_modified['$is_shared_to_client'] = 1 def get_modified_by(self): """ The method to get the modified_by Returns: User: An instance of User """ return self.__modified_by def set_modified_by(self, modified_by): """ The method to set the value to modified_by Parameters: modified_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if modified_by is not None and not isinstance(modified_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modified_by EXPECTED TYPE: User', None, None) self.__modified_by = modified_by self.__key_modified['Modified_By'] = 1 def get_size(self): """ The method to get the size Returns: string: A string representing the size """ return self.__size def set_size(self, size): """ The method to set the value to size Parameters: size (string) : A string representing the size """ if size is not None and not isinstance(size, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: size EXPECTED TYPE: str', None, None) self.__size = size self.__key_modified['$size'] = 1 def get_state(self): """ The method to get the state Returns: string: A string representing the state """ return self.__state def set_state(self, state): """ The method to set the value to state Parameters: state (string) : A string representing the state """ if state is not None and not isinstance(state, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: state EXPECTED TYPE: str', None, None) self.__state = state self.__key_modified['$state'] = 1 def get_voice_note(self): """ The method to get the voice_note Returns: bool: A bool representing the voice_note """ return self.__voice_note def set_voice_note(self, voice_note): """ The method to set the value to voice_note Parameters: voice_note (bool) : A bool representing the voice_note """ if voice_note is not None and not isinstance(voice_note, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: voice_note EXPECTED TYPE: bool', None, None) self.__voice_note = voice_note self.__key_modified['$voice_note'] = 1 def get_id(self): """ The method to get the id Returns: int: An int representing the id """ return self.__id def set_id(self, id): """ The method to set the value to id Parameters: id (int) : An int representing the id """ if id is not None and not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) self.__id = id self.__key_modified['id'] = 1 def get_created_by(self): """ The method to get the created_by Returns: User: An instance of User """ return self.__created_by def set_created_by(self, created_by): """ The method to set the value to created_by Parameters: created_by (User) : An instance of User """ try: from zcrmsdk.src.com.zoho.crm.api.users import User except Exception: from ..users import User if created_by is not None and not isinstance(created_by, User): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: created_by EXPECTED TYPE: User', None, None) self.__created_by = created_by self.__key_modified['Created_By'] = 1 def get_note_title(self): """ The method to get the note_title Returns: string: A string representing the note_title """ return self.__note_title def set_note_title(self, note_title): """ The method to set the value to note_title Parameters: note_title (string) : A string representing the note_title """ if note_title is not None and not isinstance(note_title, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: note_title EXPECTED TYPE: str', None, None) self.__note_title = note_title self.__key_modified['Note_Title'] = 1 def get_note_content(self): """ The method to get the note_content Returns: string: A string representing the note_content """ return self.__note_content def set_note_content(self, note_content): """ The method to set the value to note_content Parameters: note_content (string) : A string representing the note_content """ if note_content is not None and not isinstance(note_content, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: note_content EXPECTED TYPE: str', None, None) self.__note_content = note_content self.__key_modified['Note_Content'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notes/note.py
note.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.parameter_map import ParameterMap from zcrmsdk.src.com.zoho.crm.api.util import APIResponse, CommonAPIHandler, Constants from zcrmsdk.src.com.zoho.crm.api.param import Param from zcrmsdk.src.com.zoho.crm.api.header import Header from zcrmsdk.src.com.zoho.crm.api.header_map import HeaderMap except Exception: from ..exception import SDKException from ..parameter_map import ParameterMap from ..util import APIResponse, CommonAPIHandler, Constants from ..param import Param from ..header import Header from ..header_map import HeaderMap class NotesOperations(object): def __init__(self): """Creates an instance of NotesOperations""" pass def get_notes(self, param_instance=None, header_instance=None): """ The method to get notes Parameters: param_instance (ParameterMap) : An instance of ParameterMap header_instance (HeaderMap) : An instance of HeaderMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) if header_instance is not None and not isinstance(header_instance, HeaderMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: header_instance EXPECTED TYPE: HeaderMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/Notes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) handler_instance.set_header(header_instance) try: from zcrmsdk.src.com.zoho.crm.api.notes.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def create_notes(self, request): """ The method to create notes Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.notes.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/Notes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_POST) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_CREATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.notes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def update_notes(self, request): """ The method to update notes Parameters: request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.notes.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/Notes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) handler_instance.set_mandatory_checker(True) try: from zcrmsdk.src.com.zoho.crm.api.notes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delete_notes(self, param_instance=None): """ The method to delete notes Parameters: param_instance (ParameterMap) : An instance of ParameterMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/Notes' handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_param(param_instance) try: from zcrmsdk.src.com.zoho.crm.api.notes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def get_note(self, id, param_instance=None, header_instance=None): """ The method to get note Parameters: id (int) : An int representing the id param_instance (ParameterMap) : An instance of ParameterMap header_instance (HeaderMap) : An instance of HeaderMap Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) if param_instance is not None and not isinstance(param_instance, ParameterMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: param_instance EXPECTED TYPE: ParameterMap', None, None) if header_instance is not None and not isinstance(header_instance, HeaderMap): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: header_instance EXPECTED TYPE: HeaderMap', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/Notes/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_GET) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_READ) handler_instance.set_param(param_instance) handler_instance.set_header(header_instance) try: from zcrmsdk.src.com.zoho.crm.api.notes.response_handler import ResponseHandler except Exception: from .response_handler import ResponseHandler return handler_instance.api_call(ResponseHandler.__module__, 'application/json') def update_note(self, id, request): """ The method to update note Parameters: id (int) : An int representing the id request (BodyWrapper) : An instance of BodyWrapper Returns: APIResponse: An instance of APIResponse Raises: SDKException """ try: from zcrmsdk.src.com.zoho.crm.api.notes.body_wrapper import BodyWrapper except Exception: from .body_wrapper import BodyWrapper if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) if request is not None and not isinstance(request, BodyWrapper): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: request EXPECTED TYPE: BodyWrapper', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/Notes/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_PUT) handler_instance.set_category_method(Constants.REQUEST_CATEGORY_UPDATE) handler_instance.set_content_type('application/json') handler_instance.set_request(request) try: from zcrmsdk.src.com.zoho.crm.api.notes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') def delete_note(self, id): """ The method to delete note Parameters: id (int) : An int representing the id Returns: APIResponse: An instance of APIResponse Raises: SDKException """ if not isinstance(id, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: id EXPECTED TYPE: int', None, None) handler_instance = CommonAPIHandler() api_path = '' api_path = api_path + '/crm/v2.1/Notes/' api_path = api_path + str(id) handler_instance.set_api_path(api_path) handler_instance.set_http_method(Constants.REQUEST_METHOD_DELETE) handler_instance.set_category_method(Constants.REQUEST_METHOD_DELETE) try: from zcrmsdk.src.com.zoho.crm.api.notes.action_handler import ActionHandler except Exception: from .action_handler import ActionHandler return handler_instance.api_call(ActionHandler.__module__, 'application/json') class GetNotesParam(object): page = Param('page', 'com.zoho.crm.api.Notes.GetNotesParam') per_page = Param('per_page', 'com.zoho.crm.api.Notes.GetNotesParam') fields = Param('fields', 'com.zoho.crm.api.Notes.GetNotesParam') sort_order = Param('sort_order', 'com.zoho.crm.api.Notes.GetNotesParam') sort_by = Param('sort_by', 'com.zoho.crm.api.Notes.GetNotesParam') class GetNotesHeader(object): if_modified_since = Header('If-Modified-Since', 'com.zoho.crm.api.Notes.GetNotesHeader') class DeleteNotesParam(object): ids = Param('ids', 'com.zoho.crm.api.Notes.DeleteNotesParam') class GetNoteParam(object): fields = Param('fields', 'com.zoho.crm.api.Notes.GetNoteParam') class GetNoteHeader(object): if_modified_since = Header('If-Modified-Since', 'com.zoho.crm.api.Notes.GetNoteHeader')
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notes/notes_operations.py
notes_operations.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.notes.action_response import ActionResponse from zcrmsdk.src.com.zoho.crm.api.notes.response_handler import ResponseHandler from zcrmsdk.src.com.zoho.crm.api.notes.action_handler import ActionHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse from .response_handler import ResponseHandler from .action_handler import ActionHandler class APIException(ResponseHandler, ActionResponse, ActionHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__status = None self.__code = None self.__message = None self.__details = None self.__key_modified = dict() def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notes/api_exception.py
api_exception.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants except Exception: from ..exception import SDKException from ..util import Constants class Info(object): def __init__(self): """Creates an instance of Info""" self.__per_page = None self.__count = None self.__page = None self.__more_records = None self.__key_modified = dict() def get_per_page(self): """ The method to get the per_page Returns: int: An int representing the per_page """ return self.__per_page def set_per_page(self, per_page): """ The method to set the value to per_page Parameters: per_page (int) : An int representing the per_page """ if per_page is not None and not isinstance(per_page, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: per_page EXPECTED TYPE: int', None, None) self.__per_page = per_page self.__key_modified['per_page'] = 1 def get_count(self): """ The method to get the count Returns: int: An int representing the count """ return self.__count def set_count(self, count): """ The method to set the value to count Parameters: count (int) : An int representing the count """ if count is not None and not isinstance(count, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: count EXPECTED TYPE: int', None, None) self.__count = count self.__key_modified['count'] = 1 def get_page(self): """ The method to get the page Returns: int: An int representing the page """ return self.__page def set_page(self, page): """ The method to set the value to page Parameters: page (int) : An int representing the page """ if page is not None and not isinstance(page, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: page EXPECTED TYPE: int', None, None) self.__page = page self.__key_modified['page'] = 1 def get_more_records(self): """ The method to get the more_records Returns: bool: A bool representing the more_records """ return self.__more_records def set_more_records(self, more_records): """ The method to set the value to more_records Parameters: more_records (bool) : A bool representing the more_records """ if more_records is not None and not isinstance(more_records, bool): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: more_records EXPECTED TYPE: bool', None, None) self.__more_records = more_records self.__key_modified['more_records'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notes/info.py
info.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.notes.action_response import ActionResponse except Exception: from ..exception import SDKException from ..util import Choice, Constants from .action_response import ActionResponse class SuccessResponse(ActionResponse): def __init__(self): """Creates an instance of SuccessResponse""" super().__init__() self.__code = None self.__status = None self.__message = None self.__details = None self.__key_modified = dict() def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/notes/success_response.py
success_response.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Constants from zcrmsdk.src.com.zoho.crm.api.variable_groups.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Constants from .response_handler import ResponseHandler class ResponseWrapper(ResponseHandler): def __init__(self): """Creates an instance of ResponseWrapper""" super().__init__() self.__variable_groups = None self.__key_modified = dict() def get_variable_groups(self): """ The method to get the variable_groups Returns: list: An instance of list """ return self.__variable_groups def set_variable_groups(self, variable_groups): """ The method to set the value to variable_groups Parameters: variable_groups (list) : An instance of list """ if variable_groups is not None and not isinstance(variable_groups, list): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: variable_groups EXPECTED TYPE: list', None, None) self.__variable_groups = variable_groups self.__key_modified['variable_groups'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/variable_groups/response_wrapper.py
response_wrapper.py
try: from zcrmsdk.src.com.zoho.crm.api.exception import SDKException from zcrmsdk.src.com.zoho.crm.api.util import Choice, Constants from zcrmsdk.src.com.zoho.crm.api.variable_groups.response_handler import ResponseHandler except Exception: from ..exception import SDKException from ..util import Choice, Constants from .response_handler import ResponseHandler class APIException(ResponseHandler): def __init__(self): """Creates an instance of APIException""" super().__init__() self.__code = None self.__status = None self.__message = None self.__details = None self.__key_modified = dict() def get_code(self): """ The method to get the code Returns: Choice: An instance of Choice """ return self.__code def set_code(self, code): """ The method to set the value to code Parameters: code (Choice) : An instance of Choice """ if code is not None and not isinstance(code, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: code EXPECTED TYPE: Choice', None, None) self.__code = code self.__key_modified['code'] = 1 def get_status(self): """ The method to get the status Returns: Choice: An instance of Choice """ return self.__status def set_status(self, status): """ The method to set the value to status Parameters: status (Choice) : An instance of Choice """ if status is not None and not isinstance(status, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: status EXPECTED TYPE: Choice', None, None) self.__status = status self.__key_modified['status'] = 1 def get_message(self): """ The method to get the message Returns: Choice: An instance of Choice """ return self.__message def set_message(self, message): """ The method to set the value to message Parameters: message (Choice) : An instance of Choice """ if message is not None and not isinstance(message, Choice): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: message EXPECTED TYPE: Choice', None, None) self.__message = message self.__key_modified['message'] = 1 def get_details(self): """ The method to get the details Returns: dict: An instance of dict """ return self.__details def set_details(self, details): """ The method to set the value to details Parameters: details (dict) : An instance of dict """ if details is not None and not isinstance(details, dict): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: details EXPECTED TYPE: dict', None, None) self.__details = details self.__key_modified['details'] = 1 def is_key_modified(self, key): """ The method to check if the user has modified the given key Parameters: key (string) : A string representing the key Returns: int: An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if key in self.__key_modified: return self.__key_modified.get(key) return None def set_key_modified(self, key, modification): """ The method to mark the given key as modified Parameters: key (string) : A string representing the key modification (int) : An int representing the modification """ if key is not None and not isinstance(key, str): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: key EXPECTED TYPE: str', None, None) if modification is not None and not isinstance(modification, int): raise SDKException(Constants.DATA_TYPE_ERROR, 'KEY: modification EXPECTED TYPE: int', None, None) self.__key_modified[key] = modification
zohocrmsdk2-1
/zohocrmsdk2_1-2.0.0.tar.gz/zohocrmsdk2_1-2.0.0/zcrmsdk/src/com/zoho/crm/api/variable_groups/api_exception.py
api_exception.py