mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
Added firmware endpoint
Necessary to handle the request and response of the firmware API endpoint.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user