Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

balanced-ruby does not enforce the type returned when doing a find #25

Open
mjallday opened this issue Aug 3, 2012 · 2 comments
Open

Comments

@mjallday
Copy link
Contributor

mjallday commented Aug 3, 2012

When I ask for a Debit I should get a Debit, if it's another type of object I should get an error

require 'balanced'

key = Balanced::ApiKey.new.save
Balanced.configure(key.secret)
marketplace = Balanced::Marketplace.new.save

# this should throw an error, instead, it returns an Account object
Balanced::Debit.find(marketplace.owner_account.uri)
@mahmoudimus
Copy link
Contributor

This is a fair request - it should be expected that the find class method of a Resource child only apply to its class types. The only coercion should happen if you use the super class, in this case Resource, find method, which coerce it into the appropriate type.

@mjallday
Copy link
Contributor Author

This can also happen in this scenario:

balanced_params = {'name' => params[:name], 'email_address' => params[:email_address], 'uri' => params[:balanced_card_uri]} 
balanced_customer = Balanced::Account.new(balanced_params).save

Note that card_uri was accidentally input as uri which produces the confusing error message "Not permitted to perform update on marketplace_cards"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants