lib/wgif/uploader.rb in wgif-0.2.0 vs lib/wgif/uploader.rb in wgif-0.3.0

- old
+ new

@@ -12,14 +12,17 @@ end def upload(filename) File.open(filename, 'r') do |file| response = Typhoeus.post(UPLOAD_ENDPOINT, - body: {image: file}, + body: { image: file }, headers: auth_header) - raise WGif::ImgurException, error_message(response) unless response.success? - image_url(response) + if response.success? + image_url(response) + else + fail WGif::ImgurException, error_message(response) + end end end private @@ -30,9 +33,9 @@ def error_message(response) JSON.parse(response.body)['data']['error'] end def auth_header - {Authorization: "Client-ID #{@client_id}"} + { Authorization: "Client-ID #{@client_id}" } end end end