You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 13, 2018. It is now read-only.
It makes a bunch of guesses of how it thinks money is being represented, then parses with switch cases and some weird defaults. Plus assumes anything that responds to cents is money.
We could make each Carrier implement its own money parser, based on the types coming back for a given provider. Or something cleaner. Plus it shouldn't really be in the Package class anyway.
I started working on this the other day. It's a big refactor, made a little harder by the fact that the expected money format of each Carrier is not codified anywhere in this library. We will have to check the docs for each API to make sure we get it right.
Pulling in something like RubyMoney would be overkill, but an ActiveShipping::Money class would save us from some money arithmetic pitfalls in the future. Here's what it could look like:
Then, as mentioned above, each Carrier class would create instances of ActiveShipping::Money as needed, taking care to parse values in API responses as amounts in dollars, cents or whatever.
Package.cents_from
is a problem.active_shipping/lib/active_shipping/package.rb
Lines 117 to 131 in e76c8c7
It makes a bunch of guesses of how it thinks money is being represented, then parses with switch cases and some weird defaults. Plus assumes anything that responds to
cents
is money.We could make each
Carrier
implement its own money parser, based on the types coming back for a given provider. Or something cleaner. Plus it shouldn't really be in thePackage
class anyway.See #457 #455 for examples.
The text was updated successfully, but these errors were encountered: