lib/yoti/doc_scan/client.rb in yoti-1.9.0 vs lib/yoti/doc_scan/client.rb in yoti-1.10.0

- old
+ new

@@ -82,11 +82,11 @@ # on the supplied media ID # # @param [String] session_id # @param [String] media_id # - # @return [Yoti::Media] + # @return [Yoti::Media|nil] # def get_media_content(session_id, media_id) Validation.assert_is_a(String, session_id, 'session_id') Validation.assert_is_a(String, media_id, 'media_id') @@ -97,12 +97,16 @@ .build begin response = request.execute + content_type = response.get_fields('content-type') + + return nil if response.code == 204 || content_type.nil? + Yoti::Media.new( response.body, - response.get_fields('content-type')[0] + content_type[0] ) rescue Yoti::RequestError => e raise Yoti::DocScan::Error.wrap(e) end end