bitpay / ruby-client

Powerful, flexible, lightweight SDK for the BitPay Bitcoin Payment Gateway API.
MIT License
79 stars 64 forks source link

refactor request handling in bitpay client #14

Closed arrtchiu closed 10 years ago

arrtchiu commented 10 years ago

Noticed an exception while parsing JSON during a brief connection issue between CloudFlare and BitPay. CloudFlare in this instance responded with a HTML page which caused the JSON parser to fail.

This definitely isn't the most elegant approach (we should check response code too) but it at the very least allows API users to rescue from BitPayError in the event this occurs again.

Also took the opportunity to DRY the code a little.

JoshuaEstes commented 10 years ago

Looks fine to me, only thing I would like to see is a test. However, if someone else approves this it can be merged in.

arrtchiu commented 10 years ago

:) Thanks! Maybe we should bump the version number too?

heisler3030 commented 10 years ago

Agreed, and thanks for the enhancement! FYI we are putting the final touches on a major rewrite for the new API released yesterday, so we'd welcome your input on that in the future too (see my fork for preview)