Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

'AvailablePhoneNumber' object has no attribute 'local' #4

Closed
0x19 opened this Issue Jul 10, 2012 · 10 comments

Comments

Projects
None yet
3 participants
Owner

0x19 commented Jul 10, 2012

from telapi import rest

account_sid = '{AccountSid}'
auth_token  = '{AuthToken}'
client      = rest.Client(account_sid, auth_token)
account     = client.accounts[client.account_sid]

country_code = 'US'

for available_number in account.available_phone_numbers[country_code].local:
    print "AvailablePhoneNumber Sid: %s" % available_number.sid

Results with following issue:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python2.7/dist-packages/telapi-0.0.3-py2.7.egg/telapi/rest/__init__.py", line 295, in __getattr__
    return self.__getattribute__(name)
AttributeError: 'AvailablePhoneNumber' object has no attribute 'local'
Contributor

YAmikep commented Jun 10, 2014

This issue exists since 2012. It still has not been fixed?
I ran into the same problem today...

Thanks.

Contributor

mattwilliamson commented Jun 16, 2014

Sorry for confusion. The docs are showing SID, but these really haven't got a SID. The actual number is used to purchase them. We will fix this on the website.

Try:

for available_number in account.available_phone_numbers[country_code].local:
    print "AvailablePhoneNumber address: %s" % available_number.phone_number
Contributor

YAmikep commented Jun 16, 2014

How do you use filter? How do you use local?
The doc shows this example: http://www.telapi.com/docs/api/rest/available-phone-numbers/list/

for available_number in account.available_phone_numbers[country_code].filter({local/tollfree}):

Thanks

Contributor

mattwilliamson commented Jun 16, 2014

Local is as above, tollfree is like this:

for available_number in account.available_phone_numbers[country_code].tollfree:
    print "AvailablePhoneNumber address: %s" % available_number.phone_number
Contributor

YAmikep commented Jun 16, 2014

What about filter()?

Contributor

mattwilliamson commented Jun 16, 2014

Ah. Try this:

for available_number in account.available_phone_numbers[country_code].local.filter(AreaCode='530'):
    print "AvailablePhoneNumber address: %s" % available_number.phone_number

Valid filters are [u'Contains', u'AreaCode', u'InRegion', u'InPostalCode']

Contributor

YAmikep commented Jun 16, 2014

Trying that:

for available_number in account.available_phone_numbers['us'].local.filter(InPostalCode='75254'):
    print available_number.phone_number, available_number.region, available_number.postal_code

I get:

+17733668392 IL None
+17202594611 CO None
+15303036275 CA None
+19092329019 CA None
+12055351814 AL None
+12039516090 CT None
+19122921885 GA None
+15084197061 MA None
+15874006879 None None
+12032953422 CT None
+19043294128 FL None
+16477991986 ON None
  1. I do not understand why postal_code is None.
  2. Even though I cannot see the postal codes of each number, "75254" is in TX and I obviously do not get numbers in the postal code 75254 given the regions.
    I even got one from Canada (while I chose "us"): ON is for Ontario, Canada.

What is happening?

Contributor

mattwilliamson commented Jun 16, 2014

It appears we do not have predetermined locality data for all of our DIDs.
Unfortunately I'd ask you to perhaps just use the AreaCode filtering if you
need geographically specific numbers.

On Mon, Jun 16, 2014 at 5:03 PM, Michael Palumbo notifications@github.com
wrote:

Trying that:

for available_number in account.available_phone_numbers['us'].local.filter(InPostalCode='75254'):
print available_number.phone_number, available_number.region, available_number.postal_code

I get:

+17733668392 IL None+17202594611 CO None+15303036275 CA None+19092329019 CA None+12055351814 AL None+12039516090 CT None+19122921885 GA None+15084197061 MA None+15874006879 None None+12032953422 CT None+19043294128 FL None+16477991986 ON None

  1. I do not understand why postal_code is None.
  2. Even though I cannot see the postal codes of each number, "75254" is in
    TX and I obviously do not get numbers in the postal code 75254 given the
    regions.
    I even got one from Canada (while I chose "us"): ON is for Ontario, Canada.

What is happening?


Reply to this email directly or view it on GitHub
#4 (comment).

Contributor

YAmikep commented Jun 16, 2014

I was mainly interested in Postal Codes, not area codes.
You should really remove the InPostalCode filter because it's really confusing.
I expect that everything I see in the documentation actually works.

So the postal_code attribute to None is normal too? This attribute is not always filled?

Contributor

YAmikep commented Jun 16, 2014

Also, how do I know which properties of a resource are not mandatory?
Looking at the list in the documentation, it does not say: http://www.telapi.com/docs/api/rest/available-phone-numbers/list/ ?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment