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
This commit is contained in:
Brooke Kuhlmann
2026-01-15 09:18:33 -07:00
parent 097d77369d
commit 9a8613a048
+31
View File
@@ -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