Beispiel #1
0
    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:
                ModuleFieldsHandler.__delete_fields(module)
                Utility.get_fields(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 + module +
                    sdk_exception.__str__())
                raise sdk_exception
Beispiel #2
0
    def update_record(self, id, module_api_name, request):
        """
		The method to update record

		Parameters:
			id (int) : An int representing the id
			module_api_name (string) : A string representing the module_api_name
			request (BodyWrapper) : An instance of BodyWrapper

		Returns:
			APIResponse: An instance of APIResponse

		Raises:
			SDKException
		"""

        try:
            from zcrmsdk.src.com.zoho.crm.api.record.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 not isinstance(module_api_name, str):
            raise SDKException(Constants.DATA_TYPE_ERROR,
                               'KEY: module_api_name 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/'
        api_path = api_path + str(module_api_name)
        api_path = api_path + '/'
        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)
        Utility.get_fields(module_api_name)
        handler_instance.set_module_api_name(module_api_name)
        try:
            from zcrmsdk.src.com.zoho.crm.api.record.action_handler import ActionHandler
        except Exception:
            from .action_handler import ActionHandler
        return handler_instance.api_call(ActionHandler.__module__,
                                         'application/json')
Beispiel #3
0
    def get_records(self,
                    module_api_name,
                    param_instance=None,
                    header_instance=None):
        """
		The method to get records

		Parameters:
			module_api_name (string) : A string representing the module_api_name
			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(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)

        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/'
        api_path = api_path + str(module_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.set_param(param_instance)
        handler_instance.set_header(header_instance)
        Utility.get_fields(module_api_name)
        handler_instance.set_module_api_name(module_api_name)
        try:
            from zcrmsdk.src.com.zoho.crm.api.record.response_handler import ResponseHandler
        except Exception:
            from .response_handler import ResponseHandler
        return handler_instance.api_call(ResponseHandler.__module__,
                                         'application/json')
Beispiel #4
0
    def mass_update_records(self, module_api_name, request):
        """
		The method to mass update records

		Parameters:
			module_api_name (string) : A string representing the module_api_name
			request (MassUpdateBodyWrapper) : An instance of MassUpdateBodyWrapper

		Returns:
			APIResponse: An instance of APIResponse

		Raises:
			SDKException
		"""

        try:
            from zcrmsdk.src.com.zoho.crm.api.record.mass_update_body_wrapper import MassUpdateBodyWrapper
        except Exception:
            from .mass_update_body_wrapper import MassUpdateBodyWrapper

        if not isinstance(module_api_name, str):
            raise SDKException(Constants.DATA_TYPE_ERROR,
                               'KEY: module_api_name EXPECTED TYPE: str', None,
                               None)

        if request is not None and not isinstance(request,
                                                  MassUpdateBodyWrapper):
            raise SDKException(
                Constants.DATA_TYPE_ERROR,
                'KEY: request EXPECTED TYPE: MassUpdateBodyWrapper', None,
                None)

        handler_instance = CommonAPIHandler()
        api_path = ''
        api_path = api_path + '/crm/v2/'
        api_path = api_path + str(module_api_name)
        api_path = api_path + '/actions/mass_update'
        handler_instance.set_api_path(api_path)
        handler_instance.set_http_method(Constants.REQUEST_METHOD_POST)
        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)
        Utility.get_fields(module_api_name)
        handler_instance.set_module_api_name(module_api_name)
        try:
            from zcrmsdk.src.com.zoho.crm.api.record.mass_update_action_handler import MassUpdateActionHandler
        except Exception:
            from .mass_update_action_handler import MassUpdateActionHandler
        return handler_instance.api_call(MassUpdateActionHandler.__module__,
                                         'application/json')
Beispiel #5
0
    def convert_lead(self, id, request):
        """
		The method to convert lead

		Parameters:
			id (int) : An int representing the id
			request (ConvertBodyWrapper) : An instance of ConvertBodyWrapper

		Returns:
			APIResponse: An instance of APIResponse

		Raises:
			SDKException
		"""

        try:
            from zcrmsdk.src.com.zoho.crm.api.record.convert_body_wrapper import ConvertBodyWrapper
        except Exception:
            from .convert_body_wrapper import ConvertBodyWrapper

        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, ConvertBodyWrapper):
            raise SDKException(
                Constants.DATA_TYPE_ERROR,
                'KEY: request EXPECTED TYPE: ConvertBodyWrapper', None, None)

        handler_instance = CommonAPIHandler()
        api_path = ''
        api_path = api_path + '/crm/v2/Leads/'
        api_path = api_path + str(id)
        api_path = api_path + '/actions/convert'
        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)
        Utility.get_fields("Deals")
        try:
            from zcrmsdk.src.com.zoho.crm.api.record.convert_action_handler import ConvertActionHandler
        except Exception:
            from .convert_action_handler import ConvertActionHandler
        return handler_instance.api_call(ConvertActionHandler.__module__,
                                         'application/json')
Beispiel #6
0
    def get_all_contact_roles_of_deal(self, deal_id, param_instance=None):
        """
		The method to get all contact roles of deal

		Parameters:
			deal_id (int) : An int representing the deal_id
			param_instance (ParameterMap) : An instance of ParameterMap

		Returns:
			APIResponse: An instance of APIResponse

		Raises:
			SDKException
		"""

        if not isinstance(deal_id, int):
            raise SDKException(Constants.DATA_TYPE_ERROR,
                               'KEY: deal_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/Deals/'
        api_path = api_path + str(deal_id)
        api_path = api_path + '/Contact_Roles'
        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_module_api_name("Contacts")
        Utility.get_fields("Contacts", handler_instance)
        try:
            from zcrmsdk.src.com.zoho.crm.api.contact_roles.record_response_handler import RecordResponseHandler
        except Exception:
            from .record_response_handler import RecordResponseHandler
        return handler_instance.api_call(RecordResponseHandler.__module__,
                                         'application/json')