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)
def fax_number_url_callback(self, did, **kwargs): """ Updates the url callback 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 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 = "setFaxNumberURLCallback" 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 "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)
def email_to_fax(self, fax_id, test=None): """ Deletes a specific "Email to Fax configuration" from your Account :param fax_id: [Required] ID for a specific "Email To Fax Configuration" (Example: 923) :type fax_id: :py:class:`int` :param test: Set to true if testing how cancel a "Email To Fax Configuration" (True/False) :type test: :py:class:`bool` :returns: :py:class:`dict` """ method = "delEmailToFax" if not isinstance(fax_id, int): raise ValueError( "ID for a specific \"Email To Fax Configuration\" needs to be an int (Example: 923)" ) parameters = { "id": fax_id, } if test: if not isinstance(test, bool): raise ValueError( "Set to true if testing how cancel a \"Email To Fax Configuration\" needs to be a bool (True/False)" ) else: parameters["test"] = convert_bool(test) return self._voipms_client._get(method, parameters)
def fax_folder(self, folder_id, test=None): """ Deletes a specific Fax Folder from your Account :param folder_id: [Required] ID for a specific Fax Folder (Example: 923) :type folder_id: :py:class:`int` :param test: Set to true if testing how cancel a Fax Folder (True/False) :type test: :py:class:`bool` :returns: :py:class:`dict` """ method = "delFaxFolder" if not isinstance(folder_id, int): raise ValueError( "ID for a specific Fax Folder needs to be an int (Example: 923)" ) parameters = { "id": folder_id, } if test: if not isinstance(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(test) return self._voipms_client._get(method, parameters)
def charge(self, client, charge, description=None, test=False): """ Adds a Charge to a specific Reseller Client :param client: [Required] ID for a specific Reseller Client (Example: 561115) :type client: :py:class:`int` :param charge: [Required] Amount of money that will be Debited from the customer (Example: 4.99) :type charge: :py:class:`float` :param description: Charge Description :type description: :py:class:`str` :param test: Set to true if testing how adding charges works :type test: :py:class:`str` :returns: :py:class:`dict` """ method = "addCharge" if not isinstance(client, int): raise ValueError( "ID for a specific Reseller Client needs to be an int (Example: 561115)" ) if not isinstance(charge, float): raise ValueError( "Amount of money that will be Debited from the customer needs to be a float (Example: 4.99)" ) parameters = { "client": client, "charge": charge, } if description: if not isinstance(description, str): raise ValueError("Charge Description needs to be a str") parameters["description"] = description if test: if not isinstance(test, bool): raise ValueError( "Set to True if testing how adding charges works") parameters["test"] = convert_bool(test) return self._voipms_client._get(method, parameters)
def balance(self, advanced=False): """ Retrieves Balance for your Account if no additional parameter is provided - Retrieves Balance and Calls Statistics for your Account if "advanced" parameter is true :param advanced: True for Calls Statistics :type advanced: :py:class:`bool` :returns: :py:class:`dict` """ method = "getBalance" parameters = {} if advanced: if not isinstance(advanced, bool): raise ValueError( "To retrieve Balance and Calls Statistics use True") parameters["advanced"] = convert_bool(advanced) return self._voipms_client._get(method, parameters)
def fax_folder(self, name, **kwargs): """ Create or update the information of a specific Fax Folder :param name: [Required] Name of the Fax Folder to create or update (Example: FAMILY) :type name: :py:class:`int` :param fax_id: ID of the Fax Folder to edit (Values from fax.get_fax_folders) :type fax_id: :py:class:`int` :param test: Set to true if testing how cancel a Fax Folder (True/False) :type test: :py:class:`bool` :returns: :py:class:`dict` """ method = "setFaxFolder" if not isinstance(name, str): raise ValueError("Name of the Fax Folder to create or update needs to be a str (Example: FAMILY)") parameters = { "name": name, } if "fax_id" in kwargs: if not isinstance(kwargs["fax_id"], int): raise ValueError("ID of the Fax Folder to edit needs to be an int (Values from fax.get_fax_folders)") parameters["id"] = kwargs.pop("fax_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)
def fax_message(self, fax_id, folder_id, test=None): """ Moves a Fax Message to a different folder :param fax_id: [Required] ID of the Fax Message requested (Values from fax.get_fax_messages) :type fax_id: :py:class:`int` :param folder_id: [Required] ID of the destination Fax Folder (Values from fax.get_fax_folders) :type folder_id: :py:class:`int` :param test: Set to true if testing how cancel a Fax Folder (True/False) :type test: :py:class:`bool` :returns: :py:class:`dict` """ method = "moveFaxMessage" if not isinstance(fax_id, int): raise ValueError( "ID for a specific \"Email To Fax Configuration\" needs to be an int (Example: 923)" ) if not isinstance(folder_id, int): raise ValueError( "ID for a specific \"Email To Fax Configuration\" needs to be an int (Example: 923)" ) parameters = { "fax_id": fax_id, "folder_id": folder_id, } if test: if not isinstance(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(test) return self._voipms_client._get(method, parameters)
def sms(self, **kwargs): """ Retrieves a list of SMS messages by: date range, sms type, DID number, and contact :param sms: ID for a specific SMS (Example: 5853) :type sms: :py:class:`int` :param from: Start Date for Filtering SMSs (Example: '2014-03-30') - Default value: Today :type from: :py:class:`str` :param to: End Date for Filtering SMSs (Example: '2014-03-30') - Default value: Today :type to: :py:class:`str` :param type: Filter SMSs by Type (Boolean: True = received / False = sent) :type type: :py:class:`bool` :param did: DID number for Filtering SMSs (Example: 5551234567) :type did: :py:class:`int` :param contact: Contact number for Filtering SMSs (Example: 5551234567) :type contact: :py:class:`int` :param limit: Number of records to be displayed (Example: 20) - Default value: 50 :type limit: :py:class:`int` :param timezone: Adjust time of SMSs according to Timezome (Numeric: -12 to 13) :type timezone: :py:class:`int` :returns: :py:class:`dict` """ method = "getSMS" parameters = {} if "sms" in kwargs: if not isinstance(kwargs["sms"], int): raise ValueError( "ID for a specific SMS needs to be an int (Example: 5853)") parameters["sms"] = kwargs.pop("sms") if "from" in kwargs: if not isinstance(kwargs["from"], str): raise ValueError( "Start Date for Filtering SMSs needs to be a str (Example: '2014-03-30')" ) validate_date(kwargs["from"]) parameters["from"] = kwargs.pop("from") if "to" in kwargs: if not isinstance(kwargs["to"], str): raise ValueError( "End Date for Filtering SMSs needs to be a str (Example: '2014-03-30')" ) validate_date(kwargs["to"]) parameters["to"] = kwargs.pop("to") if "type" in kwargs: if not isinstance(kwargs["type"], bool): raise ValueError( "Filter SMSs by Type needs to be a bool (Boolean: True = received / False = sent)" ) parameters["type"] = convert_bool(kwargs.pop("type")) if "did" in kwargs: if not isinstance(kwargs["did"], int): raise ValueError( "DID number for Filtering SMSs needs to be an int (Example: 5551234567)" ) parameters["did"] = kwargs.pop("did") if "contact" in kwargs: if not isinstance(kwargs["contact"], int): raise ValueError( "Contact number for Filtering SMSs needs to be an int (Example: 5551234567)" ) parameters["contact"] = kwargs.pop("contact") if "limit" in kwargs: if not isinstance(kwargs["limit"], int): raise ValueError( "Number of records to be displayed needs to be an int (Example: 20)" ) parameters["limit"] = kwargs.pop("limit") if "timezone" in kwargs: if not isinstance(kwargs["timezone"], int): raise ValueError( "Adjust time of SMSs according to Timezome needs to be an int (Numeric: -12 to 13)" ) parameters["timezone"] = kwargs.pop("timezone") 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)
def connect_did(self, did, account, monthly, setup, minute, **kwargs): """ Connects a specific DID to a specific Reseller Client Sub Account :param did: [Required] DID to be canceled and deleted (Example: 5551234567) :type did: :py:class:`str` or `int` :param account: [Required] Reseller Sub Account (Example: '100001_VoIP') :type account: :py:class:`str` :param monthly: [Required] Montly Fee for Reseller Client (Example: 3.50) :type monthly: :py:class:`float` :param setup: [Required] Setup Fee for Reseller Client (Example: 1.99) :type setup: :py:class:`float` :param minute: [Required] Minute Rate for Reseller Client (Example: 0.03) :type minute: :py:class:`float` :param **kwargs: All optional parameters :type **kwargs: :py:class:`dict` :param next_billing: Next billing date (Example: '2014-03-30') :type next_billing: :py:class:`str` :param dont_charge_setup: If set to true, the setup value will not be charged after Connect :type dont_charge_setup: :py:class:`bool` :param dont_charge_monthly: If set to true, the monthly value will not be charged after Connect :type dont_charge_monthly: :py:class:`bool` :returns: :py:class:`dict` """ method = "connectDID" if isinstance(did, str): did = did.replace('.', '') try: did = int(did) except: raise ValueError( "DID to be canceled and deleted needs to be an int or str of numbers (Example: 555.123.4567 or 5551234567)" ) if not isinstance(did, int): raise ValueError( "DID to be canceled and deleted needs to be an int (Example: 5551234567)" ) if not isinstance(account, str): raise ValueError( "Reseller Sub Account needs to be a str (Example: '100001_VoIP')" ) if not isinstance(monthly, float): raise ValueError( "Montly Fee for Reseller Client needs to be a float (Example: 3.50)" ) if not isinstance(setup, float): raise ValueError( "Setup Fee for Reseller Client needs to be a float (Example: 1.99)" ) if not isinstance(minute, float): raise ValueError( "Minute Rate for Reseller Client needs to be a float (Example: 0.03)" ) parameters = { "did": did, "account": account, "monthly": monthly, "setup": setup, "minute": minute, } if "next_billing" in kwargs: if not isinstance(kwargs["next_billing"], str): raise ValueError( "Next billing date needs to be a str (Example: '2014-03-30')" ) validate_date(kwargs["next_billing"]) parameters["next_billing"] = kwargs.pop("next_billing") if "dont_charge_setup" in kwargs: if not isinstance(kwargs["dont_charge_setup"], bool): raise ValueError( "If set to True, the setup value will not be charged after Connect (needs to be bool)" ) parameters["dont_charge_setup"] = convert_bool( kwargs.pop("dont_charge_setup")) if "dont_charge_monthly" in kwargs: if not isinstance(kwargs["dont_charge_monthly"], bool): raise ValueError( "If set to True, the monthly value will not be charged after Connect (needs to be bool)" ) parameters["dont_charge_monthly"] = convert_bool( kwargs.pop("dont_charge_monthly")) 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)
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)
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)
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)
def did(self, did, **kwargs): """ Deletes a specific DID from your Account :param did: [Required] DID to be canceled and deleted (Example: 5551234567) :type did: :py:class:`str` or `int` :param **kwargs: All optional parameters :type **kwargs: :py:class:`dict` :param cancelcomment: Comment for DID cancellation :type cancelcomment: :py:class:`str` :param portout: Set to True if the DID is being ported out :type portout: :py:class:`bool` :param test: Set to True if testing how cancellation works - Cancellation can not be undone - When testing, no changes are made :type test: :py:class:`bool` :returns: :py:class:`dict` routing, failover_busy, failover_unreachable and failover_noanswer can receive values in the following format => header:record_id Where header could be: account, fwd, vm, sip, grp, ivr, sys, recording, queue, cb, tc, disa, none. Examples: account Used for routing calls to Sub Accounts You can get all sub accounts using the accounts.get.sub_accounts function fwd Used for routing calls to Forwarding entries. You can get the ID right after creating a Forwarding with dids.set.forwarding or by requesting all forwardings entries with getForwardings. vm Used for routing calls to a Voicemail. You can get all voicemails and their IDs using the voicemail.get.voicemails function sys System Options: hangup = Hangup the Call busy = Busy tone noservice = System Recording: Number not in service disconnected = System Recording: Number has been disconnected dtmf = DTMF Test echo = ECHO Test none Used to route calls to no action Examples: 'account:100001_VoIP' 'fwd:1026' 'vm:101' 'none:' 'sys:echo' """ method = "cancelDID" if isinstance(did, str): did = did.replace('.', '') try: did = int(did) except: raise ValueError( "DID to be canceled and deleted needs to be an int or str of numbers (Example: 555.123.4567 or 5551234567)" ) if not isinstance(did, int): raise ValueError( "DID to be canceled and deleted needs to be an int (Example: 5551234567)" ) parameters = {"did": did} if "portout" in kwargs: if not isinstance(kwargs["portout"], bool): raise ValueError("Set to True if the DID is being ported out") parameters["portout"] = convert_bool(kwargs.pop("portout")) if "test" in kwargs: if not isinstance(kwargs["test"], bool): raise ValueError( "Set to True if testing how cancellation works") 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)
def sub_account(self, username, password, protocol, auth_type, device_type, lock_international, international_route, music_on_hold, allowed_codecs, dtmf_mode, nat, **kwargs): """ Adds a new Sub Account entry to your Account :param username: [Required] Username for the Sub Account (Example: 'VoIP') :type username: :py:class:`str` :param password: [Required] Sub Account Password (For Password Authentication) :type password: :py:class:`str` :param protocol: [Required] Protocol used for the Sub Account (Values from accounts.get_protocols) :type protocol: :py:class:`int` :param auth_type: [Required] Authorization Type Code (Values from accounts.get_auth_types) :type auth_type: :py:class:`int` :param device_type: [Required] Device Type Code (Values from accounts.get_device_types) :type device_type: :py:class:`int` :param lock_international: [Required] Lock International Code (Values from accounts.get_lock_international) :type lock_international: :py:class:`int` :param international_route: [Required] Route Code (Values from accounts.get_routes) :type international_route: :py:class:`int` :param music_on_hold: [Required] Music on Hold Code (Values from accounts.get_music_on_hold) :type music_on_hold: :py:class:`str` :param allowed_codecs: [Required] List of Allowed Codecs (Values from accounts.get_allowed_codecs) Codecs separated by semicolon (Example: ulaw;g729;gsm) :type allowed_codecs: :py:class:`str` :param dtmf_mode: [Required] DTMF Mode Code (Values from accounts.get_dtmf_modes) :type dtmf_mode: :py:class:`str` :param nat: [Required] NAT Mode Code (Values from accounts.get_nat) :type nat: :py:class:`str` :param **kwargs: All optional parameters :type **kwargs: :py:class:`dict` :param description: Sub Account Description (Example: 'VoIP Account') :type description: :py:class:`str` :param ip: Sub Account IP (For IP Authentication) :type ip: :py:class:`str` :param callerid_number: Caller ID Override :type callerid_number: :py:class:`str` :param canada_routing: Route Code (Values from accounts.get_routes) :type canada_routing: :py:class:`int` :param internal_extension: Sub Account Internal Extension (Example: 1 -> Creates 101) :type internal_extension: :py:class:`int` :param internal_voicemail: Sub Account Internal Voicemail (Example: 101) :type internal_voicemail: :py:class:`str` :param internal_dialtime: Sub Account Internal Dialtime (Example: 60 -> seconds) :type internal_dialtime: :py:class:`int` :param reseller_client: Reseller Account ID (Example: 561115) :type reseller_client: :py:class:`int` :param reseller_package: Reseller Package (Example: 92364) :type reseller_package: :py:class:`int` :param reseller_nextbilling: Reseller Next Billing Date (Example: '2012-12-31') :type reseller_nextbilling: :py:class:`str` :param reseller_chargesetup: True if you want to charge Package Setup Fee after Save :type reseller_chargesetup: :py:class:`bool` :returns: :py:class:`dict` """ method = "createSubAccount" if not isinstance(username, str): raise ValueError("Username needs to be a str") if not isinstance(password, str): raise ValueError( "Sub Account Password needs to be a str (For Password Authentication)" ) if not isinstance(protocol, int): raise ValueError( "Protocol value needs to be an int (Values from accounts.get_protocols)" ) if not isinstance(auth_type, int): raise ValueError( "Auth type value needs to be an int (Values from accounts.get_auth_types)" ) if not isinstance(device_type, int): raise ValueError( "Device type value needs to be an int (Values from accounts.get_device_types)" ) if not isinstance(lock_international, int): raise ValueError( "Lock International Code value needs to be an int (Values from accounts.get_lock_international)" ) if not isinstance(international_route, int): raise ValueError( "Route Code value needs to be an int (Values from accounts.get_routes)" ) if not isinstance(music_on_hold, str): raise ValueError( "Music on Hold Code value needs to be str (Values from accounts.get_music_on_hold)" ) if not isinstance(allowed_codecs, str): raise ValueError( "List of Allowed Codecs value needs to be str (Values from accounts.get_allowed_codecs)" ) if not isinstance(dtmf_mode, str): raise ValueError( "DTMF Mode Code (Values from needs to be str accounts.get_dtmf_modes)" ) if not isinstance(nat, str): raise ValueError( "DTMF Mode Code (Values from needs to be str accounts.get_nat)" ) parameters = { "username": username, "password": password, "protocol": protocol, "auth_type": auth_type, "device_type": device_type, "lock_international": lock_international, "international_route": international_route, "music_on_hold": music_on_hold, "allowed_codecs": allowed_codecs, "dtmf_mode": dtmf_mode, "nat": nat, } if "description" in kwargs: if not isinstance(kwargs["description"], str): raise ValueError( "Sub Account Description needs to be a str (Example: 'VoIP Account')" ) parameters["description"] = kwargs.pop("description") if "ip" in kwargs: ip = kwargs["ip"] if not isinstance(ip, str): raise ValueError( "Sub Account IP needs to be a str (For IP Authentication)") try: socket.inet_aton(ip) except socket.error: raise ValueError( "The provided IP: {} is not in the correct format (Example: 127.0.0.1)" .format(ip)) parameters["ip"] = kwargs.pop("ip") if "callerid_number" in kwargs: if not isinstance(kwargs["callerid_number"], str): raise ValueError("Caller ID Override needs to be a str") parameters["callerid_number"] = kwargs.pop("callerid_number") if "canada_routing" in kwargs: if not isinstance(kwargs["canada_routing"], int): raise ValueError( "Route Code needs to be an int (Values from accounts.get_routes)" ) parameters["canada_routing"] = kwargs.pop("canada_routing") if "internal_extension" in kwargs: if not isinstance(kwargs["internal_extension"], int): raise ValueError( "Sub Account Internal Extension needs to be an int (Example: 1 -> Creates 101)" ) parameters["internal_extension"] = kwargs.pop("internal_extension") if "internal_voicemail" in kwargs: if not isinstance(kwargs["internal_voicemail"], int): raise ValueError( "Sub Account Internal Voicemail needs to be an int (Example: 101)" ) parameters["internal_voicemail"] = kwargs.pop("internal_voicemail") if "internal_dialtime" in kwargs: if not isinstance(kwargs["internal_dialtime"], int): raise ValueError( "Sub Account Internal Dialtime needs to be an int (Example: 60 -> seconds)" ) parameters["internal_dialtime"] = kwargs.pop("internal_dialtime") if "reseller_client" in kwargs: if not isinstance(kwargs["reseller_client"], int): raise ValueError( "Reseller Account ID needs to be an int (Example: 561115)") parameters["reseller_client"] = kwargs.pop("reseller_client") if "reseller_package" in kwargs: if not isinstance(kwargs["reseller_package"], int): raise ValueError( "Reseller Package needs to be an int (Example: 92364)") parameters["reseller_package"] = kwargs.pop("reseller_package") if "reseller_nextbilling" in kwargs: reseller_nextbilling = kwargs.pop("reseller_nextbilling") if not isinstance(reseller_nextbilling, int): raise ValueError( "Reseller Next Billing Date needs to be a string (Example: '2012-12-31')" ) validate_date(reseller_nextbilling) parameters["reseller_nextbilling"] = reseller_nextbilling if "reseller_chargesetup" in kwargs: if not isinstance(kwargs["reseller_chargesetup"], bool): raise ValueError( "True if you want to charge Package Setup Fee after Save") parameters["reseller_chargesetup"] = convert_bool( kwargs.pop("reseller_chargesetup")) 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)
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)
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)