Ejemplo n.º 1
0
    def fax_message_pdf(self, fax_id, email):
        """
        Send a Fax Message attached as a PDF file to an email destination

        :param fax_id: [Required] ID of the Fax Message requested (Values from fax.get_fax_messages)
        :type fax_id: :py:class:`int`
        :param email: [Required] Destination email address (example: [email protected])
        :type email: :py:class:`str`

        :returns: :py:class:`dict`
        """
        method = "mailFaxMessagePDF"

        if not isinstance(fax_id, int):
            raise ValueError("ID of the Fax Message requested needs to be an int (Values from fax.get_fax_messages)")

        if not isinstance(email, str):
            raise ValueError("Destination email address needs to be a str(example: [email protected])")
        elif not validate_email(email):
                raise ValueError("Destination email address is not a correct email syntax")

        parameters = {
            "id": fax_id,
            "email": email,
        }

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 2
0
    def fax_number_email(self, did, **kwargs):
        """
        Updates the email configuration from a specific Fax Number

        :param did: [Required] DID Number to be ported into our network (Example: 5552341234)
        :type did: :py:class:`int`

        :param email: Email address where send notifications when receive Fax Messages (Example: [email protected])
        :type email: :py:class:`str`
        :param email_enable: Flag to enable the email notifications (True/False default False)
        :type email_enable: :py:class:`bool`
        :param email_attach_file: Flag to enable attach the Fax Message as a PDF file in the notifications (True/False default False)
        :type email_attach_file: :py:class:`bool`
        :param test: Set to true if testing how cancel a Fax Folder (True/False)
        :type test: :py:class:`bool`

        :returns: :py:class:`dict`
        """
        method = "setFaxNumberEmail"

        if not isinstance(did, int):
            raise ValueError("DID Number to be ported into our network needs to be an int (Example: 5552341234)")

        parameters = {
            "did": did,
        }

        if "email" in kwargs:
            email = kwargs.pop("email")
            if not isinstance(email, str):
                raise ValueError("Email address where send notifications when receive Fax Messages needs to be a str (Example: [email protected])")
            elif not validate_email(email):
                raise ValueError("Email address where send notifications when receive Fax Messages is not a correct email syntax")
            parameters["email"] = email

        if "email_enabled" in kwargs:
            if not isinstance(kwargs["email_enabled"], bool):
                raise ValueError("Flag to enable the email notifications needs to be a bool (True/False default False)")
            parameters["email_enabled"] = convert_bool(kwargs.pop("email_enabled"))

        if "email_attach_file" in kwargs:
            if not isinstance(kwargs["email_attach_file"], bool):
                raise ValueError("Flag to enable attach the Fax Message as a PDF file in the notifications needs to be a bool (True/False default False)")
            parameters["email_attach_file"] = convert_bool(kwargs.pop("email_attach_file"))

        if "test" in kwargs:
            if not isinstance(kwargs["test"], bool):
                raise ValueError("Set to true if testing how cancel a Fax Folder needs to be a bool (True/False)")
            else:
                parameters["test"] = convert_bool(kwargs.pop("test"))

        if len(kwargs) > 0:
            not_allowed_parameters = ""
            for key, value in kwargs.items():
                not_allowed_parameters += key + " "
            raise ValueError("Parameters not allowed: {}".format(not_allowed_parameters))

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 3
0
    def client_threshold(self, client, threshold, email=None):
        """
        Update the Threshold Amount for a specific Reseller Client

        - Update the Threshold notification e-mail for a specific Reseller Client if the e-mail address is provided

        :param client: [Required] ID for a specific Reseller Client (Example: 561115)
        :type client: :py:class:`int`
        :param threshold: [Required] Threshold amount between 1 and 250 (Example: 10)
        :type threshold: :py:class:`int`
        :param email: Client's e-mail for balance threshold notification
        :type email: :py:class:`str`
        :returns: :py:class:`dict`
        """
        method = "setClientThreshold"

        if not isinstance(client, int):
            raise ValueError(
                "ID for a specific Reseller Client needs to be an int (Example: 561115)"
            )

        if not isinstance(threshold, int):
            raise ValueError(
                "Threshold amount between 1 and 250 needs to be an int (Example: 10)"
            )
        else:
            if not 1 <= threshold <= 250:
                raise ValueError(
                    "Threshold amount needs to be between 1 and 250")

        parameters = {
            "client": client,
            "threshold": threshold,
        }

        if email:
            if not isinstance(email, str):
                raise ValueError(
                    "Client's e-mail for balance threshold notification needs to be a str"
                )
            else:
                if not validate_email(email):
                    raise ValueError(
                        "Client's e-mail is not a correct email syntax")
                else:
                    parameters["email"] = email

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 4
0
    def voicemail_email(self, mailbox, folder, message_num, email_address):
        """
        Move Voicemail Message to a Destination Folder

        :param mailbox: [Required] ID for a specific Mailbox (Example: 1001)
        :type mailbox: :py:class:`int`
        :param folder: [required] Name for specific Folder (Required if message id is passed, Example: 'INBOX', values from: voicemail.get_voicemail_folders)
        :type folder: :py:class:`str`
        :param message_num: [required] ID for specific Voicemail Message (Required if folder is passed, Example: 1)
        :type message_num: :py:class:`int`
        :param email_address: [required] Destination Email address (Example: [email protected])
        :type email_address: :py:class:`str`

        :returns: :py:class:`dict`
        """
        method = "sendVoicemailEmail"

        if not isinstance(mailbox, int):
            raise ValueError(
                "ID for a specific Mailbox needs to be an int (Example: 1001)")

        if not isinstance(folder, str):
            raise ValueError(
                "Name for specific Folder needs to be a str (Required if message id is passed, Example: 'INBOX', values from: voicemail.get_voicemail_folders)"
            )

        if not isinstance(message_num, int):
            raise ValueError(
                "ID for specific Voicemail Message needs to be an int (Required if folder is passed, Example: 1)"
            )

        if not isinstance(email_address, str):
            raise ValueError(
                "Destination Email address needs to be a str (Example: [email protected])"
            )
        elif not validate_email(email_address):
            raise ValueError(
                "Destination Email address is not a correct email syntax")

        parameters = {
            "mailbox": mailbox,
            "folder": folder,
            "message_num": message_num,
            "email_address": email_address,
        }

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 5
0
    def fax_number(self, location, quantity, **kwargs):
        """
        Orders and Adds a new Fax Number to the Account

        :param location: [Required] Location ID of the Fax Number (Values from fax.get_fax_rate_centers_can/fax.get_fax_rate_centers_usa)
        :type location: :py:class:`int`
        :param quantity: [Required] Quantity of Fax Numbers to order (Example: 3)
        :type quantity: :py:class:`int`

        :param email: Email address where send notifications when receive Fax Messages (Example: [email protected])
        :type email: :py:class:`str`
        :param email_enable: Flag to enable the email notifications (True/False default False)
        :type email_enable: :py:class:`bool`
        :param email_attach_file: Flag to enable attach the Fax Message as a PDF file in the notifications (True/False default False)
        :type email_attach_file: :py:class:`bool`
        :param url_callback: URL where make a POST when you receive a Fax Message
        :type url_callback: :py:class:`str`
        :param url_callback_enable: Flag to enable the URL Callback functionality (True/False default False)
        :type url_callback_enable: :py:class:`bool`
        :param url_callback_retry: Flag to enable retry the POST action in case we don't receive "ok" (True/False default False)
        :type url_callback_retry: :py:class:`bool`
        :param test: Set to true if testing how cancel a Fax Folder (True/False)
        :type test: :py:class:`bool`

        :returns: :py:class:`dict`
        """
        method = "orderFaxNumber"

        if not isinstance(location, int):
            raise ValueError(
                "Location ID of the Fax Number needs to be an int (Values from fax.get_fax_rate_centers_can/fax.get_fax_rate_centers_usa)"
            )

        if not isinstance(quantity, int):
            raise ValueError(
                "Quantity of Fax Numbers to order needs to be an int (Example: 3)"
            )

        parameters = {
            "location": location,
            "quantity": quantity,
        }

        if "email" in kwargs:
            email = kwargs.pop("email")
            if not isinstance(email, str):
                raise ValueError(
                    "Email address where send notifications when receive Fax Messages needs to be a str (Example: [email protected])"
                )
            elif not validate_email(email):
                raise ValueError(
                    "Email address where send notifications when receive Fax Messages is not a correct email syntax"
                )
            parameters["email"] = email

        if "email_enabled" in kwargs:
            if not isinstance(kwargs["email_enabled"], bool):
                raise ValueError(
                    "Flag to enable the email notifications needs to be a bool (True/False default False)"
                )
            parameters["email_enabled"] = convert_bool(
                kwargs.pop("email_enabled"))

        if "email_attach_file" in kwargs:
            if not isinstance(kwargs["email_attach_file"], bool):
                raise ValueError(
                    "Flag to enable attach the Fax Message as a PDF file in the notifications needs to be a bool (True/False default False)"
                )
            parameters["email_attach_file"] = convert_bool(
                kwargs.pop("email_attach_file"))

        if "url_callback" in kwargs:
            if not isinstance(kwargs["url_callback"], str):
                raise ValueError(
                    "URL where make a POST when you receive a Fax Message needs to be a str"
                )
            parameters["url_callback"] = convert_bool(
                kwargs.pop("url_callback"))

        if "url_callback_enable" in kwargs:
            if not isinstance(kwargs["url_callback_enable"], bool):
                raise ValueError(
                    "Flag to enable the URL Callback functionality needs to be a bool (True/False default False)"
                )
            parameters["url_callback_enable"] = convert_bool(
                kwargs.pop("url_callback_enable"))

        if "url_callback_retry" in kwargs:
            if not isinstance(kwargs["url_callback_retry"], bool):
                raise ValueError(
                    "Flag to enable retry the POST action in case we don't receive \"ok\" (True/False default False)"
                )
            parameters["url_callback_retry"] = convert_bool(
                kwargs.pop("url_callback_retry"))

        if "test" in kwargs:
            if not isinstance(kwargs["test"], bool):
                raise ValueError(
                    "Set to true if testing how cancel a Fax Folder needs to be a bool (True/False)"
                )
            else:
                parameters["test"] = convert_bool(kwargs.pop("test"))

        if len(kwargs) > 0:
            not_allowed_parameters = ""
            for key, value in kwargs.items():
                not_allowed_parameters += key + " "
            raise ValueError(
                "Parameters not allowed: {}".format(not_allowed_parameters))

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 6
0
    def fax_message(self, to_number, from_name, from_number, file, **kwargs):
        """
        Send a Fax message to a Destination Number

        :param to_number: [Required] Destination DID Number (Example: 5552341234)
        :type to_number: :py:class:`int`
        :param from_name: [Required] Name of the sender
        :type from_name: :py:class:`str`
        :param from_number: [Required] DID number of the Fax sender (Example: 5552341234)
        :type from_number: :py:class:`int`
        :param file: [Required] The file must be encoded in Base64 and in one of the following formats: pdf, txt, jpg, gif, png, tif
        :type file: :py:class:`str`

        :param send_email_enabled: Flag to enable the send of a copy of your Fax via email (True/False default False)
        :type send_email_enabled: :py:class:`bool`
        :param send_email: Email address where you want send a copy of your Fax.
        :type send_email: :py:class:`str`
        :param station_id: A word to identify a equipment or department sending the Fax
        :type station_id: :py:class:`str`
        :param test: Set to true if testing how cancel a Fax Folder (True/False)
        :type test: :py:class:`bool`

        :returns: :py:class:`dict`
        """
        method = "sendFaxMessage"

        if not isinstance(to_number, int):
            raise ValueError("Destination DID Number needs to be an int (Example: 5552341234)")

        if not isinstance(from_name, str):
            raise ValueError("Name of the sender  needs to be a str")

        if not isinstance(from_number, int):
            raise ValueError("DID number of the Fax sender needs to be an int (Example: 5552341234)")

        if not isinstance(file, str):
            raise ValueError("The file must be encoded in Base64 and in one of the following formats: pdf, txt, jpg, gif, png, tif and needs to be a str")

        parameters = {
            "to_number": to_number,
            "from_name": from_name,
            "from_number": from_number,
            "file": file,
        }

        if "send_email_enabled" in kwargs:
            if not isinstance(kwargs["send_email_enabled"], bool):
                raise ValueError("Flag to enable the send of a copy of your Fax via email needs to be a bool (True/False default False)")
            parameters["send_email_enabled"] = convert_bool(kwargs.pop("send_email_enabled"))

        if "send_email" in kwargs:
            send_email = kwargs.pop("send_email")
            if not isinstance(send_email, str):
                raise ValueError("Email address where you want send a copy of your Fax needs to be a str (Example: [email protected])")
            elif not validate_email(send_email):
                raise ValueError("Email address where you want send a copy of your Fax is not a correct email syntax")
            parameters["send_email"] = send_email

        if "station_id" in kwargs:
            if not isinstance(kwargs["station_id"], str):
                raise ValueError("A word to identify a equipment or department sending the Fax needs to be a str")
            parameters["station_id"] = kwargs.pop("station_id")

        if "test" in kwargs:
            if not isinstance(kwargs["test"], bool):
                raise ValueError("Set to true if testing how cancel a Fax Folder needs to be a bool (True/False)")
            else:
                parameters["test"] = convert_bool(kwargs.pop("test"))

        if len(kwargs) > 0:
            not_allowed_parameters = ""
            for key, value in kwargs.items():
                not_allowed_parameters += key + " "
            raise ValueError("Parameters not allowed: {}".format(not_allowed_parameters))

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 7
0
    def client(self, firstname, lastname, address, city, state, country,
               zip_code, phone_number, email, confirm_email, password,
               confirm_password, **kwargs):
        """
        Signs a new Reseller Client to your Reseller Account

        :param firstname: [Required] Client's Firstname
        :type firstname: :py:class:`str`
        :param lastname: [Required] Client's Lastname
        :type lastname: :py:class:`str`
        :param address: Client's Address
        :type address: :py:class:`str`
        :param city: Client's City
        :type city: :py:class:`str`
        :param state: Client's State
        :type state: :py:class:`str`
        :param country: Client's Country (Values from general.get_countries)
        :type country: :py:class:`str`
        :param zip_code: Client's Zip Code
        :type zip_code: :py:class:`str`
        :param phone_number: [Required] Client's Phone Number
        :type phone_number: :py:class:`str`
        :param email: [Required] Client's e-mail
        :type email: :py:class:`str`
        :param confirm_email: [Required] Client's Confirmation e-mail
        :type confirm_email: :py:class:`str`
        :param password: [Required] Client's Password
        :type password: :py:class:`str`
        :param confirm_password: [Required] Client's Password
        :type confirm_password: :py:class:`str`
        :param **kwargs: All optional parameters
        :type **kwargs: :py:class:`dict`

        :param company: Client's Company
        :type company: :py:class:`str`
        :param activate: Activates Client (Boolean: True/False)
        :type activate: :py:class:`bool`
        :param balance_management: Balance Management for Client (Values from clients.get_balance_management)
        :type balance_management: :py:class:`str`

        :returns: :py:class:`dict`
        """
        method = "signupClient"

        if not isinstance(firstname, str):
            raise ValueError("Client's Firstname needs to be a str")

        if not isinstance(lastname, str):
            raise ValueError("Client's Lastname needs to be a str")

        if not isinstance(address, str):
            raise ValueError("Client's Address needs to be a str")

        if not isinstance(city, str):
            raise ValueError("Client's City needs to be a str")

        if not isinstance(state, str):
            raise ValueError("Client's State needs to be a str")

        if not isinstance(country, str):
            raise ValueError(
                "Client's Country needs to be a str (Values from general.get_countries)"
            )

        if not isinstance(zip_code, str):
            raise ValueError("Client's Zip Code needs to be a str")

        if not isinstance(phone_number, str):
            raise ValueError("Client's Phone Number needs to be a str")

        if not isinstance(email, str):
            raise ValueError("Client's e-mail needs to be a str")
        else:
            if not validate_email(email):
                raise ValueError(
                    "Client's e-mail is not a correct email syntax")

        if not isinstance(confirm_email, str):
            raise ValueError("Client's Confirmation e-mail needs to be a str")
        else:
            if not validate_email(confirm_email):
                raise ValueError(
                    "Client's Confirmation e-mail is not a correct email syntax"
                )

        if email != confirm_email:
            raise ValueError("The two provided e-mails do not match")

        if not isinstance(password, str):
            raise ValueError("Client's Password needs to be a str")

        if not isinstance(confirm_password, str):
            raise ValueError(
                "Client's Confirmation Password needs to be a str")

        if password != confirm_password:
            raise ValueError("The two provided passwords do not match")

        parameters = {
            "firstname": firstname,
            "lastname": lastname,
            "address": address,
            "city": city,
            "state": state,
            "country": country,
            "zip": zip_code,
            "phone_number": phone_number,
            "email": email,
            "confirm_email": confirm_email,
            "password": password,
            "confirm_password": confirm_password,
        }

        if "activate" in kwargs:
            if not isinstance(kwargs["activate"], bool):
                raise ValueError("Activates Client needs to be a bool")
            parameters["activate"] = convert_bool(kwargs.pop("activate"))

        if "balance_management" in kwargs:
            if not isinstance(kwargs["balance_management"], str):
                raise ValueError(
                    "Balance Management for Client (Values from clients.get_balance_management)"
                )
            parameters["balance_management"] = kwargs.pop("balance_management")

        if len(kwargs) > 0:
            not_allowed_parameters = ""
            for key, value in kwargs.items():
                not_allowed_parameters += key + " "
            raise ValueError(
                "Parameters not allowed: {}".format(not_allowed_parameters))

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 8
0
    def voicemail(self, digits, name, password, skip_password, attach_message, delete_message,
                  say_time, timezone, say_callerid, play_instructions, language, **kwargs):
        """
        Adds a new Voicemail entry to your Account

        :param digits: [Required] Digits used to create the voicemail (Example: 01) Minimum 1 digit, maximum 10 digits
        :type digits: :py:class:`int`
        :param name: [Required] Name for the Mailbox
        :type name: :py:class:`str`
        :param password: [Required] Password for the Mailbox
        :type password: :py:class:`int`
        :param skip_password: [Required] True if Skipping Password (True/False)
        :type skip_password: :py:class:`bool`
        :param attach_message: [Required] Yes for Attaching WAV files to Message (Values: 'yes'/'no')
        :type attach_message: :py:class:`str`
        :param delete_message: [Required] Yes for Deleting Messages (Values: 'yes'/'no')
        :type delete_message: :py:class:`str`
        :param say_time: [Required] Yes for Saying Time Stamp (Values: 'yes'/'no')
        :type say_time: :py:class:`str`
        :param timezone: [Required] Time Zone for Mailbox (Values from voicemail.get_time_zones)
        :type timezone: :py:class:`str`
        :param say_callerid: [Required] Yes for Saying the Caller ID (Values: 'yes'/'no')
        :type say_callerid: :py:class:`str`
        :param play_instructions: [Required] Code for Play Instructions Setting (Values from voicemail.get_play_instructions)
        :type play_instructions: :py:class:`str`
        :param language: [Required] Code for Language (Values from general.get_languages)
        :type language: :py:class:`str`

        :param email: Client's e-mail address for receiving Messages
        :type email: :py:class:`str`
        :param email_attachment_format: Code for Email Attachment format (Values from voicemail.get_voicemail_attachment_formats)
        :type email_attachment_format: :py:class:`str`
        :param unavailable_message_recording: Recording for the Unavailable Message (values from dids.get_recordings)
        :type unavailable_message_recording: :py:class:`int`

        :returns: :py:class:`dict`
        """
        method = "createVoicemail"

        if not isinstance(digits, int):
            raise ValueError("Digits used to create the voicemail needs to be an int (Example: 01) Minimum 1 digit, maximum 10 digits")
        elif len(str(digits)) > 10:
            raise ValueError("Digits used to create the voicemail can only have a maximum of 10 digits")

        if not isinstance(name, str):
            raise ValueError("Name for the Mailbox needs to be a str")

        if not isinstance(password, int):
            raise ValueError("Password for the Mailbox needs to be an int")

        if not isinstance(skip_password, bool):
            raise ValueError("True if Skipping Password needs to be a bool (True/False)")

        if not isinstance(attach_message, str):
            raise ValueError("Yes for Attaching WAV files to Message needs to be a str (Values: 'yes'/'no')")
        elif attach_message not in ("yes", "no"):
            raise ValueError("Attaching WAV files to Message only allows values: 'yes'/'no'")

        if not isinstance(delete_message, str):
            raise ValueError("Yes for Deleting Messages needs to be a str (Values: 'yes'/'no')")
        elif delete_message not in ("yes", "no"):
            raise ValueError("Deleting Messages only allows values: 'yes'/'no'")

        if not isinstance(say_time, str):
            raise ValueError("Yes for Saying Time Stamp needs to be a str (Values: 'yes'/'no')")
        elif say_time not in ("yes", "no"):
            raise ValueError("Saying Time Stamp only allows values: 'yes'/'no'")

        if not isinstance(timezone, str):
            raise ValueError("Time Zone for Mailbox needs to be a str (Values from voicemail.get_time_zones)")

        if not isinstance(say_callerid, str):
            raise ValueError("Yes for Saying the Caller ID needs to be a str (Values: 'yes'/'no')")
        elif say_callerid not in ("yes", "no"):
            raise ValueError("Saying the Caller ID only allows values: 'yes'/'no'")

        if not isinstance(play_instructions, str):
            raise ValueError("Code for Play Instructions Setting needs to be a str (Values from voicemail.get_play_instructions)")

        if not isinstance(language, str):
            raise ValueError("Code for Language needs to be a str (Values from general.get_languages)")

        parameters = {
            "digits": digits,
            "name": name,
            "password": password,
            "skip_password": convert_bool(skip_password),
            "attach_message": attach_message,
            "attach_message": attach_message,
            "delete_message": delete_message,
            "say_time": say_time,
            "timezone": timezone,
            "say_callerid": say_callerid,
            "play_instructions": play_instructions,
            "language": language,
        }

        if "email" in kwargs:
            email = kwargs.pop("email")
            if not isinstance(email, str):
                raise ValueError("Client's e-mail address for receiving Messages needs to be a str")
            elif not validate_email(email):
                raise ValueError("Client's e-mail address is not a correct email syntax")
            parameters["email"] = email

        if "email_attachment_format" in kwargs:
            if not isinstance(kwargs["email_attachment_format"], str):
                raise ValueError("Code for Email Attachment format needs to be a str (Values from voicemail.get_voicemail_attachment_formats)")
            parameters["email_attachment_format"] = kwargs.pop("email_attachment_format")

        if "unavailable_message_recording" in kwargs:
            if not isinstance(kwargs["unavailable_message_recording"], int):
                raise ValueError("Recording for the Unavailable Message needs to be an int (values from dids.get_recordings)")
            parameters["unavailable_message_recording"] = kwargs.pop("unavailable_message_recording")

        if len(kwargs) > 0:
            not_allowed_parameters = ""
            for key, value in kwargs.items():
                not_allowed_parameters += key + " "
            raise ValueError("Parameters not allowed: {}".format(not_allowed_parameters))

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 9
0
    def client(self, client, email, password, firstname, lastname,
               phone_number, **kwargs):
        """
        Updates Reseller Client information

        :param client: [Required] ID for a specific Reseller Client (Example: 561115)
        :type client: :py:class:`int`
        :param email: [Required] Client's e-mail
        :type email: :py:class:`str`
        :param password: [Required] Client's Password
        :type password: :py:class:`str`
        :param firstname: [Required] Client's Firstname
        :type firstname: :py:class:`str`
        :param lastname: [Required] Client's Lastname
        :type lastname: :py:class:`str`
        :param phone_number: [Required] Client's Phone Number
        :type phone_number: :py:class:`str`
        :param **kwargs: All optional parameters
        :type **kwargs: :py:class:`dict`

        :param company: Client's Company
        :type company: :py:class:`str`
        :param address: Client's Address
        :type address: :py:class:`str`
        :param city: Client's City
        :type city: :py:class:`str`
        :param state: Client's State
        :type state: :py:class:`str`
        :param country: Client's Country (Values from general.get_countries)
        :type country: :py:class:`str`
        :param zip: Client's Zip Code
        :type zip: :py:class:`str`
        :param balance_management: Balance Management for Client (Values from clients.get_balance_management)
        :type balance_management: :py:class:`str`

        :returns: :py:class:`dict`
        """
        method = "setClient"

        if not isinstance(client, int):
            raise ValueError(
                "ID for a specific Reseller Client needs to be in int (Example: 561115)"
            )

        if not isinstance(email, str):
            raise ValueError("Client's e-mail needs to be a str")
        else:
            if not validate_email(email):
                raise ValueError(
                    "Client's e-mail is not a correct email syntax")

        if not isinstance(password, str):
            raise ValueError("Client's Password needs to be a str")

        if not isinstance(firstname, str):
            raise ValueError("Client's Firstname needs to be a str")

        if not isinstance(lastname, str):
            raise ValueError("Client's Lastname needs to be a str")

        if not isinstance(phone_number, str):
            raise ValueError("Client's Phone Number needs to be a str")

        parameters = {
            "client": client,
            "email": email,
            "password": password,
            "firstname": firstname,
            "lastname": lastname,
            "phone_number": phone_number,
        }

        if "company" in kwargs:
            if not isinstance(kwargs["company"], str):
                raise ValueError("Client's Company needs to be a str")
            parameters["company"] = kwargs.pop("company")

        if "address" in kwargs:
            if not isinstance(kwargs["address"], str):
                raise ValueError("Client's Address needs to be a str")
            parameters["address"] = kwargs.pop("address")

        if "city" in kwargs:
            if not isinstance(kwargs["city"], str):
                raise ValueError("Client's City needs to be a str")
            parameters["city"] = kwargs.pop("city")

        if "state" in kwargs:
            if not isinstance(kwargs["state"], str):
                raise ValueError("Client's State needs to be a str")
            parameters["state"] = kwargs.pop("state")

        if "country" in kwargs:
            if not isinstance(kwargs["country"], str):
                raise ValueError(
                    "Client's Country needs to be a str (Values from general.get_countries)"
                )
            parameters["country"] = kwargs.pop("country")

        if "zip" in kwargs:
            if not isinstance(kwargs["zip"], str):
                raise ValueError("Client's Zip Code needs to be a str")
            parameters["zip"] = kwargs.pop("zip")

        if "balance_management" in kwargs:
            if not isinstance(kwargs["balance_management"], str):
                raise ValueError(
                    "Balance Management for Client (Values from clients.get_balance_management)"
                )
            parameters["balance_management"] = kwargs.pop("balance_management")

        if len(kwargs) > 0:
            not_allowed_parameters = ""
            for key, value in kwargs.items():
                not_allowed_parameters += key + " "
            raise ValueError(
                "Parameters not allowed: {}".format(not_allowed_parameters))

        return self._voipms_client._get(method, parameters)
Ejemplo n.º 10
0
    def email_to_fax(self, auth_email, from_number_id, security_code, **kwargs):
        """
        eate or update the information of a specific "Email to Fax configuration"

        :param auth_email: [Required] Email address from you will sent Fax Messages
        :type auth_email: :py:class:`str`
        :param from_number_id: [Required] Fax number that will appear as fax sender. (values from fax.get_fax_numbers_info)
        :type from_number_id: :py:class:`int`
        :param security_code: [Required] An alphanumeric code to identify your emails before send as Fax
        :type security_code: :py:class:`str`

        :param fax_id: ID of the "Email to Fax" to edit (Values from fax.get_email_to_fax)
        :type fax_id: :py:class:`int`
        :param enabled: If Enable, we will send Fax Message when we receive an email from the provided address (True/False)
        :type enabled: :py:class:`bool`
        :param security_code_enabled: If Enable, we will check the mail subject if this include a Security Code before send the Fax (True/False)
        :type security_code_enabled: :py:class:`bool`
        :param test: Set to true if testing how cancel a Fax Folder (True/False)
        :type test: :py:class:`bool`

        :returns: :py:class:`dict`
        """
        method = "setEmailToFax"

        if not isinstance(auth_email, str):
            raise ValueError("Email address from you will sent Fax Messages needs to be a str")
        elif not validate_email(auth_email):
                raise ValueError("Email address from you will sent Fax Messages is not a correct email syntax")

        if not isinstance(from_number_id, int):
            raise ValueError("Fax number that will appear as fax sender needs to be an int (values from fax.get_fax_numbers_info)")

        if not isinstance(security_code, str):
            raise ValueError("An alphanumeric code to identify your emails before send as Fax needs to be a str")

        parameters = {
            "auth_email": auth_email,
            "from_number_id": from_number_id,
            "security_code": security_code,
        }

        if "fax_id" in kwargs:
            if not isinstance(kwargs["fax_id"], int):
                raise ValueError("ID of the \"Email to Fax\" to edit (Values from fax.get_fax_folders)")
            parameters["id"] = kwargs.pop("fax_id")

        if "enabled" in kwargs:
            if not isinstance(kwargs["enabled"], bool):
                raise ValueError("If Enable, we will send Fax Message when we receive an email from the provided address needs to be a bool (True/False)")
            else:
                parameters["enabled"] = convert_bool(kwargs.pop("enabled"))

        if "security_code_enabled" in kwargs:
            if not isinstance(kwargs["security_code_enabled"], bool):
                raise ValueError("If Enable, we will check the mail subject if this include a Security Code before send the Fax needs to be a bool (True/False)")
            else:
                parameters["security_code_enabled"] = convert_bool(kwargs.pop("security_code_enabled"))

        if "test" in kwargs:
            if not isinstance(kwargs["test"], bool):
                raise ValueError("Set to true if testing how cancel a Fax Folder needs to be a bool (True/False)")
            else:
                parameters["test"] = convert_bool(kwargs.pop("test"))

        if len(kwargs) > 0:
            not_allowed_parameters = ""
            for key, value in kwargs.items():
                not_allowed_parameters += key + " "
            raise ValueError("Parameters not allowed: {}".format(not_allowed_parameters))

        return self._voipms_client._get(method, parameters)