-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
Description
in some methods we _post()
passed arguments directly:
Lines 481 to 492 in 646861d
} elsif (defined($customer)) { | |
my %args = ( | |
account_balance => $account_balance, | |
card => $card, | |
coupon => $coupon, | |
default_card => $default_card, | |
email => $email, | |
metadata => $metadata, | |
); | |
return $self->_post("customers/" . $customer, \%args); | |
} |
but in doing so, we are unable to take advantage of any magic that happens during objectification:
stripe-perl/lib/Net/Stripe/Resource.pm
Lines 22 to 26 in 646861d
for my $f (qw/card default_card/) { | |
next unless $args{$f}; | |
next unless ref($args{$f}) eq 'HASH'; | |
$args{$f} = Net::Stripe::Card->new($args{$f}); | |
} |
and therefore have to duplicate it in the method:
Lines 475 to 477 in 646861d
if (defined($card) && ref($card) eq 'HASH') { | |
$card = Net::Stripe::Card->new($card); | |
} |
where feasible, i think that we should use a pattern similar to post_subscription()
:
Lines 781 to 799 in 646861d
if (ref($subscription) ne 'Net::Stripe::Subscription') { | |
my %args = (plan => $plan, | |
coupon => $coupon, | |
trial_end => $trial_end, | |
card => $card, | |
prorate => $prorate, | |
quantity => $quantity, | |
application_fee_percent => $application_fee_percent); | |
if (defined($subscription)) { | |
$args{id} = $subscription; | |
} | |
$subscription = Net::Stripe::Subscription->new( %args ); | |
} | |
if (defined($subscription->id)) { | |
return $self->_post("customers/$customer/subscriptions/" . $subscription->id, $subscription); | |
} else { | |
return $self->_post("customers/$customer/subscriptions", $subscription); | |
} |