예제 #1
0
파일: account.py 프로젝트: 99co/hoiiopie
 def balance(self, **kwargs):
     """
     Retrieve the credit balance
     
     :returns: Return :class:`hoiio.service.Response`
     """
     return self.make_request(api_endpoint('user', 'get_balance'), **kwargs)
예제 #2
0
파일: number.py 프로젝트: 99co/hoiiopie
    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)
예제 #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)
예제 #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)
예제 #5
0
파일: number.py 프로젝트: 99co/hoiiopie
    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)
예제 #6
0
파일: fax.py 프로젝트: anduslim/hoiiopie
    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)
예제 #7
0
파일: fax.py 프로젝트: anduslim/hoiiopie
    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)
예제 #8
0
파일: account.py 프로젝트: 99co/hoiiopie
 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 
예제 #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)
예제 #10
0
파일: sms.py 프로젝트: samwize/hoiiopie
    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)
예제 #11
0
파일: sms.py 프로젝트: samwize/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)
예제 #12
0
파일: voice.py 프로젝트: 99co/hoiiopie
    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)
예제 #13
0
파일: fax.py 프로젝트: anduslim/hoiiopie
    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)
예제 #14
0
파일: sms.py 프로젝트: 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)
예제 #15
0
파일: number.py 프로젝트: 99co/hoiiopie
    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
예제 #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)
예제 #17
0
파일: sms.py 프로젝트: samwize/hoiiopie
    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)
예제 #18
0
파일: number.py 프로젝트: 99co/hoiiopie
    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)
예제 #19
0
파일: number.py 프로젝트: 99co/hoiiopie
    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)
예제 #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
예제 #21
0
파일: voice.py 프로젝트: 99co/hoiiopie
    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)
예제 #22
0
파일: number.py 프로젝트: 99co/hoiiopie
    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)
예제 #23
0
파일: sms.py 프로젝트: 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)
예제 #24
0
파일: voice.py 프로젝트: 99co/hoiiopie
    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)
예제 #25
0
파일: sms.py 프로젝트: samwize/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)
예제 #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)
예제 #27
0
파일: ivr.py 프로젝트: samwize/hoiiopie
    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)
예제 #28
0
파일: ivr.py 프로젝트: samwize/hoiiopie
    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)
예제 #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)
예제 #30
0
파일: ivr.py 프로젝트: samwize/hoiiopie
    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)
예제 #31
0
파일: ivr.py 프로젝트: samwize/hoiiopie
    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)
예제 #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)
예제 #33
0
파일: ivr.py 프로젝트: samwize/hoiiopie
    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)
예제 #34
0
파일: ivr.py 프로젝트: samwize/hoiiopie
    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)
예제 #35
0
파일: ivr.py 프로젝트: samwize/hoiiopie
    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)
예제 #36
0
파일: sms.py 프로젝트: 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)
예제 #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)
예제 #38
0
파일: sms.py 프로젝트: samwize/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)
예제 #39
0
파일: voice.py 프로젝트: 99co/hoiiopie
    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)
예제 #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)
예제 #41
0
파일: voice.py 프로젝트: 99co/hoiiopie
    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)
예제 #42
0
파일: fax.py 프로젝트: anduslim/hoiiopie
    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
예제 #43
0
파일: fax.py 프로젝트: anduslim/hoiiopie
    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)