From 9a8613a048ab3480597855d9f9abdf90157e148d Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Tue, 13 Jan 2026 14:58:21 -0700 Subject: [PATCH] Added recipe entry model Necessary to model recipe data. A `Struct` is used because some fields are optional. This will soon be used by the recipe model (soon to be added). Milestone: minor --- lib/trmnl/api/models/recipes/entry.rb | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/trmnl/api/models/recipes/entry.rb 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