Closed Siraris closed 6 years ago
Hey @Siraris,
Thanks for letting us know about this. I'm not quite sure what's going on either. Would you be able to provide a script I can run that reproduces the issue?
@sausman
This should be all that you need to reproduce the issue. If you just place test strings for all the business_params (I was doing it without setting a controller, so setting "soleProprietorship", and then just using a the authenticated client. Client.post is just:
def post(endpoint, params = {}) authenticated_client.post endpoint, params end
if this is helpful, here's the test data I was using:
{:firstName=>"Kendrick", :lastName=>"Lamar", :email=>"kendrick@test.co", :type=>"business", :address1=>"1917 N Elston", :city=>"Chicago", :state=>"IL", :postalCode=>"60642", :businessName=>"Test Company", :businessType=>"soleProprietorship", :businessClassification=>"9ed3cf5f-7d6f-11e3-8af8-5404a6144203", :ein=>"12-3456789"}
Thanks @Siraris,
Here's what I'm getting when I run this script:
Script
require 'dwolla_v2'
client = DwollaV2::Client.new(id: "MY_CLIENT_ID", secret: "MY_CLIENT_SECRET") {|c| c.environment :sandbox }
token = client.auths.client
token.post("customers", {
:firstName => "Kendrick",
:lastName => "Lamar",
:email => "kendrick@test.co",
:type => "business",
:address1 => "1917 N Elston",
:city => "Chicago",
:state => "IL",
:postalCode => "60642",
:businessName => "Test Company",
:businessType => "soleProprietorship",
:businessClassification => "9ed3cf5f-7d6f-11e3-8af8-5404a6144203",
:ein => "12-3456789"
})
Result
/Users/sausman/git/dwolla-v2-ruby/lib/dwolla_v2/middleware/handle_errors.rb:9:in `block in call': {"code"=>"ValidationError", "message"=>"Validation error(s) present. See embedded errors list for more details.", "_embedded"=>{"errors"=>[{"code"=>"InvalidFormat", "message"=>"BusinessClassification invalid.", "path"=>"/businessClassification", "_links"=>{}}, {"code"=>"Required", "message"=>"DateOfBirth required.", "path"=>"/dateOfBirth", "_links"=>{}}, {"code"=>"Required", "message"=>"Ssn required.", "path"=>"/ssn", "_links"=>{}}]}} (DwollaV2::ValidationError)
from /Users/sausman/.rvm/gems/ruby-2.4.0/gems/faraday-0.13.1/lib/faraday/response.rb:61:in `on_complete'
from /Users/sausman/git/dwolla-v2-ruby/lib/dwolla_v2/middleware/handle_errors.rb:8:in `call'
from /Users/sausman/git/dwolla-v2-ruby/lib/dwolla_v2/middleware/set_user_agent.rb:13:in `call'
from /Users/sausman/.rvm/gems/ruby-2.4.0/gems/faraday_middleware-0.12.2/lib/faraday_middleware/request/encode_json.rb:24:in `call'
from /Users/sausman/.rvm/gems/ruby-2.4.0/gems/faraday-0.13.1/lib/faraday/request/multipart.rb:15:in `call'
from /Users/sausman/.rvm/gems/ruby-2.4.0/gems/faraday-0.13.1/lib/faraday/rack_builder.rb:141:in `build_response'
from /Users/sausman/.rvm/gems/ruby-2.4.0/gems/faraday-0.13.1/lib/faraday/connection.rb:387:in `run_request'
from /Users/sausman/.rvm/gems/ruby-2.4.0/gems/faraday-0.13.1/lib/faraday/connection.rb:174:in `post'
from /Users/sausman/git/dwolla-v2-ruby/lib/dwolla_v2/token.rb:42:in `public_send'
from /Users/sausman/git/dwolla-v2-ruby/lib/dwolla_v2/token.rb:42:in `block (2 levels) in <class:Token>'
from foo.rb:6:in `<main>'
Does that script give you the same thing?
Hey @sausman
That's my bad, it looks as if the error was being swallowed and is actually coming from us. Thanks again so much for being so quick to get to this.
So I ran into an issue this morning trying to make a request to create a business customer. I thought that my hash was malformed, and passing in the wrong number of arguments, and finally threw a binding.pry in the source of the error (the hashie gem) and found the following:
` From: /Users/andrewsoep/.rvm/gems/ruby-2.4.1/gems/hashie- 3.5.7/lib/hashie/extensions/indifferent_access.rb @ line 79 Hashie::Extensions::IndifferentAccess#convert!:
=> 79: keys.each do |k| 80: regular_writer convert_key(k), indifferent_value(regular_delete(k)) 81: end 82: self 83: end
[1] pry(#)> keys
=> ["access_token", "token_type", "expires_in"]`
It seems as if the library is passing in an odd number of arguments, which is causing the issue at hand. The odd thing is, I use this gem for a lot of requests to the API, and it works fine, so I'm confused why this would be an issue. My code can be found below, if it illustrates something I'm doing in error.
` business_params = { firstName: name[0], lastName: name[1], email: params[:admin_email], type: org.client_type, address1: org.address_line_1, city: org.city, state: org.region, postalCode: org.postal_code, businessName: org.name, businessType: params[:business_type], businessClassification: params[:business_classification], ein: params[:ein] }