lib/atol/transaction/post_document.rb in atol-0.5.0 vs lib/atol/transaction/post_document.rb in atol-0.5.1
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'atol/request/post_document'
require 'atol/errors'
module Atol
module Transaction
@@ -18,10 +20,10 @@
end
def call
request = Atol::Request::PostDocument.new(@params)
response = request.call
- encoded_body = response.body.force_encoding(Atol::ENCODING)
+ encoded_body = response.body.dup.force_encoding(Atol::ENCODING)
json = JSON.parse(encoded_body)
if response.code == '200' && json['error'].nil?
json
elsif ERRORS[json['error']['code']]