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, firmware_flashes: Endpoints::Firmware::Flash, firmware_latest: Endpoints::Firmware::Latest, ip_addresses: Endpoints::IPAddress, 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
- #firmware_flashes ⇒ Object
- #firmware_latest ⇒ Object
-
#initialize(requester: Requester, endpoints: ENDPOINTS) {|settings| ... } ⇒ Client
constructor
A new instance of Client.
- #ip_addresses ⇒ 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.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/trmnl/api/client.rb', line 26 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
38 |
# File 'lib/trmnl/api/client.rb', line 38 def categories = endpoints.fetch(__method__).call |
#current_screen ⇒ Object
40 |
# File 'lib/trmnl/api/client.rb', line 40 def current_screen(**) = endpoints.fetch(__method__).call(**) |
#display ⇒ Object
42 |
# File 'lib/trmnl/api/client.rb', line 42 def display(**) = endpoints.fetch(__method__).call(**) |
#firmware_flashes ⇒ Object
44 |
# File 'lib/trmnl/api/client.rb', line 44 def firmware_flashes = endpoints.fetch(__method__).call |
#firmware_latest ⇒ Object
46 |
# File 'lib/trmnl/api/client.rb', line 46 def firmware_latest = endpoints.fetch(__method__).call |
#ip_addresses ⇒ Object
48 |
# File 'lib/trmnl/api/client.rb', line 48 def ip_addresses = endpoints.fetch(__method__).call |
#log ⇒ Object
50 |
# File 'lib/trmnl/api/client.rb', line 50 def log(**) = endpoints.fetch(__method__).call(**) |
#models ⇒ Object
52 |
# File 'lib/trmnl/api/client.rb', line 52 def models(**) = endpoints.fetch(__method__).call(**) |
#palettes ⇒ Object
54 |
# File 'lib/trmnl/api/client.rb', line 54 def palettes = endpoints.fetch(__method__).call |
#recipes ⇒ Object
56 |
# File 'lib/trmnl/api/client.rb', line 56 def recipes(**) = endpoints.fetch(__method__).call(**) |
#setup ⇒ Object
58 |
# File 'lib/trmnl/api/client.rb', line 58 def setup(**) = endpoints.fetch(__method__).call(**) |