Added palette model

Necessary to build a record out of the API response.

Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2025-12-11 14:53:55 -07:00
parent b331402854
commit c200ae5491
3 changed files with 32 additions and 0 deletions
+1
View File
@@ -36,6 +36,7 @@ module TRMNL
register :firmware, Models::Firmware
register :ip_address, Models::IPAddress
register :model, Models::Model
register :palette, Models::Palette
register :setup, Models::Setup
end
end
+12
View File
@@ -0,0 +1,12 @@
# frozen_string_literal: true
module TRMNL
module API
module Models
# IPs API response.
Palette = Data.define :id, :name, :grays, :colors, :framework_class do
def self.for(attributes) = new(**attributes)
end
end
end
end
+19
View File
@@ -0,0 +1,19 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe TRMNL::API::Models::Palette do
describe ".for" do
it "answers record for attributes" do
attributes = {
id: "test",
name: "Test",
grays: 2,
colors: %w[#000000 #FFFFFF],
framework_class: "screen--1bit"
}
expect(described_class.for(attributes)).to eq(described_class[**attributes])
end
end
end