Class: TRMNL::API::Client

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(requester: Requester, endpoints: ENDPOINTS) {|settings| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (settings)


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

#categoriesObject



37
# File 'lib/trmnl/api/client.rb', line 37

def categories = endpoints.fetch(__method__).call

#current_screenObject



39
# File 'lib/trmnl/api/client.rb', line 39

def current_screen(**) = endpoints.fetch(__method__).call(**)

#displayObject



41
# File 'lib/trmnl/api/client.rb', line 41

def display(**) = endpoints.fetch(__method__).call(**)

#ip_addressesObject



43
# File 'lib/trmnl/api/client.rb', line 43

def ip_addresses = endpoints.fetch(__method__).call

#latest_firmwareObject



45
# File 'lib/trmnl/api/client.rb', line 45

def latest_firmware = endpoints.fetch(__method__).call

#logObject



47
# File 'lib/trmnl/api/client.rb', line 47

def log(**) = endpoints.fetch(__method__).call(**)

#modelsObject



49
# File 'lib/trmnl/api/client.rb', line 49

def models(**) = endpoints.fetch(__method__).call(**)

#palettesObject



51
# File 'lib/trmnl/api/client.rb', line 51

def palettes = endpoints.fetch(__method__).call

#recipesObject



53
# File 'lib/trmnl/api/client.rb', line 53

def recipes(**) = endpoints.fetch(__method__).call(**)

#setupObject



55
# File 'lib/trmnl/api/client.rb', line 55

def setup(**) = endpoints.fetch(__method__).call(**)