Added palette contract

Necessary to validate the Palette API response. I've logged and issue against our Core project to improve upon this further since the API design is inconsistent so hoping this will improve soon.

Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2025-12-11 14:53:55 -07:00
parent eca4ae4f54
commit b331402854
2 changed files with 21 additions and 0 deletions
+1
View File
@@ -26,6 +26,7 @@ module TRMNL
register :firmware, Contracts::Firmware
register :ip_address, Contracts::IPAddress
register :model, Contracts::Model
register :palette, Contracts::Palette
register :setup, Contracts::Setup
end
+20
View File
@@ -0,0 +1,20 @@
# frozen_string_literal: true
require "dry/schema"
module TRMNL
module API
module Contracts
# Validates API response.
Palette = Dry::Schema.JSON do
required(:data).array(:hash) do
required(:id).filled :string
required(:name).filled :string
optional(:grays).maybe :integer
optional(:colors).maybe(:array)
optional(:framework_class).maybe :string
end
end
end
end
end