mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user