lib/billogram/request.rb in billogram-0.4.2 vs lib/billogram/request.rb in billogram-0.5.0

- old
+ new

@@ -18,9 +18,17 @@ {} end end def execute - Billogram.client.send(type, url, content) + response.success? ? response["data"] : raise_from(response) + end + + def raise_from(response) + raise Billogram::Error.from_response(response) + end + + def response + @response ||= Billogram.client.send(type, url, content) end end end