diff --git a/lib/trmnl/api/container.rb b/lib/trmnl/api/container.rb index 3d13410..6c53c16 100644 --- a/lib/trmnl/api/container.rb +++ b/lib/trmnl/api/container.rb @@ -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 diff --git a/lib/trmnl/api/models/palette.rb b/lib/trmnl/api/models/palette.rb new file mode 100644 index 0000000..7a1e7a0 --- /dev/null +++ b/lib/trmnl/api/models/palette.rb @@ -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 diff --git a/spec/lib/trmnl/api/models/palette_spec.rb b/spec/lib/trmnl/api/models/palette_spec.rb new file mode 100644 index 0000000..bd2b6b0 --- /dev/null +++ b/spec/lib/trmnl/api/models/palette_spec.rb @@ -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