Skip to content

didip/tornado_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is tornado_api

tornado_api is a collection of Mixins and asynchronous HTTP libraries for Tornado Web Framework.

FacebookGraphMixin

Re-implementation of Tornado's OAuth2 Mixin.

FoursquareMixin

OAuth2 Mixin for Foursquare. Once authorized via authorize_redirect(), you can call Foursquare API using foursquare_request()

tornado_api.Stripe

A complete implementation of Stripe v1 API using Tornado AsyncHTTPClient.

Initialization

    #
	# By default, blocking is set to False.
	# If blocking is set to True, then it uses Tornado blocking HTTP client.
	#
	stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY, blocking=True)

Building URL

tornado_api.Stripe maps to Stripe Curl URL exactly one-to-one.

/v1/charges

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.charges

/v1/charges/{CHARGE_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.charges.id(CHARGE_ID)

/v1/customers

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.customers

/v1/customers/{CUSTOMER_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.customers.id(CUSTOMER_ID)

/v1/customers/{CUSTOMER_ID}/subscription

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.customers.id(CUSTOMER_ID).subscription

/v1/invoices

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoices

/v1/invoices/{INVOICE_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoices.id(INVOICE_ID)

/v1/invoiceitems

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoiceitems

/v1/invoiceitems/{INVOICEITEM_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.invoiceitems.id(INVOICEITEM_ID)

/v1/tokens

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.tokens

/v1/tokens/{TOKEN_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.tokens.id(TOKEN_ID)

/v1/events

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.events

/v1/events/{EVENT_ID}

    stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
    stripe.events.id(EVENT_ID)

Performing HTTP request

GET

  	stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
  	stripe.plans.get()
  	stripe.plans.id(PLAN_ID).get()

POST

	DUMMY_PLAN = {
    	'amount': 2000,
    	'interval': 'month',
    	'name': 'Amazing Gold Plan',
    	'currency': 'usd',
    	'id': 'stripe-test-gold'
 	}
  	stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
	stripe.plans.post(**DUMMY_PLAN)

DELETE

	stripe = tornado_api.Stripe(YOUR_STRIPE_API_KEY)
  	stripe.plans.id(DUMMY_PLAN['id']).delete()

tornado_api.Twitter

Requirement:

pip install twitter

Based on Twitter module. The only 2 differences:

  • The HTTP client have been replaced by Tornado AsyncHTTPClient.

  • __call__() accepts _callback as keyword argument.

About

Collection of web service libraries for Tornado web framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages