예제 #1
0
    def get_related_records(self, param_instance=None, header_instance=None):
        """
		The method to get related records

		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/'
        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 + '/'
        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.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_record(self, related_record_id, request):
		"""
		The method to update related record

		Parameters:
			related_record_id (int) : An int representing the related_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 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(self.__module_api_name)
		api_path = api_path + '/'
		api_path = api_path + str(self.__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)
		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')