mollie / mollie-api-ruby

Mollie API client for Ruby
http://www.mollie.com
BSD 2-Clause "Simplified" License
81 stars 42 forks source link

Testing if customer id exists #128

Closed ldestrooper closed 4 years ago

ldestrooper commented 4 years ago

Is it possible to check if a customer id exists?

If i use Mollie::Customer.get i immediately get an exception.

justincase commented 4 years ago

You can rescue the exception:

customer = begin
  Mollie::Customer.get('cst_8wmqcHMN4U')
rescue Mollie::RequestError => e
  if e['status'] == 404
    nil
  else
    raise
  end
end

@vernondegoede We could add a NotFound exception for 404 responses