mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
Fixed recipe entry model to be data model
Necessary to add clarity to what this model represents as `Entry` was slightly confusing, and now that there is no conflict with native `Data` objects, we can use `Data` for the model name. Milestone: minor
This commit is contained in:
@@ -15,7 +15,7 @@ module TRMNL
|
||||
:next_page_url
|
||||
) do
|
||||
def self.for(**attributes)
|
||||
data = attributes[:data].map { Recipes::Entry.for(**it) }
|
||||
data = attributes[:data].map { Recipes::Data.for(**it) }
|
||||
new(**attributes.merge!(data:))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ module TRMNL
|
||||
module Models
|
||||
module Recipes
|
||||
# Models the data of the API response.
|
||||
Entry = Struct.new(
|
||||
Data = Struct.new(
|
||||
:id,
|
||||
:name,
|
||||
:icon_url,
|
||||
@@ -58,7 +58,7 @@ RSpec.describe TRMNL::API::Endpoints::Recipe do
|
||||
expect(endpoint.call.success).to match(
|
||||
TRMNL::API::Models::Recipe[
|
||||
data: [
|
||||
TRMNL::API::Models::Recipes::Entry[
|
||||
TRMNL::API::Models::Recipes::Data[
|
||||
id: 1,
|
||||
name: "test",
|
||||
published_at: Time.parse("2026-01-02T03:04:05.000Z"),
|
||||
|
||||
@@ -52,7 +52,7 @@ RSpec.describe TRMNL::API::Models::Recipe do
|
||||
expect(described_class.for(**attributes)).to eq(
|
||||
described_class[
|
||||
data: [
|
||||
TRMNL::API::Models::Recipes::Entry[
|
||||
TRMNL::API::Models::Recipes::Data[
|
||||
id: 1,
|
||||
name: "Test",
|
||||
published_at: "2026-01-13T13:00:32.349Z",
|
||||
|
||||
Reference in New Issue
Block a user