mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
Added palette model
Necessary to build a record out of the API response. Milestone: minor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user