Skip to content

Commit

Permalink
Merge branch 'gweeds' of github.com:balanced/balanced-python into gweeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew committed May 24, 2012
2 parents 583f979 + da9e3d0 commit d60856f
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 70 deletions.
5 changes: 3 additions & 2 deletions balanced/__init__.py
@@ -1,4 +1,5 @@
__version__ = '0.8.4'
__version__ = '0.8.5'
from collections import defaultdict
import contextlib


Expand Down Expand Up @@ -30,7 +31,7 @@
config = http_client.config


CACHE = dict()
CACHE = defaultdict(dict)


def bust_cache():
Expand Down
42 changes: 40 additions & 2 deletions balanced/resources.py
Expand Up @@ -407,10 +407,10 @@ def cacher(f):
@functools.wraps(f)
def wrapped(*args, **kwargs):
from balanced import config, CACHE
cached = CACHE.get(config.api_key_secret)
cached = CACHE[config.api_key_secret].get(f.__name__)
if bust_cache or not cached:
cached = f(*args, **kwargs)
CACHE[config.api_key_secret] = cached
CACHE[config.api_key_secret][f.__name__] = cached
return cached

return wrapped
Expand All @@ -437,6 +437,44 @@ class Marketplace(Resource):
collection='marketplaces',
resides_under_marketplace=False)

def create_card(self,
name,
card_number,
expiration_month,
expiration_year,
security_code=None,
street_address=None,
city=None,
region=None,
postal_code=None,
country_code=None,
phone_number=None,
):
return Card(
card_number=card_number,
expiration_month=expiration_month,
expiration_year=expiration_year,
name=name,
security_code=security_code,
street_address=street_address,
postal_code=postal_code,
city=city,
region=region,
country_code=country_code,
phone_number=phone_number,
).save()

def create_bank_account(self,
name,
account_number,
bank_code,
):
return BankAccount(
name=name,
account_number=account_number,
bank_code=bank_code,
).save()

def create_buyer(self, email_address, card_uri, name=None, meta=None):
meta = meta or {}
return Account(
Expand Down

0 comments on commit d60856f

Please sign in to comment.