Mangopay / mangopay2-ruby-sdk

Ruby Gem for MANGOPAY
https://rubygems.org/gems/mangopay
MIT License
42 stars 38 forks source link

process parameters before request to be able to use ruby conventions for parameters #6

Closed antho1404 closed 10 years ago

antho1404 commented 10 years ago

MangoPay::CardRegistration.create({ user_id: "...", currency: "EUR" })

instead of

MangoPay::CardRegistration.create({ 'UserId' => "...", 'Currency' => "EUR" })

both behaviour are working !

ghost commented 10 years ago

Hi Anthony,

Thanks for your input, it could be a good idea. However:

  1. It adds another dependency to our package and I'm not sure if the profit is big enough to justify introducing dependency on rails. (And you can always convert your hashes before passing it to mangopay, inside your client code).
  2. It doesn't handle embedded hashes properly; see:

undersc = { 'some_string' => "some value", 'some_hash' => { 'im_inside' => 321 }, } pp undersc, processed_params(undersc)

  1. I guess using camelize would be better than classify method. Camelizing is simple and doesn't depend on lexicons as the heavy task of pluralization (supported by classify method) does.

Thanks, Sergiusz

antho1404 commented 10 years ago

You're right for the dependency, I didn't think about that. For the embedded hashes this can be fixed quickly, I was not aware of embedded hash for your api but this can be fixed easily and the same for camelizing but this don't fix the dependency.