Esempio n. 1
0
    def get_content(self, attachment_id: str, headers: dict = None) -> bytes:
        """get_content returns None on success and raises an exception if the attachment couldn't be deleted"""

        return self.__client.download(
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  attachment_id),
            self.__client.get_basic_headers())
Esempio n. 2
0
    def get_projects(self, params: dict = None) -> dict:
        """get_projects returns a dict with project objects"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint, params),
            self.__client.get_basic_headers_for_json())
Esempio n. 3
0
    def get_webhook(self, webhook_id: str) -> dict:
        """get_webhook returns the referenced (id) webhook"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  webhook_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 4
0
    def delete_project(self, project_id: str) -> None:
        """delete_project returns None on success and raises an exception if the project couldn't be deleted"""

        self.__client.call(
            "DELETE",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  project_id),
            self.__client.get_basic_headers())
Esempio n. 5
0
    def get_project(self, project_id: str) -> dict:
        """get_project returns the referenced (id) project"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  project_id),
            self.__client.get_basic_headers_for_json())
    def get_serial_number(self, serial_number_id: str) -> dict:
        """get_serial_number returns the referenced (id) serial number"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  serial_number_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 7
0
    def get_contacts(self, customer_id: str, params: dict = None) -> dict:
        """get_contacts returns a dict with contact objects for the referenced customer"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(
                self.__endpoint + "/" + customer_id + "/" + "contacts",
                params), self.__client.get_basic_headers_for_json())
Esempio n. 8
0
    def update_attachment(self, attachment_id: str, payload: dict) -> dict:
        """update_attachment updates the reference (id) attachment with the given payload. Returns a part of the updated attachment model"""

        return self.__client.call(
            "PUT",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  attachment_id),
            self.__client.get_basic_headers_for_json(), payload)
Esempio n. 9
0
    def update_webhook(self, webhook_id: str, payload: dict) -> dict:
        """update_webhook updates the reference (id) webhook with the given payload. Returns the updated webhook model"""

        return self.__client.call(
            "PUT",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  webhook_id),
            self.__client.get_basic_headers_for_json(), payload)
Esempio n. 10
0
    def get_customer_group(self, customer_group_id: str) -> dict:
        """get_customer_group returns the referenced (id) customer group"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  customer_group_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 11
0
    def get_login(self, login_id: str) -> dict:
        """get_login returns the referenced (id) login"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  login_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 12
0
    def update_project(self, project_id: str, payload: dict) -> dict:
        """update_project updates the reference (id) project with the given payload. Returns the updated project model"""

        return self.__client.call(
            "PUT",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  project_id),
            self.__client.get_basic_headers_for_json(), payload)
Esempio n. 13
0
    def get_text_template(self, text_template_id: str) -> dict:
        """get_text_template returns the referenced (id) text template"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  text_template_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 14
0
    def update_customer(self, customer_id: str, payload: dict) -> dict:
        """update_customer updates the reference (id) customer with the given payload. Returns the updated customer model"""

        return self.__client.call(
            "PUT",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  customer_id),
            self.__client.get_basic_headers_for_json(), payload)
Esempio n. 15
0
    def delete_serial_number(self, serial_number_id: str) -> None:
        """delete_serial_number returns None on success and raises an exception if the serial number couldn't be deleted"""

        self.__client.call(
            "DELETE",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  serial_number_id),
            self.__client.get_basic_headers())
Esempio n. 16
0
    def delete_customer_group(self, customer_group_id: str) -> None:
        """delete_customer_group returns None on success and raises an exception if the customer-group couldn't be deleted"""

        self.__client.call(
            "DELETE",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  customer_group_id),
            self.__client.get_basic_headers())
Esempio n. 17
0
    def create_contact(self, customer_id: str, payload: dict) -> dict:
        """create_contact returns the contact model as dict on success with the data from the passed payload for the referenced customer"""

        return self.__client.call(
            "POST",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  customer_id + "/" +
                                                  "contacts"),
            self.__client.get_basic_headers_for_json(), payload)
Esempio n. 18
0
    def update_text_template(self, text_template_id: str,
                             payload: dict) -> dict:
        """update_text_template updates the reference (id) task with the given payload. Returns the updated text template model"""

        return self.__client.call(
            "PUT",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  text_template_id),
            self.__client.get_basic_headers_for_json(), payload)
Esempio n. 19
0
    def get_position_group_discount(self,
                                    position_group_discount_id: str) -> dict:
        """get_position_group_discount returns the referenced (id) position group discount"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  position_group_discount_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 20
0
    def create_stock(self, payload: dict) -> dict:
        """create_stock returns the stock model as dict on success with the data from the passed payload"""

        return self.__client.call(
            "POST",
            Helper.create_request_url_from_params(self.__endpoint),
            self.__client.get_basic_headers_for_json(),
            payload
        )
Esempio n. 21
0
    def get_time_tracking(self, time_tracking_id: str) -> dict:
        """get_time_tracking returns the referenced (id) time tracking"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(
                self.__endpoint +
                "/" +
                time_tracking_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 22
0
    def get_contact(self, customer_id: str, contact_id: str) -> dict:
        """get_contact returns the referenced (id) contact for the referenced customer"""

        return self.__client.call(
            "GET",
            Helper.create_request_url_from_params(self.__endpoint + "/" +
                                                  customer_id + "/" +
                                                  "contacts" + "/" +
                                                  contact_id),
            self.__client.get_basic_headers_for_json())
Esempio n. 23
0
    def download_document(self, document_id: str) -> bytes:
        """download_document returns the document as bytes on success"""

        return self.__client.download(
            Helper.create_request_url_from_params(
                self.__endpoint +
                "/" +
                document_id +
                "/pdf"),
            self.__client.get_basic_headers_for_pdf(),
        )
Esempio n. 24
0
    def cancel_document(self, document_id: str) -> dict:
        """cancel_document returns the canceled document on success"""

        return self.__client.call(
            "POST",
            Helper.create_request_url_from_params(
                self.__endpoint +
                "/" +
                document_id +
                "/cancel"),
            self.__client.get_basic_headers_for_json())
Esempio n. 25
0
    def finalize_document(self, document_id: str) -> dict:
        """finalize_document returns the finalized document on success"""

        return self.__client.call(
            "PUT",
            Helper.create_request_url_from_params(
                self.__endpoint +
                "/" +
                document_id +
                "/done"),
            self.__client.get_basic_headers_for_json())
Esempio n. 26
0
    def update_time_tracking(
            self,
            time_tracking_id: str,
            payload: dict) -> dict:
        """update_task updates the reference (id) time tracking with the given payload. Returns the updated time tracking model"""

        return self.__client.call(
            "PUT",
            Helper.create_request_url_from_params(
                self.__endpoint +
                "/" +
                time_tracking_id),
            self.__client.get_basic_headers_for_json(),
            payload)
Esempio n. 27
0
    def send_document(
            self,
            document_id: str,
            send_method: SendMethod,
            payload: dict) -> None:
        """send_document returns None on success and rises exception on failure"""

        self.__client.call(
            "POST",
            Helper.create_request_url_from_params(
                self.__endpoint +
                "/" +
                document_id +
                "/send/" +
                str(send_method)),
            self.__client.get_basic_headers_for_json(),
            payload)
Esempio n. 28
0
    def create_attachment(self, payload: bytes) -> dict:
        """create_attachment returns the attachment model as dict on success with the data from the passed payload"""

        return self.__client.upload(
            Helper.create_request_url_from_params(self.__endpoint),
            self.__client.get_basic_headers(), payload)
Esempio n. 29
0
 def test_create_request_url_from_params_with_payload(self):
     result = Helper.create_request_url_from_params("/test", {"id": 23})
     self.assertTrue(True if result.find("/rest/v1/") > -1 else False)
     self.assertTrue(True if result.find("23") > -1 else False)
     self.assertTrue(True if result.find("/test") > -1 else False)
Esempio n. 30
0
    def delete_time_tracking(self, task_id: str) -> None:
        """delete_time_tracking returns None on success and raises an exception if the time tracking couldn't be deleted"""

        self.__client.call("DELETE", Helper.create_request_url_from_params(
            self.__endpoint + "/" + task_id), self.__client.get_basic_headers())