lib/setsuzoku/service/web_service/api_strategy.rb in setsuzoku-0.14.3 vs lib/setsuzoku/service/web_service/api_strategy.rb in setsuzoku-0.14.4
- old
+ new
@@ -79,11 +79,12 @@
# @return [Hash] the parsed hash of the response object.
sig { override.params(response: Faraday::Response, options: T.untyped).returns(T.untyped) }
def parse_response(response:, **options)
case options[:response_type]
when :json
- JSON.parse(response.body).deep_symbolize_keys
+ resp = JSON.parse(response.body)
+ resp.is_a?(Hash) ? resp.deep_symbolize_keys : resp
when :xml
convert_xml_to_hash(response.body)
when :html
response.body
when :txt, :png, :jpg, :gif
@@ -95,10 +96,11 @@
# t = Tempfile.new([file_name, ".#{options[:response_type]}"], encoding: 'ascii-8bit')
# t.write(response.body)
# t.rewind
# t
else
- JSON.parse(response.body).deep_symbolize_keys
+ resp = JSON.parse(response.body)
+ resp.is_a?(Hash) ? resp.deep_symbolize_keys : resp
end
end
private
\ No newline at end of file