Example #1
0
    def get_api_response(self):
        try:
            self.authenticate_request()
            connector = HTTPConnector.get_instance(self.url, self.request_params, self.request_headers,
                                                   self.request_body, self.request_method)
            # Attachments are handled here
            if self.request_files is not None:
                try:
                    from controllers.Utility import CommonUtil
                except ImportError:
                    from .Utility import CommonUtil
                attachments = CommonUtil.create_api_supported_attachments_dictionary(self.request_files)
                connector.set_file(attachments)

            response = connector.trigger_request()

            try:
                if "application/json" in response.headers["Content-Type"] or "text/" in response.headers[
                    "Content-Type"]:
                    return APIResponse(response, response.status_code, self.url)
                else:
                    return FileAPIResponse(response, response.status_code, self.url)
            except KeyError:
                return APIResponse(response, response.status_code, self.url)
        except ZOIException as ex:
            raise ex
        except Exception as ex:
            try:
                from controllers.Utility import CommonUtil
            except ImportError:
                from .Utility import CommonUtil
            import traceback
            CommonUtil.raise_exception(self.url, str(ex), traceback.format_stack())
Example #2
0
    def set_bulk_permissions(self, document_export=None, document_print=None, document_edit=None,
                             review_changes_resolve=None, review_comment=None, collab_chat=None,
                             document_pausecollaboration=None, document_fill=None):

        # If Settings are passed as a list with preferred settings
        if isinstance(document_export, dict):
            self.permissions = document_export

        # If Settings are individually passed as separate arguments
        else:
            if self.permissions is None:
                self.permissions = dict()
            if document_export is not None:
                self.permissions["document.export"] = CommonUtil.true_false_utility(document_export)
            if document_print is not None:
                self.permissions["document.print"] = CommonUtil.true_false_utility(document_print)
            if document_edit is not None:
                self.permissions["document.edit"] = CommonUtil.true_false_utility(document_edit)
            if review_changes_resolve is not None:
                self.permissions["review.changes.resolve"] = CommonUtil.true_false_utility(review_changes_resolve)
            if review_comment is not None:
                self.permissions["review.comment"] = CommonUtil.true_false_utility(review_comment)
            if collab_chat is not None:
                self.permissions["collab.chat"] = CommonUtil.true_false_utility(collab_chat)
            if document_pausecollaboration is not None:
                self.permissions["document.pausecollaboration"] = CommonUtil.true_false_utility(
                    document_pausecollaboration)
            if document_fill is not None:
                self.permissions["document.fill"] = CommonUtil.true_false_utility(document_fill)
Example #3
0
    def set_bulk_permissions(self, document_export=None, document_print=None, document_edit=None):

        # If Settings are passed as a list with preferred settings
        if isinstance(document_export, dict):
            self.permissions = document_export

        # If Settings are individually passed as separate arguments
        else:
            if self.permissions is None:
                self.permissions = dict()
            if document_export is not None:
                self.permissions["document.export"] = CommonUtil.true_false_utility(document_export)
            if document_print is not None:
                self.permissions["document.print"] = CommonUtil.true_false_utility(document_print)
            if document_edit is not None:
                self.permissions["document.edit"] = CommonUtil.true_false_utility(document_edit)
Example #4
0
    def delete_request_handler(self):
        try:
            api_handler_init = APIHandler()

            api_handler_init.request_api_end_point = self.editor_obj.api_end_point
            api_handler_init.request_method = APIConstants.REQUEST_METHOD_DELETE

            api_handler_init.request_params = CommonUtil.create_api_supported_input_json(
                ZOIConfigUtil.get_api_key())

            api_response = APIRequest(api_handler_init).get_api_response()
            api_response.data = self.editor_obj
            return api_response
        except ZOIException as ex:
            raise ex
Example #5
0
    def sheet_show_request_handler(self):
        try:
            api_handler_init = APIHandler()

            api_handler_init.request_api_end_point = self.editor_obj.api_end_point
            api_handler_init.request_method = APIConstants.REQUEST_METHOD_POST

            input_json = self.get_sheet_show_object_as_json()

            api_handler_init.request_body = CommonUtil.create_api_supported_input_json(
                ZOIConfigUtil.get_api_key(), input_json)
            if self.editor_obj.document is not None:
                api_handler_init.request_files = self.editor_obj.document

            api_response = APIRequest(api_handler_init).get_api_response()
            api_response.data = self.editor_obj
            return api_response
        except ZOIException as ex:
            raise ex
Example #6
0
 def set_permissions(self, key, value):
     if self.permissions is None:
         self.permissions = dict()
     self.permissions[key] = CommonUtil.true_false_utility(value)