Created
February 9, 2012 00:42
-
-
Save ryonlife/1775940 to your computer and use it in GitHub Desktop.
Monkey patch Braintree's Python API wrapper so results/responses are serializable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from types import MethodType | |
import braintree | |
import jsonpickle | |
import json | |
def serialize(self): | |
""" Serialize a Braintree SuccessfulResult or ErrorResult object to a Python dict """ | |
return json.loads(jsonpickle.encode(self)) | |
braintree.ErrorResult.serialize = MethodType(serialize, None, braintree.ErrorResult) | |
braintree.SuccessfulResult.serialize = MethodType(serialize, None, braintree.SuccessfulResult) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment