diff --git a/lib/trmnl/api/models/recipes/entry.rb b/lib/trmnl/api/models/recipes/entry.rb new file mode 100644 index 0000000..6f1c19a --- /dev/null +++ b/lib/trmnl/api/models/recipes/entry.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module TRMNL + module API + module Models + module Recipes + # Models the data of the API response. + Entry = Struct.new( + :id, + :name, + :icon_url, + :icon_content_type, + :screenshot_url, + :author, + :custom_fields, + :statistics, + :published_at + ) do + def self.for(**attributes) + new( + **attributes.merge!( + author: Author.for(**attributes.delete(:author_bio)), + statistics: Statistics[**attributes.delete(:stats)] + ) + ) + end + end + end + end + end +end