<s> from decimal import Decimal <EOL> from braintree . util . http import Http <EOL> import braintree <EOL> import warnings <EOL> from braintree . add_on import AddOn <EOL> from braintree . descriptor import Descriptor <EOL> from braintree . discount import Discount <EOL> from braintree . exceptions . not_found_error import NotFoundError <EOL> from braintree . resource_collection import ResourceCollection <EOL> from braintree . subscription_status_event import SubscriptionStatusEvent <EOL> from braintree . successful_result import SuccessfulResult <EOL> from braintree . error_result import ErrorResult <EOL> from braintree . transaction import Transaction <EOL> from braintree . resource import Resource <EOL> from braintree . configuration import Configuration <EOL> class Subscription ( Resource ) : <EOL> """<STR_LIT>""" <EOL> class TrialDurationUnit ( object ) : <EOL> """<STR_LIT>""" <EOL> Day = "<STR_LIT>" <EOL> Month = "<STR_LIT>" <EOL> class Source ( object ) : <EOL> Api = "<STR_LIT>" <EOL> ControlPanel = "<STR_LIT>" <EOL> Recurring = "<STR_LIT>" <EOL> Unrecognized = "<STR_LIT>" <EOL> class Status ( object ) : <EOL> """<STR_LIT>""" <EOL> Active = "<STR_LIT>" <EOL> Canceled = "<STR_LIT>" <EOL> Expired = "<STR_LIT>" <EOL> PastDue = "<STR_LIT>" <EOL> Pending = "<STR_LIT>" <EOL> @ staticmethod <EOL> def create ( params = { } ) : <EOL> """<STR_LIT>""" <EOL> return Configuration . gateway ( ) . subscription . create ( params ) <EOL> @ staticmethod <EOL> def create_signature ( ) : <EOL> return [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT:id>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> { <EOL> "<STR_LIT>" : [ "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT:url>" ] <EOL> } , <EOL> { <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] <EOL> } <EOL> ] + Subscription . _add_ons_discounts_signature ( ) <EOL> @ staticmethod <EOL> def find ( subscription_id ) : <EOL> """<STR_LIT>""" <EOL> return Configuration . gateway ( ) . subscription . find ( subscription_id ) <EOL> @ staticmethod <EOL> def retryCharge ( subscription_id , amount = None ) : <EOL> warnings . warn ( "<STR_LIT>" , DeprecationWarning ) <EOL> return Subscription . retry_charge ( subscription_id , amount ) <EOL> @ staticmethod <EOL> def retry_charge ( subscription_id , amount = None ) : <EOL> return Configuration . gateway ( ) . subscription . retry_charge ( subscription_id , amount ) <EOL> @ staticmethod <EOL> def update ( subscription_id , params = { } ) : <EOL> """<STR_LIT>""" <EOL> return Configuration . gateway ( ) . subscription . update ( subscription_id , params ) <EOL> @ staticmethod <EOL> def cancel ( subscription_id ) : <EOL> """<STR_LIT>""" <EOL> return Configuration . gateway ( ) . subscription . cancel ( subscription_id ) <EOL> @ staticmethod <EOL> def search ( * query ) : <EOL> """<STR_LIT>""" <EOL> return Configuration . gateway ( ) . subscription . search ( * query ) <EOL> @ staticmethod <EOL> def update_signature ( ) : <EOL> return [ <EOL> "<STR_LIT:id>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> { <EOL> "<STR_LIT>" : [ "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT:url>" ] <EOL> } , <EOL> { <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> } <EOL> ] + Subscription . _add_ons_discounts_signature ( ) <EOL> @ staticmethod <EOL> def _add_ons_discounts_signature ( ) : <EOL> return [ <EOL> { <EOL> "<STR_LIT>" : [ { <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> } ] , <EOL> "<STR_LIT>" : [ { <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> } ] <EOL> } <EOL> ] <EOL> def __init__ ( self , gateway , attributes ) : <EOL> if "<STR_LIT>" in attributes : <EOL> self . _next_bill_amount = Decimal ( attributes [ "<STR_LIT>" ] ) <EOL> del ( attributes [ "<STR_LIT>" ] ) <EOL> Resource . __init__ ( self , gateway , attributes ) <EOL> if "<STR_LIT>" in attributes : <EOL> self . price = Decimal ( self . price ) <EOL> if "<STR_LIT>" in attributes : <EOL> self . balance = Decimal ( self . balance ) <EOL> if "<STR_LIT>" in attributes : <EOL> self . next_billing_period_amount = Decimal ( self . next_billing_period_amount ) <EOL> if "<STR_LIT>" in attributes : <EOL> self . add_ons = [ AddOn ( gateway , add_on ) for add_on in self . add_ons ] <EOL> if "<STR_LIT>" in attributes : <EOL> self . descriptor = Descriptor ( gateway , attributes . pop ( "<STR_LIT>" ) ) <EOL> if "<STR_LIT>" in attributes : <EOL> self . discounts = [ Discount ( gateway , discount ) for discount in self . discounts ] <EOL> if "<STR_LIT>" in attributes : <EOL> self . status_history = [ SubscriptionStatusEvent ( gateway , status_event ) for status_event in self . status_history ] <EOL> if "<STR_LIT>" in attributes : <EOL> self . transactions = [ Transaction ( gateway , transaction ) for transaction in self . transactions ] <EOL> @ property <EOL> def next_bill_amount ( self ) : <EOL> warnings . warn ( "<STR_LIT>" , DeprecationWarning ) <EOL> return self . _next_bill_amount </s>
