lib/mangadex/api/response.rb in mangadex-5.3.2 vs lib/mangadex/api/response.rb in mangadex-5.3.3

- old
+ new

@@ -5,10 +5,11 @@ extend T::Sig extend T::Generic attr_accessor :result, :response, :errors, :data attr_accessor :limit, :offset, :total + attr_accessor :raw_data def self.attributes_to_inspect %i(result errors limit offset total data) end @@ -42,10 +43,14 @@ def errored? Array(errors).any? end + def as_json(*) + Hash(raw_data) + end + private def self.coerce_errors(data) new( result: data['result'], @@ -58,10 +63,11 @@ title: error_data['title'], detail: error_data['detail'], ) end ), + raw_data: data, ) end def self.coerce_entity(data) object_type = data['type'] || data.dig('data', 'type') @@ -73,10 +79,11 @@ klass = Object.const_get(class_from_data) new( result: data['result'], response: data['response'], data: klass.from_data(data['data'] || data), + raw_data: data, ) end def self.coerce_collection(data) new( @@ -95,9 +102,10 @@ klass = Object.const_get(class_from_data) klass.from_data(entity_data) end ) ), + raw_data: data, ) end end end end