balanced / balanced-ruby

Balanced API library in ruby.
MIT License
111 stars 47 forks source link

Balanced::Card#debit doesn't accept "on_behalf_of" #72

Closed mdchaney closed 10 years ago

mdchaney commented 11 years ago

Balanced::Account#debit accepts "on_behalf_of" as a option, but Balanced::Card#debit does not. It can be added simply by ignoring positionals (or make it arg[4]) and grabbing from options:

on_behalf_of = options.fetch(:on_behalf_of) { nil }

And then pass it in on the self.account.debit call below.

As an aside, it would also be useful to clean up the parameters to "debit" as well as the documentation. In the docs, we have "account_uri", "on_behalf_of_uri", "hold_uri", "source_uri", etc. In the code, "on_behalf_of_uri" doesn't exist - it's just "on_behalf_of".

A good change would be to allow either form in Balanced::Account and Balanced::Card, e.g. "on_behalf_of" and "on_behalf_of_uri" and then properly use whichever is passed in, pulling the uri if it's the non-uri style. The code in Balanced::Account already does that, but it's a bit clunky and undocumented. If it has a "uri" method, then that is used. If it's a string, it's assumed to be a uri. The same could easily be done for all of the *_uri methods.

remear commented 10 years ago

Stale. The Order resource is now used to associate debits and credits.