Added setup endpoint

Necessary to handle the request and response of the setup API endpoint.
This commit is contained in:
Brooke Kuhlmann
2025-04-22 14:24:34 -06:00
parent f635aa4cd7
commit 0e579ea701
2 changed files with 88 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
# frozen_string_literal: true
require "pipeable"
module TRMNL
module API
module Endpoints
# Handles API request/response.
class Setup
include Dependencies[:client, contract: "contracts.setup", model: "models.setup"]
include Pipeable
def call id:
pipe client.get("setup", headers: {"ID" => id}),
try(:parse, catch: JSON::ParserError),
validate(contract, as: :to_h),
to(model, :for)
end
end
end
end
end