From 8c7e3ffb6b97686a105c2451e59f4cdf82d3b12e Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Mon, 5 May 2025 16:37:36 -0600 Subject: [PATCH] Added primary Object API Necessary to obtain an API client with access to all endpoints. Milestone: minor --- lib/trmnl/api.rb | 2 ++ spec/lib/trmnl/api_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/trmnl/api.rb b/lib/trmnl/api.rb index 4eb3a2d..016cf04 100644 --- a/lib/trmnl/api.rb +++ b/lib/trmnl/api.rb @@ -18,5 +18,7 @@ module TRMNL def self.loader registry = Zeitwerk::Registry @loader ||= registry.loaders.find { |loader| loader.tag == "trmnl-api" } end + + def self.new(&) = Client.new(&) end end diff --git a/spec/lib/trmnl/api_spec.rb b/spec/lib/trmnl/api_spec.rb index 2d54205..576e39a 100644 --- a/spec/lib/trmnl/api_spec.rb +++ b/spec/lib/trmnl/api_spec.rb @@ -13,4 +13,27 @@ RSpec.describe TRMNL::API do expect(described_class.loader.tag).to eq("trmnl-api") end end + + describe ".new" do + include_context "with application dependencies" + + it "configures client" do + described_class.new do |settings| + settings.content_type = "application/json" + settings.uri = "https://api.test.io" + end + + expect(settings).to eq( + TRMNL::API::Configuration::Content[ + content_type: "application/json", + uri: "https://api.test.io" + ] + ) + end + + it "answers client" do + described_class.new + expect(described_class.new).to be_a(TRMNL::API::Client) + end + end end