Module: TRMNL::API::Schemas

Defined in:
lib/trmnl/api/schemas/model.rb,
lib/trmnl/api/schemas/setup.rb,
lib/trmnl/api/schemas/recipe.rb,
lib/trmnl/api/schemas/display.rb,
lib/trmnl/api/schemas/palette.rb,
lib/trmnl/api/schemas/category.rb,
lib/trmnl/api/schemas/ip_address.rb,
lib/trmnl/api/schemas/current_screen.rb,
lib/trmnl/api/schemas/recipes/author.rb,
lib/trmnl/api/schemas/latest_firmware.rb

Defined Under Namespace

Modules: Recipes

Constant Summary collapse

Model =

Validates API response.

Dry::Schema.JSON do
  required(:data).array(:hash) do
    required(:name).filled :string
    required(:label).filled :string
    required(:description).filled :string
    required(:kind).filled :string
    required(:colors).filled :integer
    required(:bit_depth).filled :integer
    required(:scale_factor) { filled? > int? | float? }
    required(:rotation).filled :integer
    required(:mime_type).filled :string
    required(:width).filled :integer
    required(:height).filled :integer
    required(:offset_x).filled :integer
    required(:offset_y).filled :integer
    required(:palette_ids).array(:string)
    optional(:css).hash do
      optional(:classes).hash do
        required(:density).filled :string
        required(:device).filled :string
        required(:size).filled :string
      end

      optional(:variables).filled(Types::CSSVariables)
    end
  end
end
Setup =

Validates API response.

Dry::Schema.JSON do
  required(:api_key).filled :string
  required(:friendly_id).filled :string
  required(:image_url).filled :string
  required(:message).filled :string
end
Recipe =

Validates API response.

Dry::Schema.JSON do
  required(:data).array(:hash) do
    required(:id).filled :integer
    required(:name).filled :string
    required(:screenshot_url).filled :string
    required(:published_at).filled :time
    optional(:icon_url).maybe :string
    optional(:icon_content_type).maybe :string
    required(:author_bio).maybe Recipes::Author
    required(:custom_fields).array(:hash)

    required(:stats).filled :hash do
      required(:installs).filled :integer
      required(:forks).filled :integer
    end
  end

  required(:total).filled :integer
  required(:from).filled :integer
  required(:to).filled :integer
  required(:per_page).filled :integer
  required(:current_page).filled :integer
  required(:prev_page_url).maybe :string
  required(:next_page_url).maybe :string
end
Display =

Validates API response.

Dry::Schema.JSON do
  required(:filename).filled :string
  required(:firmware_url).filled :string
  optional(:firmware_version).maybe :string
  required(:image_url).filled :string
  required(:refresh_rate).filled :integer
  required(:reset_firmware).filled :bool
  required(:special_function).filled :string
  required(:update_firmware).filled :bool
end
Palette =

Validates API response.

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
Category =

Validates API response.

Dry::Schema.JSON { required(:data).array(:string) }
IPAddress =

Validates API response.

Dry::Schema.JSON do
  required(:data).hash do
    required(:ipv4).array(Types::IPAddress)
    required(:ipv6).array(Types::IPAddress)
  end
end
CurrentScreen =

Validates API response.

Dry::Schema.JSON do
  required(:refresh_rate).filled :integer
  required(:image_url).filled :string
  required(:filename).filled :string
end
LatestFirmware =

Validates API response.

Dry::Schema.JSON do
  required(:url).filled :string
  required(:version).filled :string
end