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