Search code examples
pythonrecurly

Recurly Account Subscription


I'm trying through Python to get a Recurly account email given a subscription or a subscription state given an account email. When I try drilling from account into subscription for example, I get a

for account in r.Account.all():
    print 'Account: %s' % account
    print 'Sub: %s' % account.subscriptions

When I try to access account.subscription.state I get an error:

AttributeError: 'function' object has no attribute 'state'

Anyone know the solution?


Solution

  • An account has many subscriptions, so you'll need to iterate through each subscription and print its state. The following should work for ya:

        for account in recurly.Account.all():
           print 'Account: %s' % account
           for subscription in account.subscriptions():
              print 'Subscription: %s' % subscription.state