Added log endpoint

Necessary to handle the request and response of the log API endpoint.
This commit is contained in:
Brooke Kuhlmann
2025-04-22 14:24:34 -06:00
parent a941c8f180
commit f635aa4cd7
2 changed files with 41 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
# frozen_string_literal: true
module TRMNL
module API
module Endpoints
# Handles API request/response.
class Log
include Dependencies[:client]
def call(token:, **) = client.post("log", headers: {"Access-Token" => token}, **)
end
end
end
end
+27
View File
@@ -0,0 +1,27 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe TRMNL::API::Endpoints::Log do
subject(:endpoint) { described_class.new client: }
include_context "with application dependencies"
let(:client) { TRMNL::API::Client.new http: }
describe "#call" do
let :http do
HTTP::Fake::Client.new do
post "/api/log" do
headers["Content-Type"] = "application/json"
status 204
end
end
end
it "answers record" do
result = endpoint.call token: "secret"
expect(result.success.status).to eq(204)
end
end
end