| 1 | # vim: sw=4 ts=4 ft=perl | ||||||||||
| 2 | |||||||||||
| 3 | package # hide from pause | ||||||||||
| 4 | WebService::Braintree::Types; | ||||||||||
| 5 | |||||||||||
| 6 | 22 | ▶ | use 5.010_001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 22 | ▶ | use strictures 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 22 | ▶ | use Class::Load qw(try_load_class); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 22 | ▶ | use Hash::Inflator; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 22 | ▶ | use Type::Library -base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 22 | ▶ | use Type::Utils -all; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 22 | ▶ | use Types::Standard -types; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | # These are the ones that live in WS::BT::_ | ||||||||||
| 17 | 22 | my @obj_types = qw( | |||||||||
| 18 | AccountUpdaterDailyReport | ||||||||||
| 19 | AchMandate AddOn Address AmexExpressCheckoutCard AndroidPayCard | ||||||||||
| 20 | ApplePay ApplePayCard ApplePayOptions | ||||||||||
| 21 | AuthorizationAdjustment | ||||||||||
| 22 | BinData CoinbaseAccount | ||||||||||
| 23 | ConnectedMerchantPayPalStatusChanged | ||||||||||
| 24 | ConnectedMerchantStatusTransitioned | ||||||||||
| 25 | CreditCard CreditCardVerification Customer | ||||||||||
| 26 | Descriptor Disbursement Discount Dispute | ||||||||||
| 27 | DocumentUpload EuropeBankAccount GrantedPaymentInstrumentUpdate | ||||||||||
| 28 | IbanBankAccount IdealPayment MasterpassCard | ||||||||||
| 29 | Merchant MerchantAccount PaymentMethodNonce PaymentMethodNonceDetails | ||||||||||
| 30 | PayPalAccount Plan SettlementBatchSummary SettlementBatchSummaryRecord | ||||||||||
| 31 | Subscription ThreeDSecureInfo Transaction UnknownPaymentMethod | ||||||||||
| 32 | UsBankAccount VenmoAccount VisaCheckoutCard WebhookNotification | ||||||||||
| 33 | |||||||||||
| 34 | Dispute::Evidence Dispute::HistoryEvent | ||||||||||
| 35 | Dispute::Transaction Dispute::TransactionDetails | ||||||||||
| 36 | |||||||||||
| 37 | MerchantAccount::AddressDetails MerchantAccount::BusinessDetails | ||||||||||
| 38 | MerchantAccount::FundingDetails MerchantAccount::IndividualDetails | ||||||||||
| 39 | |||||||||||
| 40 | Subscription::StatusDetail | ||||||||||
| 41 | |||||||||||
| 42 | Transaction::AddressDetail | ||||||||||
| 43 | Transaction::AmexExpressCheckoutDetail | ||||||||||
| 44 | Transaction::AndroidPayDetail | ||||||||||
| 45 | Transaction::ApplePayDetail | ||||||||||
| 46 | Transaction::CoinbaseDetail | ||||||||||
| 47 | Transaction::CreditCardDetail | ||||||||||
| 48 | Transaction::CustomerDetail | ||||||||||
| 49 | Transaction::DisbursementDetail | ||||||||||
| 50 | Transaction::FacilitatedDetail | ||||||||||
| 51 | Transaction::FacilitatorDetail | ||||||||||
| 52 | Transaction::IdealPaymentDetail | ||||||||||
| 53 | Transaction::MasterpassCardDetail | ||||||||||
| 54 | Transaction::PayPalDetail | ||||||||||
| 55 | Transaction::RiskData | ||||||||||
| 56 | Transaction::StatusDetail | ||||||||||
| 57 | Transaction::SubscriptionDetail | ||||||||||
| 58 | Transaction::UsBankAccountDetail | ||||||||||
| 59 | Transaction::VenmoAccountDetail | ||||||||||
| 60 | Transaction::VisaCheckoutCardDetail | ||||||||||
| 61 | ); | ||||||||||
| 62 | |||||||||||
| 63 | # These are the ones that live in WS::BT | ||||||||||
| 64 | 22 | my @class_types = qw( | |||||||||
| 65 | ValidationErrorCollection | ||||||||||
| 66 | ErrorResult | ||||||||||
| 67 | ); | ||||||||||
| 68 | |||||||||||
| 69 | 22 | foreach my $type_proto (@obj_types) { | |||||||||
| 70 | 1562 | my $class = "WebService::Braintree::_::${type_proto}"; | |||||||||
| 71 | |||||||||||
| 72 | # Type names cannot have '::' in them, so convert that to '_' | ||||||||||
| 73 | 1562 | (my $type = $type_proto) =~ s/::/_/g; | |||||||||
| 74 | |||||||||||
| 75 | 1562 | class_type $type, { class => $class }; | |||||||||
| 76 | |||||||||||
| 77 | coerce $type, | ||||||||||
| 78 | 29 | ▶ | from HashRef, via { $class->new($_) }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | # These are unconverted classes | ||||||||||
| 82 | 22 | foreach my $type (@class_types) { | |||||||||
| 83 | 44 | my $class = "WebService::Braintree::${type}"; | |||||||||
| 84 | |||||||||||
| 85 | 44 | class_type $type, { class => $class }; | |||||||||
| 86 | |||||||||||
| 87 | coerce $type, | ||||||||||
| 88 | 2 | ▶ | from HashRef, via { $class->new($_) }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | 22 | class_type HashInflator => { class => 'Hash::Inflator' }; | |||||||||
| 92 | coerce HashInflator => | ||||||||||
| 93 | 3 | ▶ | from HashRef, via { Hash::Inflator->new($_) }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 94 | |||||||||||
| 95 | # Now, load all the classes here so they don't have to be loaded | ||||||||||
| 96 | # anywhere else. | ||||||||||
| 97 | |||||||||||
| 98 | 22 | foreach my $type_proto (@obj_types) { | |||||||||
| 99 | 1562 | my $class = "WebService::Braintree::_::${type_proto}"; | |||||||||
| 100 | |||||||||||
| 101 | 1562 | my ($ok, $error) = try_load_class($class); | |||||||||
| 102 | 1562 | ▶ | $ok ? $class->import : die $error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | } | ||||||||||
| 104 | |||||||||||
| 105 | 22 | foreach my $type_proto (@class_types) { | |||||||||
| 106 | 44 | my $class = "WebService::Braintree::${type_proto}"; | |||||||||
| 107 | |||||||||||
| 108 | 44 | my ($ok, $error) = try_load_class($class); | |||||||||
| 109 | 44 | ▶ | $ok ? $class->import : die $error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | 22 | 1; | |||||||||
| 113 | __END__ | ||||||||||