diff --git a/braintree/dispute.py b/braintree/dispute.py index b8e12c1b..4437c14f 100644 --- a/braintree/dispute.py +++ b/braintree/dispute.py @@ -5,7 +5,15 @@ from braintree.dispute_details import DisputeEvidence, DisputeStatusHistory, DisputePayPalMessage from braintree.configuration import Configuration -class Dispute(AttributeGetter): + +class _DisputeType(type): + @property + def ChargebackProtectionLevel(cls): + warnings.warn("Use ProtectionLevel enum instead", DeprecationWarning) + return cls._ChargebackProtectionLevel + + +class Dispute(AttributeGetter, metaclass=_DisputeType): # NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+ class Status(object): """ @@ -72,7 +80,7 @@ class Kind(object): Retrieval = "retrieval" # NEXT_MAJOR_VERSION Remove this enum - class ChargebackProtectionLevel(object): + class _ChargebackProtectionLevel(object): """ Constants representing dispute ChargebackProtectionLevel. Available types are: @@ -80,11 +88,14 @@ class ChargebackProtectionLevel(object): * braintree.Dispute.ChargebackProtectionLevel.STANDARD * braintree.Dispute.ChargebackProtectionLevel.NOT_PROTECTED """ - warnings.warn("Use ProtectionLevel enum instead", DeprecationWarning) Effortless = "effortless" Standard = "standard" NotProtected = "not_protected" + @property + def ChargebackProtectionLevel(self): + return self.__class__.ChargebackProtectionLevel + # NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+ class PreDisputeProgram(object): """ diff --git a/braintree/dispute_search.py b/braintree/dispute_search.py index 821d71b1..02da334e 100644 --- a/braintree/dispute_search.py +++ b/braintree/dispute_search.py @@ -1,12 +1,24 @@ +import warnings + from braintree.search import Search -class DisputeSearch: + +class _DisputeSearchType(type): + @property + def chargeback_protection_level(cls): + warnings.warn("Use protection_level parameter instead", DeprecationWarning) + return cls._chargeback_protection_level + + +class DisputeSearch(metaclass=_DisputeSearchType): amount_disputed = Search.RangeNodeBuilder("amount_disputed") amount_won = Search.RangeNodeBuilder("amount_won") case_number = Search.TextNodeBuilder("case_number") # NEXT_MAJOR_VERSION Remove this attribute # DEPRECATED The chargeback_protection_level attribute is deprecated in favor of protection_level - chargeback_protection_level = Search.MultipleValueNodeBuilder("chargeback_protection_level") + with warnings.catch_warnings(): + warnings.simplefilter('ignore') + _chargeback_protection_level = Search.MultipleValueNodeBuilder("chargeback_protection_level") protection_level = Search.MultipleValueNodeBuilder("protection_level") customer_id = Search.TextNodeBuilder("customer_id") disbursement_date = Search.RangeNodeBuilder("disbursement_date")