Class: TRMNL::API::Endpoints::Model

Inherits:
Object
  • Object
show all
Includes:
Pipeable
Defined in:
lib/trmnl/api/endpoints/model.rb

Overview

Handles API request/response.

Instance Method Summary collapse

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
# File 'lib/trmnl/api/endpoints/model.rb', line 20

def call
  pipe(
    requester.get("models"),
    try(:parse, catch: JSON::ParserError),
    validate(contract, as: :to_h),
    as(:fetch, :data),
    map { |data| model.for(**data) }
  )
end