Add config to get hashes' keys in snake_case #238
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the option to snakify_keys we receive when calling MangoPay endpoints. This allows us to map objects params 1:1 in the db, without transform them to follow ruby's convention. For example:
default:
=> {"Id"=>"206880768", "UserId"=>"206880767", "CreationDate"=>1697803982, "ProcessedDate"=>nil, "Status"=>"VALIDATION_ASKED", "Reason"=>nil, "Message"=>nil, "Ubos"=>[{"Id"=>"206880769", "CreationDate"=>1697803982, "LastName"=>"Doe", "FirstName"=>"John", "Birthday"=>1300186358, "Nationality"=>"FR", "Address"=>{"AddressLine1"=>"6 Parvis Notre-Dame", "AddressLine2"=>"Pl. Jean-Paul II", "City"=>"Paris", "Region"=>"", "PostalCode"=>"75004", "Country"=>"FR"}, "Birthplace"=>{"City"=>"Paris", "Country"=>"FR"}, "IsActive"=>true}]}
snakify_keys = true:
=> {"id"=>"206880772", "user_id"=>"206880771", "creation_date"=>1697803989, "processed_date"=>nil, "status"=>"VALIDATION_ASKED", "reason"=>nil, "message"=>nil, "ubos"=>[{"id"=>"206880773", "creation_date"=>1697803990, "last_name"=>"Doe", "first_name"=>"John", "birthday"=>1300186358, "nationality"=>"FR", "address"=>{"address_line1"=>"6 Parvis Notre-Dame", "address_line2"=>"Pl. Jean-Paul II", "city"=>"Paris", "region"=>"", "postal_code"=>"75004", "country"=>"FR"}, "birthplace"=>{"city"=>"Paris", "country"=>"FR"}, "is_active"=>true}]}
This change requires
activesupport
, but adding this gem as dependency lead to bump the minimum ruby version to2.2.2
, idk if this can be a problem.I've added a bunch of tests and everything seems to be working good. Let me know if further explanations or tests are required