dwolla-v2-ruby icon indicating copy to clipboard operation
dwolla-v2-ruby copied to clipboard

Issue with $dwolla.get function and search customer with multiple statuses

Open TheDevster opened this issue 4 years ago • 1 comments

According to the documentation (https://docs.dwolla.com/#list-and-search-customers), you can stack statuses for a unique query (such as getting all suspended and unverified customers). However when I use the dwolla gem, instead of sending the multiple status (as the Dwolla API documentation indicates), it overwrites and only the last one is sent.

Example: $dwolla.get "customers", status: "suspended", status: "unverified"

The result is only status=unverified gets sent.

I also tried to send the whole url as a string, same result: $dwolla.get "https://api.dwolla.com/customers?status=suspended&status=unverified"

Opened ticket with Dwolla support thinking it was an issue with the API documentation. Instead it's an issue with the Gem and its inability to handle same status without overwriting.

Is there a known workaround for this issue?

TheDevster avatar Mar 18 '21 16:03 TheDevster

Not a Dwolla employee but I've been customizing the gem a bit lately. I think you need to customize the underlying Faraday instance in order to change the request param encoder to use the FlatParamsEncoder.

Give this a try:

$dwolla = DwollaV2::Client.new(
  key: ENV["DWOLLA_APP_KEY"],
  secret: ENV["DWOLLA_APP_SECRET"]
) do |config|
  config.faraday do |faraday|
    faraday.options.params_encoder = Faraday::FlatParamsEncoder
    faraday.adapter Faraday.default_adapter
  end
end

$dwolla.get("customers", status: ["suspended", "unverified"])

abevoelker avatar Aug 07 '21 17:08 abevoelker