From 9b47c7bae0217f618f8273e849be9536b875fa8d Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Mon, 12 May 2025 13:58:27 -0600 Subject: [PATCH] Added client custom inspection Necessary to reduce verbosity of output when inspecting the client. Milestone: minor --- lib/trmnl/api/client.rb | 10 ++++++++++ spec/lib/trmnl/api/client_spec.rb | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/trmnl/api/client.rb b/lib/trmnl/api/client.rb index bf0f21e..77d813f 100644 --- a/lib/trmnl/api/client.rb +++ b/lib/trmnl/api/client.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "inspectable" + module TRMNL module API # Provides the primary client for making API requests. @@ -14,6 +16,14 @@ module TRMNL endpoint_setup: :setup ] + include Inspectable[ + endpoint_current_screen: :class, + endpoint_display: :class, + endpoint_firmware: :class, + endpoint_log: :class, + endpoint_setup: :class + ] + def initialize(**) super yield settings if block_given? diff --git a/spec/lib/trmnl/api/client_spec.rb b/spec/lib/trmnl/api/client_spec.rb index 4de76d2..d0d47f6 100644 --- a/spec/lib/trmnl/api/client_spec.rb +++ b/spec/lib/trmnl/api/client_spec.rb @@ -75,4 +75,16 @@ RSpec.describe TRMNL::API::Client do expect(client.setup(id: "abc")).to have_received(:call).with(id: "abc") end end + + describe "#inspect" do + it "answers endpoint classes" do + expect(client.inspect).to include( + "@endpoint_current_screen=TRMNL::API::Endpoints::CurrentScreen, " \ + "@endpoint_display=TRMNL::API::Endpoints::Display, " \ + "@endpoint_firmware=TRMNL::API::Endpoints::Firmware, " \ + "@endpoint_log=TRMNL::API::Endpoints::Log, " \ + "@endpoint_setup=TRMNL::API::Endpoints::Setup, " + ) + end + end end