Added firmware endpoint

Necessary to handle the request and response of the firmware API endpoint.
This commit is contained in:
Brooke Kuhlmann
2025-04-22 14:24:34 -06:00
parent 2da39573fc
commit a941c8f180
2 changed files with 82 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 Firmware
include Dependencies[:client, contract: "contracts.firmware", model: "models.firmware"]
include Pipeable
def call
pipe client.get("firmware/latest"),
try(:parse, catch: JSON::ParserError),
validate(contract, as: :to_h),
to(model, :for)
end
end
end
end
end