Class: TRMNL::API::Client
- Inherits:
-
Object
- Object
- TRMNL::API::Client
- Defined in:
- lib/trmnl/api/client.rb
Overview
Provides the primary client for making API requests.
Constant Summary collapse
- ENDPOINTS =
{ categories: Endpoints::Category, current_screen: Endpoints::CurrentScreen, display: Endpoints::Display, ip_addresses: Endpoints::IPAddress, latest_firmware: Endpoints::LatestFirmware, log: Endpoints::Log, models: Endpoints::Model, palettes: Endpoints::Palette, recipes: Endpoints::Recipe, setup: Endpoints::Setup }.freeze
Instance Method Summary collapse
- #categories ⇒ Object
- #current_screen ⇒ Object
- #display ⇒ Object
-
#initialize(requester: Requester, endpoints: ENDPOINTS) {|settings| ... } ⇒ Client
constructor
A new instance of Client.
- #ip_addresses ⇒ Object
- #latest_firmware ⇒ Object
- #log ⇒ Object
- #models ⇒ Object
- #palettes ⇒ Object
- #recipes ⇒ Object
- #setup ⇒ Object
Constructor Details
#initialize(requester: Requester, endpoints: ENDPOINTS) {|settings| ... } ⇒ Client
Returns a new instance of Client.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/trmnl/api/client.rb', line 25 def initialize(requester: Requester, endpoints: ENDPOINTS, **) super(**) yield settings if block_given? requester = requester.new(settings:) @endpoints = endpoints.each.with_object({}) do |(key, value), all| all[key] = value.new requester: end end |
Instance Method Details
#categories ⇒ Object
37 |
# File 'lib/trmnl/api/client.rb', line 37 def categories = endpoints.fetch(__method__).call |
#current_screen ⇒ Object
39 |
# File 'lib/trmnl/api/client.rb', line 39 def current_screen(**) = endpoints.fetch(__method__).call(**) |
#display ⇒ Object
41 |
# File 'lib/trmnl/api/client.rb', line 41 def display(**) = endpoints.fetch(__method__).call(**) |
#ip_addresses ⇒ Object
43 |
# File 'lib/trmnl/api/client.rb', line 43 def ip_addresses = endpoints.fetch(__method__).call |
#latest_firmware ⇒ Object
45 |
# File 'lib/trmnl/api/client.rb', line 45 def latest_firmware = endpoints.fetch(__method__).call |
#log ⇒ Object
47 |
# File 'lib/trmnl/api/client.rb', line 47 def log(**) = endpoints.fetch(__method__).call(**) |
#models ⇒ Object
49 |
# File 'lib/trmnl/api/client.rb', line 49 def models(**) = endpoints.fetch(__method__).call(**) |
#palettes ⇒ Object
51 |
# File 'lib/trmnl/api/client.rb', line 51 def palettes = endpoints.fetch(__method__).call |
#recipes ⇒ Object
53 |
# File 'lib/trmnl/api/client.rb', line 53 def recipes(**) = endpoints.fetch(__method__).call(**) |
#setup ⇒ Object
55 |
# File 'lib/trmnl/api/client.rb', line 55 def setup(**) = endpoints.fetch(__method__).call(**) |