<s> import urllib <EOL> import warnings <EOL> import sys <EOL> from stripe import api_requestor , error , util , upload_api_base <EOL> def convert_to_stripe_object ( resp , api_key , account ) : <EOL> types = { <EOL> '<STR_LIT>' : Account , <EOL> '<STR_LIT>' : ApplicationFee , <EOL> '<STR_LIT>' : BankAccount , <EOL> '<STR_LIT>' : BitcoinReceiver , <EOL> '<STR_LIT>' : BitcoinTransaction , <EOL> '<STR_LIT>' : Card , <EOL> '<STR_LIT>' : Charge , <EOL> '<STR_LIT>' : CountrySpec , <EOL> '<STR_LIT>' : Coupon , <EOL> '<STR_LIT>' : Customer , <EOL> '<STR_LIT>' : Dispute , <EOL> '<STR_LIT>' : Event , <EOL> '<STR_LIT>' : ApplicationFeeRefund , <EOL> '<STR_LIT>' : FileUpload , <EOL> '<STR_LIT>' : Invoice , <EOL> '<STR_LIT>' : InvoiceItem , <EOL> '<STR_LIT:list>' : ListObject , <EOL> '<STR_LIT>' : Plan , <EOL> '<STR_LIT>' : Recipient , <EOL> '<STR_LIT>' : Refund , <EOL> '<STR_LIT>' : Subscription , <EOL> '<STR_LIT>' : Token , <EOL> '<STR_LIT>' : Transfer , <EOL> '<STR_LIT>' : Reversal , <EOL> '<STR_LIT>' : Product , <EOL> '<STR_LIT>' : SKU , <EOL> '<STR_LIT>' : Order <EOL> } <EOL> if isinstance ( resp , list ) : <EOL> return [ convert_to_stripe_object ( i , api_key , account ) for i in resp ] <EOL> elif isinstance ( resp , dict ) and not isinstance ( resp , StripeObject ) : <EOL> resp = resp . copy ( ) <EOL> klass_name = resp . get ( '<STR_LIT:object>' ) <EOL> if isinstance ( klass_name , basestring ) : <EOL> klass = types . get ( klass_name , StripeObject ) <EOL> else : <EOL> klass = StripeObject <EOL> return klass . construct_from ( resp , api_key , stripe_account = account ) <EOL> else : <EOL> return resp <EOL> def populate_headers ( idempotency_key ) : <EOL> if idempotency_key is not None : <EOL> return { "<STR_LIT>" : idempotency_key } <EOL> return None <EOL> def _compute_diff ( current , previous ) : <EOL> if isinstance ( current , dict ) : <EOL> previous = previous or { } <EOL> diff = current . copy ( ) <EOL> for key in set ( previous . keys ( ) ) - set ( diff . keys ( ) ) : <EOL> diff [ key ] = "<STR_LIT>" <EOL> return diff <EOL> return current if current is not None else "<STR_LIT>" <EOL> def _serialize_list ( array , previous ) : <EOL> array = array or [ ] <EOL> previous = previous or [ ] <EOL> params = { } <EOL> for i , v in enumerate ( array ) : <EOL> previous_item = previous [ i ] if len ( previous ) > i else None <EOL> if hasattr ( v , '<STR_LIT>' ) : <EOL> params [ str ( i ) ] = v . serialize ( previous_item ) <EOL> else : <EOL> params [ str ( i ) ] = _compute_diff ( v , previous_item ) <EOL> return params <EOL> class StripeObject ( dict ) : <EOL> def __init__ ( self , id = None , api_key = None , stripe_account = None , ** params ) : <EOL> super ( StripeObject , self ) . __init__ ( ) <EOL> self . _unsaved_values = set ( ) <EOL> self . _transient_values = set ( ) <EOL> self . _retrieve_params = params <EOL> self . _previous = None <EOL> object . __setattr__ ( self , '<STR_LIT>' , api_key ) <EOL> object . __setattr__ ( self , '<STR_LIT>' , stripe_account ) <EOL> if id : <EOL> self [ '<STR_LIT:id>' ] = id <EOL> def update ( self , update_dict ) : <EOL> for k in update_dict : <EOL> self . _unsaved_values . add ( k ) <EOL> return super ( StripeObject , self ) . update ( update_dict ) <EOL> def __setattr__ ( self , k , v ) : <EOL> if k [ <NUM_LIT:0> ] == '<STR_LIT:_>' or k in self . __dict__ : <EOL> return super ( StripeObject , self ) . __setattr__ ( k , v ) <EOL> else : <EOL> self [ k ] = v <EOL> def __getattr__ ( self , k ) : <EOL> if k [ <NUM_LIT:0> ] == '<STR_LIT:_>' : <EOL> raise AttributeError ( k ) <EOL> try : <EOL> return self [ k ] <EOL> except KeyError as err : <EOL> raise AttributeError ( * err . args ) <EOL> def __delattr__ ( self , k ) : <EOL> if k [ <NUM_LIT:0> ] == '<STR_LIT:_>' or k in self . __dict__ : <EOL> return super ( StripeObject , self ) . __delattr__ ( k ) <EOL> else : <EOL> del self [ k ] <EOL> def __setitem__ ( self , k , v ) : <EOL> if v == "<STR_LIT>" : <EOL> raise ValueError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( <EOL> k , str ( self ) , k ) ) <EOL> super ( StripeObject , self ) . __setitem__ ( k , v ) <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . _unsaved_values = set ( ) <EOL> self . _unsaved_values . add ( k ) <EOL> def __getitem__ ( self , k ) : <EOL> try : <EOL> return super ( StripeObject , self ) . __getitem__ ( k ) <EOL> except KeyError as err : <EOL> if k in self . _transient_values : <EOL> raise KeyError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( k , k , '<STR_LIT:U+002CU+0020>' . join ( self . keys ( ) ) ) ) <EOL> else : <EOL> raise err <EOL> def __delitem__ ( self , k ) : <EOL> super ( StripeObject , self ) . __delitem__ ( k ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> self . _unsaved_values . remove ( k ) <EOL> @ classmethod <EOL> def construct_from ( cls , values , key , stripe_account = None ) : <EOL> instance = cls ( values . get ( '<STR_LIT:id>' ) , api_key = key , <EOL> stripe_account = stripe_account ) <EOL> instance . refresh_from ( values , api_key = key , <EOL> stripe_account = stripe_account ) <EOL> return instance <EOL> def refresh_from ( self , values , api_key = None , partial = False , <EOL> stripe_account = None ) : <EOL> self . api_key = api_key or getattr ( values , '<STR_LIT>' , None ) <EOL> self . stripe_account = stripe_account or getattr ( values , '<STR_LIT>' , None ) <EOL> if partial : <EOL> self . _unsaved_values = ( self . _unsaved_values - set ( values ) ) <EOL> else : <EOL> removed = set ( self . keys ( ) ) - set ( values ) <EOL> self . _transient_values = self . _transient_values | removed <EOL> self . _unsaved_values = set ( ) <EOL> self . clear ( ) <EOL> self . _transient_values = self . _transient_values - set ( values ) <EOL> for k , v in values . iteritems ( ) : <EOL> super ( StripeObject , self ) . __setitem__ ( <EOL> k , convert_to_stripe_object ( v , api_key , stripe_account ) ) <EOL> self . _previous = values <EOL> @ classmethod <EOL> def api_base ( cls ) : <EOL> return None <EOL> def request ( self , method , url , params = None , headers = None ) : <EOL> if params is None : <EOL> params = self . _retrieve_params <EOL> requestor = api_requestor . APIRequestor ( <EOL> key = self . api_key , api_base = self . api_base ( ) , <EOL> account = self . stripe_account ) <EOL> response , api_key = requestor . request ( method , url , params , headers ) <EOL> return convert_to_stripe_object ( response , api_key , self . stripe_account ) <EOL> def __repr__ ( self ) : <EOL> ident_parts = [ type ( self ) . __name__ ] <EOL> if isinstance ( self . get ( '<STR_LIT:object>' ) , basestring ) : <EOL> ident_parts . append ( self . get ( '<STR_LIT:object>' ) ) <EOL> if isinstance ( self . get ( '<STR_LIT:id>' ) , basestring ) : <EOL> ident_parts . append ( '<STR_LIT>' % ( self . get ( '<STR_LIT:id>' ) , ) ) <EOL> unicode_repr = '<STR_LIT>' % ( <EOL> '<STR_LIT:U+0020>' . join ( ident_parts ) , hex ( id ( self ) ) , str ( self ) ) <EOL> if sys . version_info [ <NUM_LIT:0> ] < <NUM_LIT:3> : <EOL> return unicode_repr . encode ( '<STR_LIT:utf-8>' ) <EOL> else : <EOL> return unicode_repr <EOL> def __str__ ( self ) : <EOL> return util . json . dumps ( self , sort_keys = True , indent = <NUM_LIT:2> ) <EOL> def to_dict ( self ) : <EOL> warnings . warn ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> DeprecationWarning ) <EOL> return dict ( self ) <EOL> @ property <EOL> def stripe_id ( self ) : <EOL> return self . id <EOL> def serialize ( self , previous ) : <EOL> params = { } <EOL> unsaved_keys = self . _unsaved_values or set ( ) <EOL> previous = previous or self . _previous or { } <EOL> for k , v in self . items ( ) : <EOL> if k == '<STR_LIT:id>' or ( isinstance ( k , str ) and k . startswith ( '<STR_LIT:_>' ) ) : <EOL> continue <EOL> elif isinstance ( v , APIResource ) : <EOL> continue <EOL> elif hasattr ( v , '<STR_LIT>' ) : <EOL> params [ k ] = v . serialize ( previous . get ( k , None ) ) <EOL> elif k in unsaved_keys : <EOL> params [ k ] = _compute_diff ( v , previous . get ( k , None ) ) <EOL> elif k == '<STR_LIT>' and v is not None : <EOL> params [ k ] = _serialize_list ( v , previous . get ( k , None ) ) <EOL> return params <EOL> class StripeObjectEncoder ( util . json . JSONEncoder ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> warnings . warn ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> DeprecationWarning ) <EOL> super ( StripeObjectEncoder , self ) . __init__ ( * args , ** kwargs ) <EOL> class APIResource ( StripeObject ) : <EOL> @ classmethod <EOL> def retrieve ( cls , id , api_key = None , ** params ) : <EOL> instance = cls ( id , api_key , ** params ) <EOL> instance . refresh ( ) <EOL> return instance <EOL> def refresh ( self ) : <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , self . instance_url ( ) ) ) <EOL> return self <EOL> @ classmethod <EOL> def class_name ( cls ) : <EOL> if cls == APIResource : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> return str ( urllib . quote_plus ( cls . __name__ . lower ( ) ) ) <EOL> @ classmethod <EOL> def class_url ( cls ) : <EOL> cls_name = cls . class_name ( ) <EOL> return "<STR_LIT>" % ( cls_name , ) <EOL> def instance_url ( self ) : <EOL> id = self . get ( '<STR_LIT:id>' ) <EOL> if not id : <EOL> raise error . InvalidRequestError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( type ( self ) . __name__ , id ) , '<STR_LIT:id>' ) <EOL> id = util . utf8 ( id ) <EOL> base = self . class_url ( ) <EOL> extn = urllib . quote_plus ( id ) <EOL> return "<STR_LIT>" % ( base , extn ) <EOL> class ListObject ( StripeObject ) : <EOL> def list ( self , ** params ) : <EOL> return self . request ( '<STR_LIT>' , self [ '<STR_LIT:url>' ] , params ) <EOL> def all ( self , ** params ) : <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> DeprecationWarning ) <EOL> return self . list ( ** params ) <EOL> def auto_paging_iter ( self ) : <EOL> page = self <EOL> params = dict ( self . _retrieve_params ) <EOL> while True : <EOL> item_id = None <EOL> for item in page : <EOL> item_id = item . get ( '<STR_LIT:id>' , None ) <EOL> yield item <EOL> if not getattr ( page , '<STR_LIT>' , False ) or item_id is None : <EOL> return <EOL> params [ '<STR_LIT>' ] = item_id <EOL> page = self . list ( ** params ) <EOL> def create ( self , idempotency_key = None , ** params ) : <EOL> headers = populate_headers ( idempotency_key ) <EOL> return self . request ( '<STR_LIT>' , self [ '<STR_LIT:url>' ] , params , headers ) <EOL> def retrieve ( self , id , ** params ) : <EOL> base = self . get ( '<STR_LIT:url>' ) <EOL> id = util . utf8 ( id ) <EOL> extn = urllib . quote_plus ( id ) <EOL> url = "<STR_LIT>" % ( base , extn ) <EOL> return self . request ( '<STR_LIT>' , url , params ) <EOL> def __iter__ ( self ) : <EOL> return getattr ( self , '<STR_LIT:data>' , [ ] ) . __iter__ ( ) <EOL> class SingletonAPIResource ( APIResource ) : <EOL> @ classmethod <EOL> def retrieve ( cls , ** params ) : <EOL> return super ( SingletonAPIResource , cls ) . retrieve ( None , ** params ) <EOL> @ classmethod <EOL> def class_url ( cls ) : <EOL> cls_name = cls . class_name ( ) <EOL> return "<STR_LIT>" % ( cls_name , ) <EOL> def instance_url ( self ) : <EOL> return self . class_url ( ) <EOL> class ListableAPIResource ( APIResource ) : <EOL> @ classmethod <EOL> def all ( cls , * args , ** params ) : <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> DeprecationWarning ) <EOL> return cls . list ( * args , ** params ) <EOL> @ classmethod <EOL> def auto_paging_iter ( self , * args , ** params ) : <EOL> return self . list ( * args , ** params ) . auto_paging_iter ( ) <EOL> @ classmethod <EOL> def list ( cls , api_key = None , idempotency_key = None , <EOL> stripe_account = None , ** params ) : <EOL> requestor = api_requestor . APIRequestor ( api_key , <EOL> api_base = cls . api_base ( ) , <EOL> account = stripe_account ) <EOL> url = cls . class_url ( ) <EOL> response , api_key = requestor . request ( '<STR_LIT>' , url , params ) <EOL> stripe_object = convert_to_stripe_object ( response , api_key , <EOL> stripe_account ) <EOL> stripe_object . _retrieve_params = params <EOL> return stripe_object <EOL> class CreateableAPIResource ( APIResource ) : <EOL> @ classmethod <EOL> def create ( cls , api_key = None , idempotency_key = None , <EOL> stripe_account = None , ** params ) : <EOL> requestor = api_requestor . APIRequestor ( api_key , account = stripe_account ) <EOL> url = cls . class_url ( ) <EOL> headers = populate_headers ( idempotency_key ) <EOL> response , api_key = requestor . request ( '<STR_LIT>' , url , params , headers ) <EOL> return convert_to_stripe_object ( response , api_key , stripe_account ) <EOL> class UpdateableAPIResource ( APIResource ) : <EOL> def save ( self , idempotency_key = None ) : <EOL> updated_params = self . serialize ( None ) <EOL> headers = populate_headers ( idempotency_key ) <EOL> if updated_params : <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , self . instance_url ( ) , <EOL> updated_params , headers ) ) <EOL> else : <EOL> util . logger . debug ( "<STR_LIT>" , self ) <EOL> return self <EOL> class DeletableAPIResource ( APIResource ) : <EOL> def delete ( self , ** params ) : <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , self . instance_url ( ) , params ) ) <EOL> return self <EOL> class Account ( CreateableAPIResource , ListableAPIResource , <EOL> UpdateableAPIResource , DeletableAPIResource ) : <EOL> @ classmethod <EOL> def retrieve ( cls , id = None , api_key = None , ** params ) : <EOL> instance = cls ( id , api_key , ** params ) <EOL> instance . refresh ( ) <EOL> return instance <EOL> def instance_url ( self ) : <EOL> id = self . get ( '<STR_LIT:id>' ) <EOL> if not id : <EOL> return "<STR_LIT>" <EOL> id = util . utf8 ( id ) <EOL> base = self . class_url ( ) <EOL> extn = urllib . quote_plus ( id ) <EOL> return "<STR_LIT>" % ( base , extn ) <EOL> def reject ( self , reason = None , idempotency_key = None ) : <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> if reason : <EOL> params = { "<STR_LIT>" : reason } <EOL> else : <EOL> params = { } <EOL> self . refresh_from ( <EOL> self . request ( '<STR_LIT>' , url , params , headers ) <EOL> ) <EOL> return self <EOL> class Balance ( SingletonAPIResource ) : <EOL> pass <EOL> class BalanceTransaction ( ListableAPIResource ) : <EOL> @ classmethod <EOL> def class_url ( cls ) : <EOL> return '<STR_LIT>' <EOL> class Card ( UpdateableAPIResource , DeletableAPIResource ) : <EOL> def instance_url ( self ) : <EOL> token = util . utf8 ( self . id ) <EOL> extn = urllib . quote_plus ( token ) <EOL> if ( hasattr ( self , '<STR_LIT>' ) ) : <EOL> customer = util . utf8 ( self . customer ) <EOL> base = Customer . class_url ( ) <EOL> owner_extn = urllib . quote_plus ( customer ) <EOL> class_base = "<STR_LIT>" <EOL> elif ( hasattr ( self , '<STR_LIT>' ) ) : <EOL> recipient = util . utf8 ( self . recipient ) <EOL> base = Recipient . class_url ( ) <EOL> owner_extn = urllib . quote_plus ( recipient ) <EOL> class_base = "<STR_LIT>" <EOL> elif ( hasattr ( self , '<STR_LIT>' ) ) : <EOL> account = util . utf8 ( self . account ) <EOL> base = Account . class_url ( ) <EOL> owner_extn = urllib . quote_plus ( account ) <EOL> class_base = "<STR_LIT>" <EOL> else : <EOL> raise error . InvalidRequestError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % token , '<STR_LIT:id>' ) <EOL> return "<STR_LIT>" % ( base , owner_extn , class_base , extn ) <EOL> @ classmethod <EOL> def retrieve ( cls , id , api_key = None , stripe_account = None , ** params ) : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class VerifyMixin ( object ) : <EOL> def verify ( self , idempotency_key = None , ** params ) : <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , url , params , headers ) ) <EOL> return self <EOL> class BankAccount ( UpdateableAPIResource , DeletableAPIResource , VerifyMixin ) : <EOL> def instance_url ( self ) : <EOL> token = util . utf8 ( self . id ) <EOL> extn = urllib . quote_plus ( token ) <EOL> if ( hasattr ( self , '<STR_LIT>' ) ) : <EOL> customer = util . utf8 ( self . customer ) <EOL> base = Customer . class_url ( ) <EOL> owner_extn = urllib . quote_plus ( customer ) <EOL> class_base = "<STR_LIT>" <EOL> elif ( hasattr ( self , '<STR_LIT>' ) ) : <EOL> account = util . utf8 ( self . account ) <EOL> base = Account . class_url ( ) <EOL> owner_extn = urllib . quote_plus ( account ) <EOL> class_base = "<STR_LIT>" <EOL> else : <EOL> raise error . InvalidRequestError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % token , '<STR_LIT:id>' ) <EOL> return "<STR_LIT>" % ( base , owner_extn , class_base , extn ) <EOL> @ classmethod <EOL> def retrieve ( cls , id , api_key = None , stripe_account = None , ** params ) : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class Charge ( CreateableAPIResource , ListableAPIResource , <EOL> UpdateableAPIResource ) : <EOL> def refund ( self , idempotency_key = None , ** params ) : <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , url , params , headers ) ) <EOL> return self <EOL> def capture ( self , idempotency_key = None , ** params ) : <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , url , params , headers ) ) <EOL> return self <EOL> def update_dispute ( self , idempotency_key = None , ** params ) : <EOL> requestor = api_requestor . APIRequestor ( self . api_key , <EOL> account = self . stripe_account ) <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> response , api_key = requestor . request ( '<STR_LIT>' , url , params , headers ) <EOL> self . refresh_from ( { '<STR_LIT>' : response } , api_key , True ) <EOL> return self . dispute <EOL> def close_dispute ( self , idempotency_key = None ) : <EOL> requestor = api_requestor . APIRequestor ( self . api_key , <EOL> account = self . stripe_account ) <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> response , api_key = requestor . request ( '<STR_LIT>' , url , { } , headers ) <EOL> self . refresh_from ( { '<STR_LIT>' : response } , api_key , True ) <EOL> return self . dispute <EOL> def mark_as_fraudulent ( self , idempotency_key = None ) : <EOL> params = { <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } <EOL> } <EOL> url = self . instance_url ( ) <EOL> headers = populate_headers ( idempotency_key ) <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , url , params , headers ) ) <EOL> return self <EOL> def mark_as_safe ( self , idempotency_key = None ) : <EOL> params = { <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } <EOL> } <EOL> url = self . instance_url ( ) <EOL> headers = populate_headers ( idempotency_key ) <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , url , params , headers ) ) <EOL> return self <EOL> class Dispute ( CreateableAPIResource , ListableAPIResource , <EOL> UpdateableAPIResource ) : <EOL> def close ( self , idempotency_key = None ) : <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , url , { } , headers ) ) <EOL> return self <EOL> class Customer ( CreateableAPIResource , UpdateableAPIResource , <EOL> ListableAPIResource , DeletableAPIResource ) : <EOL> def add_invoice_item ( self , idempotency_key = None , ** params ) : <EOL> params [ '<STR_LIT>' ] = self . id <EOL> ii = InvoiceItem . create ( self . api_key , <EOL> idempotency_key = idempotency_key , ** params ) <EOL> return ii <EOL> def invoices ( self , ** params ) : <EOL> params [ '<STR_LIT>' ] = self . id <EOL> invoices = Invoice . list ( self . api_key , ** params ) <EOL> return invoices <EOL> def invoice_items ( self , ** params ) : <EOL> params [ '<STR_LIT>' ] = self . id <EOL> iis = InvoiceItem . list ( self . api_key , ** params ) <EOL> return iis <EOL> def charges ( self , ** params ) : <EOL> params [ '<STR_LIT>' ] = self . id <EOL> charges = Charge . list ( self . api_key , ** params ) <EOL> return charges <EOL> def update_subscription ( self , idempotency_key = None , ** params ) : <EOL> warnings . warn ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> DeprecationWarning ) <EOL> requestor = api_requestor . APIRequestor ( self . api_key , <EOL> account = self . stripe_account ) <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> response , api_key = requestor . request ( '<STR_LIT>' , url , params , headers ) <EOL> self . refresh_from ( { '<STR_LIT>' : response } , api_key , True ) <EOL> return self . subscription <EOL> def cancel_subscription ( self , idempotency_key = None , ** params ) : <EOL> warnings . warn ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> DeprecationWarning ) <EOL> requestor = api_requestor . APIRequestor ( self . api_key , <EOL> account = self . stripe_account ) <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> headers = populate_headers ( idempotency_key ) <EOL> response , api_key = requestor . request ( '<STR_LIT>' , url , params , headers ) <EOL> self . refresh_from ( { '<STR_LIT>' : response } , api_key , True ) <EOL> return self . subscription <EOL> def delete_discount ( self , ** params ) : <EOL> requestor = api_requestor . APIRequestor ( self . api_key , <EOL> account = self . stripe_account ) <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> _ , api_key = requestor . request ( '<STR_LIT>' , url ) <EOL> self . refresh_from ( { '<STR_LIT>' : None } , api_key , True ) <EOL> class Invoice ( CreateableAPIResource , ListableAPIResource , <EOL> UpdateableAPIResource ) : <EOL> def pay ( self , idempotency_key = None ) : <EOL> headers = populate_headers ( idempotency_key ) <EOL> return self . request ( '<STR_LIT>' , self . instance_url ( ) + '<STR_LIT>' , { } , headers ) <EOL> @ classmethod <EOL> def upcoming ( cls , api_key = None , stripe_account = None , ** params ) : <EOL> requestor = api_requestor . APIRequestor ( api_key , <EOL> account = stripe_account ) <EOL> url = cls . class_url ( ) + '<STR_LIT>' <EOL> response , api_key = requestor . request ( '<STR_LIT>' , url , params ) <EOL> return convert_to_stripe_object ( response , api_key , stripe_account ) <EOL> class InvoiceItem ( CreateableAPIResource , UpdateableAPIResource , <EOL> ListableAPIResource , DeletableAPIResource ) : <EOL> pass <EOL> class Plan ( CreateableAPIResource , DeletableAPIResource , <EOL> UpdateableAPIResource , ListableAPIResource ) : <EOL> pass <EOL> class Subscription ( UpdateableAPIResource , DeletableAPIResource ) : <EOL> def instance_url ( self ) : <EOL> token = util . utf8 ( self . id ) <EOL> customer = util . utf8 ( self . customer ) <EOL> base = Customer . class_url ( ) <EOL> cust_extn = urllib . quote_plus ( customer ) <EOL> extn = urllib . quote_plus ( token ) <EOL> return "<STR_LIT>" % ( base , cust_extn , extn ) <EOL> @ classmethod <EOL> def retrieve ( cls , id , api_key = None , ** params ) : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def delete_discount ( self , ** params ) : <EOL> requestor = api_requestor . APIRequestor ( self . api_key , <EOL> account = self . stripe_account ) <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> _ , api_key = requestor . request ( '<STR_LIT>' , url ) <EOL> self . refresh_from ( { '<STR_LIT>' : None } , api_key , True ) <EOL> class Refund ( CreateableAPIResource , ListableAPIResource , <EOL> UpdateableAPIResource ) : <EOL> pass <EOL> class Token ( CreateableAPIResource ) : <EOL> pass <EOL> class Coupon ( CreateableAPIResource , UpdateableAPIResource , <EOL> DeletableAPIResource , ListableAPIResource ) : <EOL> pass <EOL> class Event ( ListableAPIResource ) : <EOL> pass <EOL> class Transfer ( CreateableAPIResource , UpdateableAPIResource , <EOL> ListableAPIResource ) : <EOL> def cancel ( self ) : <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , <EOL> self . instance_url ( ) + '<STR_LIT>' ) ) <EOL> class Reversal ( UpdateableAPIResource ) : <EOL> def instance_url ( self ) : <EOL> token = util . utf8 ( self . id ) <EOL> transfer = util . utf8 ( self . transfer ) <EOL> base = Transfer . class_url ( ) <EOL> cust_extn = urllib . quote_plus ( transfer ) <EOL> extn = urllib . quote_plus ( token ) <EOL> return "<STR_LIT>" % ( base , cust_extn , extn ) <EOL> @ classmethod <EOL> def retrieve ( cls , id , api_key = None , ** params ) : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class Recipient ( CreateableAPIResource , UpdateableAPIResource , <EOL> ListableAPIResource , DeletableAPIResource ) : <EOL> def transfers ( self , ** params ) : <EOL> params [ '<STR_LIT>' ] = self . id <EOL> transfers = Transfer . list ( self . api_key , ** params ) <EOL> return transfers <EOL> class FileUpload ( ListableAPIResource ) : <EOL> @ classmethod <EOL> def api_base ( cls ) : <EOL> return upload_api_base <EOL> @ classmethod <EOL> def class_name ( cls ) : <EOL> return '<STR_LIT:file>' <EOL> @ classmethod <EOL> def create ( cls , api_key = None , stripe_account = None , ** params ) : <EOL> requestor = api_requestor . APIRequestor ( <EOL> api_key , api_base = cls . api_base ( ) , account = stripe_account ) <EOL> url = cls . class_url ( ) <EOL> supplied_headers = { <EOL> "<STR_LIT:Content-Type>" : "<STR_LIT>" <EOL> } <EOL> response , api_key = requestor . request ( <EOL> '<STR_LIT>' , url , params = params , headers = supplied_headers ) <EOL> return convert_to_stripe_object ( response , api_key , stripe_account ) <EOL> class ApplicationFee ( ListableAPIResource ) : <EOL> @ classmethod <EOL> def class_name ( cls ) : <EOL> return '<STR_LIT>' <EOL> def refund ( self , idempotency_key = None , ** params ) : <EOL> headers = populate_headers ( idempotency_key ) <EOL> url = self . instance_url ( ) + '<STR_LIT>' <EOL> self . refresh_from ( self . request ( '<STR_LIT>' , url , params , headers ) ) <EOL> return self <EOL> class ApplicationFeeRefund ( UpdateableAPIResource ) : <EOL> def instance_url ( self ) : <EOL> token = util . utf8 ( self . id ) <EOL> fee = util . utf8 ( self . fee ) <EOL> base = ApplicationFee . class_url ( ) <EOL> cust_extn = urllib . quote_plus ( fee ) <EOL> extn = urllib . quote_plus ( token ) <EOL> return "<STR_LIT>" % ( base , cust_extn , extn ) <EOL> @ classmethod <EOL> def retrieve ( cls , id , api_key = None , ** params ) : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> class BitcoinReceiver ( CreateableAPIResource , UpdateableAPIResource , <EOL> DeletableAPIResource , ListableAPIResource ) : <EOL> def instance_url ( self ) : <EOL> token = util . utf8 ( self . id ) <EOL> extn = urllib . quote_plus ( token ) <EOL> if ( hasattr ( self , '<STR_LIT>' ) ) : <EOL> customer = util . utf8 ( self . customer ) <EOL> base = Customer . class_url ( ) <EOL> cust_extn = urllib . quote_plus ( customer ) <EOL> return "<STR_LIT>" % ( base , cust_extn , extn ) <EOL> else : <EOL> base = BitcoinReceiver . class_url ( ) <EOL> return "<STR_LIT>" % ( base , extn ) <EOL> @ classmethod <EOL> def class_url ( cls ) : <EOL> return '<STR_LIT>' <EOL> class BitcoinTransaction ( StripeObject ) : <EOL> pass <EOL> class Product ( CreateableAPIResource , UpdateableAPIResource , <EOL> ListableAPIResource , DeletableAPIResource ) : <EOL> pass <EOL> class SKU ( CreateableAPIResource , UpdateableAPIResource , <EOL> ListableAPIResource , DeletableAPIResource ) : <EOL> pass <EOL> class Order ( CreateableAPIResource , UpdateableAPIResource , <EOL> ListableAPIResource ) : <EOL> def pay ( self , idempotency_key = None , ** params ) : <EOL> headers = populate_headers ( idempotency_key ) <EOL> return self . request ( <EOL> '<STR_LIT>' , self . instance_url ( ) + '<STR_LIT>' , params , headers ) <EOL> class CountrySpec ( ListableAPIResource ) : <EOL> @ classmethod <EOL> def class_name ( cls ) : <EOL> return '<STR_LIT>' </s>
