Ejemplo n.º 1
0
 def balance(self, **kwargs):
     """
     Retrieve the credit balance
     
     :returns: Return :class:`hoiio.service.Response`
     """
     return self.make_request(api_endpoint('user', 'get_balance'), **kwargs)
Ejemplo n.º 2
0
    def subscribed_numbers(self, **kwargs):
        """
        Retrieve the list of subscribed numbers

        :returns: Return :class:`hoiio.service.Response`
        """
        return self.make_request(api_endpoint('number', 'get_active'), **kwargs)
Ejemplo n.º 3
0
    def subscribed_numbers(self, **kwargs):
        """
        Retrieve the list of subscribed numbers

        :returns: Return :class:`hoiio.service.Response`
        """
        return self.make_request(api_endpoint('number', 'get_active'),
                                 **kwargs)
Ejemplo n.º 4
0
    def rate(self, country, **kwargs):
        """
        Returns the subscription cost of the country

        :param country: Subscription cost of the country

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['country'] = country
        return self.make_request(api_endpoint('number', 'get_rates'), **kwargs)
Ejemplo n.º 5
0
    def rate(self, country, **kwargs):
        """
        Returns the subscription cost of the country

        :param country: Subscription cost of the country

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['country'] = country
        return self.make_request(api_endpoint('number', 'get_rates'), **kwargs)
Ejemplo n.º 6
0
    def rate_in(self, dest, **kwargs):
        """
        Retrieve the cost of receiving a fax

        :param dest: The fax number to receiving at
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['incoming'] = dest
        return self.make_request(api_endpoint('fax', 'get_rate'), **kwargs)
Ejemplo n.º 7
0
    def rate(self, dest, **kwargs):
        """
        Retrieve the cost of sending a fax

        :param dest: The fax number to send to
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['dest'] = dest
        return self.make_request(api_endpoint('fax', 'get_rate'), **kwargs)
Ejemplo n.º 8
0
 def info(self, **kwargs):
     """
     Retrieve account info
     
     :returns: Return :class:`hoiio.service.Response`
     """
     res = self.make_request(api_endpoint('user', 'get_info'), **kwargs)
     # To be consistent with Hoiio.number.available_countries, we remove + 
     if res.prefix.startswith('+'):
     	res.prefix = res.prefix[1:]
     return res 
Ejemplo n.º 9
0
    def hangup(self, txn_ref, **kwargs):
        """
        Hangup a call. For conference, you need to hangup for each of the participants.

        :param txn_ref: The transaction reference for the call to hangup

        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Hangup %s' % (txn_ref)
        kwargs['txn_ref'] = txn_ref
        return self.make_request(api_endpoint('voice', 'hangup'), **kwargs)
Ejemplo n.º 10
0
    def status(self, txn_ref, **kwargs):
        """
        Retrieve the status and various information about an SMS

        :param txn_ref: The transaction reference for the SMS
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Status of %s' % (txn_ref)
        kwargs['txn_ref'] = txn_ref
        return self.make_request(api_endpoint('sms', 'query_status'), **kwargs)
Ejemplo n.º 11
0
    def rate_in(self, dest, **kwargs):
        """
        Retrieve the cost of sending an SMS

        :param dest: The phone number to receive the SMS at
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'SMS rate receiving at %s' % (dest)
        kwargs['incoming'] = dest
        return self.make_request(api_endpoint('sms', 'get_rate'), **kwargs)
Ejemplo n.º 12
0
    def hangup(self, txn_ref, **kwargs):
        """
        Hangup a call. For conference, you need to hangup for each of the participants.

        :param txn_ref: The transaction reference for the call to hangup

        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Hangup %s' % (txn_ref)
        kwargs['txn_ref'] = txn_ref
        return self.make_request(api_endpoint('voice', 'hangup'), **kwargs)
Ejemplo n.º 13
0
    def status(self, txn_ref, **kwargs):
        """
        Retrieve the status and various information about a fax

        :param txn_ref: The transaction reference for the fax
        
        :returns: Return :class:`hoiio.service.Response`
        """     
        if self._Hoiio.debuglevel > 0:
            print('Status of %s' % (txn_ref))
        kwargs['txn_ref'] = txn_ref
        return self.make_request(api_endpoint('fax', 'query_status'), **kwargs)
Ejemplo n.º 14
0
Archivo: sms.py Proyecto: 99co/hoiiopie
    def rate_in(self, dest, **kwargs):
        """
        Retrieve the cost of sending an SMS

        :param dest: The phone number to receive the SMS at
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'SMS rate receiving at %s' % (dest)
        kwargs['incoming'] = dest
        return self.make_request(api_endpoint('sms', 'get_rate'), **kwargs)
Ejemplo n.º 15
0
    def available_countries(self, **kwargs):
        """
        Returns the countries that have Hoiio numbers.

        :returns: Return :class:`hoiio.service.Response`
        """
        res = self.make_request(api_endpoint('number', 'get_countries'), **kwargs)
        # We make sure states attribute is None if not present 
        for country in res.entries:
            if not hasattr(country, 'states'):
                country.states = None
        return res
Ejemplo n.º 16
0
    def subscribe(self, number, duration, **kwargs):
        """
        Subscribe a number

        :param number: The number to subscribe to
        :param duration: The number of months to subscribe to
        :type duration: 1, 3, 12 or auto_extend

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['number'] = number
        kwargs['duration'] = duration
        return self.make_request(api_endpoint('number', 'subscribe'), **kwargs)
Ejemplo n.º 17
0
    def history(self, **kwargs):
        """
        Retrieve the history of SMS. There is pagination, and each page returns up to 100 entries.

        :param string from: SMS sent/received after this date. In "YYYY-MM-DD HH:MM:SS" (GMT+8) format.
        :param string to: SMS sent/received made before this date. In "YYYY-MM-DD HH:MM:SS" (GMT+8) format.
        :param int page: The page number. Count starts from 1.
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'SMS history'
        return self.make_request(api_endpoint('sms', 'get_history'), **kwargs)
Ejemplo n.º 18
0
    def available_numbers(self, country, state=None, **kwargs):
        """
        Returns the available numbers for purchase
        
        :param country: The country with available numbers
        :param state: The state in the country. Required for countries with states.

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['country'] = country
        if state != None:
            kwargs['state'] = state
        return self.make_request(api_endpoint('number', 'get_choices'), **kwargs)
Ejemplo n.º 19
0
    def subscribe(self, number, duration, **kwargs):
        """
        Subscribe a number

        :param number: The number to subscribe to
        :param duration: The number of months to subscribe to
        :type duration: 1, 3, 12 or auto_extend

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['number'] = number
        kwargs['duration'] = duration
        return self.make_request(api_endpoint('number', 'subscribe'), **kwargs)
Ejemplo n.º 20
0
    def available_countries(self, **kwargs):
        """
        Returns the countries that have Hoiio numbers.

        :returns: Return :class:`hoiio.service.Response`
        """
        res = self.make_request(api_endpoint('number', 'get_countries'),
                                **kwargs)
        # We make sure states attribute is None if not present
        for country in res.entries:
            if not hasattr(country, 'states'):
                country.states = None
        return res
Ejemplo n.º 21
0
    def history(self, **kwargs):
        """
        Retrieve the history of calls. There is pagination, and each page returns up to 100 entries.

        :param string from: Calls made after this date. In "YYYY-MM-DD HH:MM:SS" (GMT+8) format.
        :param string to: Calls made before this date. In "YYYY-MM-DD HH:MM:SS" (GMT+8) format.
        :param int page: The page number. Count starts from 1.
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Call history'
        return self.make_request(api_endpoint('voice', 'get_history'), **kwargs)
Ejemplo n.º 22
0
    def configure(self, number, **kwargs):
        """
        Configure a number. It is recommended to use configure_voice, configure_fax or configure_sms instead of this.

        :param number: The number to configure
        :param forward_to: The notify_url when there is an incoming call (could be voice or fax depending on mode).
        :param forward_sms_to: The notify_url when there is an incoming SMS
        :param mode: The mode for incoming call. It can either be voice or fax (but not both). Default to voice.
        :type mode: voice or fax

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['number'] = number
        return self.make_request(api_endpoint('number', 'update_forwarding'), **kwargs)
Ejemplo n.º 23
0
Archivo: sms.py Proyecto: 99co/hoiiopie
    def rate(self, msg, dest, **kwargs):
        """
        Retrieve the cost of sending an SMS

        :param msg: The SMS message
        :param dest: The phone number to send SMS to
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'SMS rate from %s [%s]' % (dest, msg)
        kwargs['dest'] = dest
        kwargs['msg'] = msg
        return self.make_request(api_endpoint('sms', 'get_rate'), **kwargs)
Ejemplo n.º 24
0
    def rate(self, dest1, dest2, **kwargs):
        """
        Retrieve the cost of making a call

        :param dest1: The first phone number to call. 
        :param dest2: The second phont number to call
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Calling %s to %s' % (dest1, dest2)
        kwargs['dest1'] = dest1
        kwargs['dest2'] = dest2
        return self.make_request(api_endpoint('voice', 'get_rate'), **kwargs)
Ejemplo n.º 25
0
    def rate(self, msg, dest, **kwargs):
        """
        Retrieve the cost of sending an SMS

        :param msg: The SMS message
        :param dest: The phone number to send SMS to
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'SMS rate from %s [%s]' % (dest, msg)
        kwargs['dest'] = dest
        kwargs['msg'] = msg
        return self.make_request(api_endpoint('sms', 'get_rate'), **kwargs)
Ejemplo n.º 26
0
    def rate(self, dest1, dest2, **kwargs):
        """
        Retrieve the cost of making a call

        :param dest1: The first phone number to call. 
        :param dest2: The second phont number to call
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Calling %s to %s' % (dest1, dest2)
        kwargs['dest1'] = dest1
        kwargs['dest2'] = dest2
        return self.make_request(api_endpoint('voice', 'get_rate'), **kwargs)
Ejemplo n.º 27
0
    def monitor(self, session, **kwargs):
        """
        Record the whole phone conversation from this point onwards

        :param session: The IVR session
        
        :param msg: The message to play as you record
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['session'] = session
        return self.make_request(api_endpoint('ivr/middle', 'monitor'), **kwargs)
Ejemplo n.º 28
0
    def hangup(self, session, **kwargs):
        """
        Hangup a phone call

        :param session: The IVR session
        
        :param msg: The message to play before you hangup
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['session'] = session
        return self.make_request(api_endpoint('ivr/end', 'hangup'), **kwargs)
Ejemplo n.º 29
0
    def available_numbers(self, country, state=None, **kwargs):
        """
        Returns the available numbers for purchase
        
        :param country: The country with available numbers
        :param state: The state in the country. Required for countries with states.

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['country'] = country
        if state != None:
            kwargs['state'] = state
        return self.make_request(api_endpoint('number', 'get_choices'),
                                 **kwargs)
Ejemplo n.º 30
0
    def play(self, session, msg, **kwargs):
        """
        Play a message over the phone call

        :param session: The IVR session
        :param msg: The message to play

        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['session'] = session
        kwargs['msg'] = msg
        return self.make_request(api_endpoint('ivr/middle', 'play'), **kwargs)
Ejemplo n.º 31
0
    def record(self, session, **kwargs):
        """
        Record a voice message

        :param session: The IVR session
        
        :param msg: The message to play before you record
        :param max_duration: The maximum duration (in seconds) for the recorded voice message
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['session'] = session
        return self.make_request(api_endpoint('ivr/middle', 'record'), **kwargs)
Ejemplo n.º 32
0
    def configure(self, number, **kwargs):
        """
        Configure a number. It is recommended to use configure_voice, configure_fax or configure_sms instead of this.

        :param number: The number to configure
        :param forward_to: The notify_url when there is an incoming call (could be voice or fax depending on mode).
        :param forward_sms_to: The notify_url when there is an incoming SMS
        :param mode: The mode for incoming call. It can either be voice or fax (but not both). Default to voice.
        :type mode: voice or fax

        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['number'] = number
        return self.make_request(api_endpoint('number', 'update_forwarding'),
                                 **kwargs)
Ejemplo n.º 33
0
    def dial(self, dest, **kwargs):
        """
        Make a call out to a phone number

        :param dest: The phone number to call to
        
        :param msg: The message to play when the phone is answered
        :param caller_id: The caller ID when connected to the phone number
        :param max_duration: The maximum duration for the call, afterwhich it will hangup automatically
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['dest'] = dest
        return self.make_request(api_endpoint('ivr/start', 'dial'), **kwargs)
Ejemplo n.º 34
0
    def transfer(self, session, dest, **kwargs):
        """
        Transfer the call to another phone number or a conference room

        :param session: The IVR session
        :param dest: The phone number or conference room. If you are transferring to a conference room, prefix with a room: eg. room:R1234.
        
        :param msg: The message to play as you record
        :param caller_id: The caller ID when connected to the dest
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['session'] = session
        kwargs['dest'] = dest
        return self.make_request(api_endpoint('ivr/end', 'transfer'), **kwargs)
Ejemplo n.º 35
0
    def gather(self, session, **kwargs):
        """
        Gather a keypad response from the user on the phone

        :param session: The IVR session
        
        :param msg: The message to play as you gather 
        :param max_digits: The maximum number of digits to gather from
        :param timeout: The call will hangup if no response after timeout (in seconds)
        :param attempts: The number of times the message will be repeated
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        kwargs['session'] = session
        return self.make_request(api_endpoint('ivr/middle', 'gather'), **kwargs)
Ejemplo n.º 36
0
Archivo: sms.py Proyecto: 99co/hoiiopie
    def bulk_send(self, msg, *dests, **kwargs):
        """
        Send SMS to multiple phone numbers (up to 1,000).

        :param dests: List of phone numbers to send SMS to
        :param msg: The SMS message
        
        :param sender_name: The sender name that will be displayed to :data:`dest`
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to SMS to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Sending [%s] to %s' % (msg, dests)
        kwargs['dest'] = ','.join(dests)
        kwargs['msg'] = msg
        return self.make_request(api_endpoint('sms', 'bulk_send'), **kwargs)
Ejemplo n.º 37
0
    def conference(self, *dests, **kwargs):
        """
        Call multiple phone numbers and connect them up in a conference call

        :param dests: List of phone numbers to call
        
        :param string room: The conference room to transfer the callers to
        :param caller_id: The caller ID to show to :data:`dest2`
        
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Conference call to %s' % (dests, )
        kwargs['dest'] = ','.join(dests)
        return self.make_request(api_endpoint('voice', 'conference'), **kwargs)
Ejemplo n.º 38
0
    def bulk_send(self, msg, *dests, **kwargs):
        """
        Send SMS to multiple phone numbers (up to 1,000).

        :param dests: List of phone numbers to send SMS to
        :param msg: The SMS message
        
        :param sender_name: The sender name that will be displayed to :data:`dest`
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to SMS to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Sending [%s] to %s' % (msg, dests)
        kwargs['dest'] = ','.join(dests)
        kwargs['msg'] = msg
        return self.make_request(api_endpoint('sms', 'bulk_send'), **kwargs)
Ejemplo n.º 39
0
    def conference(self, *dests, **kwargs):
        """
        Call multiple phone numbers and connect them up in a conference call

        :param dests: List of phone numbers to call
        
        :param string room: The conference room to transfer the callers to
        :param caller_id: The caller ID to show to :data:`dest2`
        
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Conference call to %s' % (dests,)
        kwargs['dest'] = ','.join(dests)
        return self.make_request(api_endpoint('voice', 'conference'), **kwargs)
Ejemplo n.º 40
0
    def call(self, dest1, dest2, **kwargs):
        """
        Call 2 phone numbers and connect them up

        :param dest1: The first phone number to call. If None, Hoiio will call the account's registered mobile number. 
        :param dest2: The second phont number to call
        :param caller_id: The caller ID to show to :data:`dest2`
        :param max_duration: Maximum duration (in seconds). Call will be hangup after :data:`max_duration`
        
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Calling %s to %s' % (dest1, dest2)
        kwargs['dest1'] = dest1
        kwargs['dest2'] = dest2
        return self.make_request(api_endpoint('voice', 'call'), **kwargs)
Ejemplo n.º 41
0
    def call(self, dest1, dest2, **kwargs):
        """
        Call 2 phone numbers and connect them up

        :param dest1: The first phone number to call. If None, Hoiio will call the account's registered mobile number. 
        :param dest2: The second phont number to call
        :param caller_id: The caller ID to show to :data:`dest2`
        :param max_duration: Maximum duration (in seconds). Call will be hangup after :data:`max_duration`
        
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print 'Calling %s to %s' % (dest1, dest2)
        kwargs['dest1'] = dest1
        kwargs['dest2'] = dest2
        return self.make_request(api_endpoint('voice', 'call'), **kwargs)
Ejemplo n.º 42
0
    def history(self, **kwargs):
        """
        Retrieve the history of Fax. There is pagination, and each page returns up to 100 entries.

        :param string from: Fax sent/received after this date. In "YYYY-MM-DD HH:MM:SS" (GMT+8) format.
        :param string to: Fax sent/received before this date. In "YYYY-MM-DD HH:MM:SS" (GMT+8) format.
        :param int page: The page number. Count starts from 1.
        :param type: The type of fax. Default to all.
        :type type: incoming, outgoing or all

        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print('Fax history')
        res = self.make_request(api_endpoint('fax', 'get_history'), **kwargs)
        for entry in res.entries:
            if not hasattr(entry, 'fax_url'):
                entry.fax_url = None
        return res
Ejemplo n.º 43
0
    def send(self, dest, filename, **kwargs):
        """
        Send a fax to a fax number

        :param dest: The fax number to send fax to
        :param file: The path to the pdf file to fax
        
        :param caller_id: The caller ID when connected to the fax number
        :param filename: The filename to store on Hoiio. If omitted, the filename of the file will be used.
        :param tag: Your own reference tag for this transaction
        :param notify_url: A notification URL for Hoiio to call to your web server
        
        :returns: Return :class:`hoiio.service.Response`
        """
        if self._Hoiio.debuglevel > 0:
            print('Faxing [%s] to %s' % (filename, dest))
        f = open(filename, "r")
        data = f.read()
        str_data = base64.b64encode(data)

        kwargs['dest'] = dest
        kwargs['file'] = str_data
        return self.make_request(api_endpoint('fax', 'send'), **kwargs)