mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user