diff --git a/lib/instapaper/bookmark.rb b/lib/instapaper/bookmark.rb index 4d15e6b..5828454 100644 --- a/lib/instapaper/bookmark.rb +++ b/lib/instapaper/bookmark.rb @@ -5,17 +5,17 @@ module Instapaper include Virtus.value_object values do - attribute :type, String - attribute :bookmark_id, String - attribute :url, String - attribute :title, String + attribute :instapaper_hash, String attribute :description, String - attribute :time, String - attribute :starred, String + attribute :bookmark_id, Integer attribute :private_source, String - attribute :hash, String + attribute :title, String + attribute :url, String + attribute :progress_timestamp, DateTime + attribute :time, DateTime attribute :progress, String - attribute :progress_timestamp, String + attribute :starred, String + attribute :type, String end end end diff --git a/lib/instapaper/http/utils.rb b/lib/instapaper/http/utils.rb index f57196e..f0b02a7 100644 --- a/lib/instapaper/http/utils.rb +++ b/lib/instapaper/http/utils.rb @@ -18,7 +18,7 @@ module Instapaper # @param klass [Class] def perform_request_with_objects(request_method, path, options, klass) perform_request(request_method, path, options).collect do |element| - klass.new(element) + klass.new(coerce_hash(element)) end end @@ -36,7 +36,7 @@ module Instapaper def perform_request_with_object(request_method, path, options, klass) response = perform_request(request_method, path, options) response = response.is_a?(Array) ? response.first : response - klass.new(response) + klass.new(coerce_hash(response)) end # @param path [String] @@ -48,6 +48,13 @@ module Instapaper def perform_request(method, path, options) Instapaper::HTTP::Request.new(self, method, path, options).perform end + + def coerce_hash(response) + if response.key?('hash') + response['instapaper_hash'] = response.delete('hash') + end + response + end end end end