trmnl-api 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +66 -67
- data/lib/trmnl/api/endpoints/recipe.rb +7 -2
- data/lib/trmnl/api/models/current_screen.rb +1 -1
- data/lib/trmnl/api/models/firmware.rb +1 -1
- data/lib/trmnl/api/models/ip_address.rb +1 -1
- data/lib/trmnl/api/models/recipe.rb +13 -13
- data/lib/trmnl/api/models/recipes/{entry.rb → data.rb} +1 -1
- data/lib/trmnl/api/models/recipes/meta.rb +34 -0
- data/lib/trmnl/api/models/recipes/statistics.rb +1 -1
- data/lib/trmnl/api/models/setup.rb +1 -1
- data/trmnl-api.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 168b5086d30774ef88cc9d12ae187ffa4da349bfe10456c64a5e2fe7e94372a3
|
|
4
|
+
data.tar.gz: d7c785269f0ddf0238d399a352cef774c9081bb6706a238cf9ead6bcc413ff0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b6cdd52fa7cc10214220a4906298a1d2243d1da94f8854d1dd1eb67cdcd70a761655a717630bb561151e84c01b8926e7b9fac65e1cd84c9fb7590cddc164f7e
|
|
7
|
+
data.tar.gz: 732532ba60f51c994898d1a982f404ba0d38b419ccc2c6cc95b46548234c51e1b40eedeeda6b4047d81b46f03408b4fccaa8dc8bef3b85dbcef70c0a4a355576
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.adoc
CHANGED
|
@@ -304,82 +304,81 @@ Success(
|
|
|
304
304
|
|
|
305
305
|
Allows you to obtain information about link:https://usetrmnl.com/recipes[Recipes]. Example:
|
|
306
306
|
|
|
307
|
-
⚠️ This _does not_ use the {trmnl_api_link} like every other endpoint documented here. This is why you must customize the settings URI to point to the root of the TRMNL application instead of using the default API endpoint.
|
|
308
|
-
|
|
309
307
|
[source,ruby]
|
|
310
308
|
----
|
|
311
309
|
client = TRMNL::API.new { |settings| settings.uri = "https://usetrmnl.com" }
|
|
312
310
|
|
|
313
|
-
client.recipes
|
|
314
|
-
client.recipes page: 10
|
|
315
|
-
client.recipes search: "comic"
|
|
316
|
-
client.recipes
|
|
311
|
+
client.recipes # Answers first page.
|
|
312
|
+
client.recipes page: 10 # Answers page ten.
|
|
313
|
+
client.recipes search: "comic" # Answers first page of comics.
|
|
314
|
+
client.recipes sort: "popularity" # Answers first page sorted by popularity.
|
|
317
315
|
|
|
318
316
|
# Success(
|
|
319
|
-
#
|
|
320
|
-
#
|
|
321
|
-
#
|
|
322
|
-
#
|
|
323
|
-
#
|
|
324
|
-
#
|
|
325
|
-
#
|
|
326
|
-
#
|
|
327
|
-
#
|
|
328
|
-
#
|
|
329
|
-
#
|
|
330
|
-
#
|
|
331
|
-
#
|
|
332
|
-
#
|
|
333
|
-
#
|
|
334
|
-
#
|
|
335
|
-
#
|
|
336
|
-
#
|
|
337
|
-
#
|
|
338
|
-
#
|
|
339
|
-
#
|
|
340
|
-
#
|
|
341
|
-
#
|
|
342
|
-
#
|
|
343
|
-
#
|
|
344
|
-
#
|
|
345
|
-
#
|
|
346
|
-
#
|
|
347
|
-
#
|
|
348
|
-
# "
|
|
349
|
-
#
|
|
350
|
-
#
|
|
351
|
-
#
|
|
352
|
-
#
|
|
353
|
-
#
|
|
354
|
-
#
|
|
355
|
-
#
|
|
356
|
-
#
|
|
357
|
-
#
|
|
358
|
-
#
|
|
359
|
-
#
|
|
360
|
-
#
|
|
361
|
-
#
|
|
362
|
-
#
|
|
363
|
-
#
|
|
364
|
-
#
|
|
365
|
-
#
|
|
366
|
-
#
|
|
367
|
-
#
|
|
368
|
-
#
|
|
369
|
-
#
|
|
370
|
-
#
|
|
371
|
-
#
|
|
372
|
-
#
|
|
373
|
-
#
|
|
374
|
-
#
|
|
375
|
-
#
|
|
376
|
-
#
|
|
377
|
-
#
|
|
378
|
-
# >
|
|
317
|
+
# #<data TRMNL::API::Models::Recipe:0x00010fc0
|
|
318
|
+
# data = [
|
|
319
|
+
# #<Struct:TRMNL::API::Models::Recipes::Data:0x00010fe0
|
|
320
|
+
# author = #<Struct:TRMNL::API::Models::Recipes::Author:0x00010ff0
|
|
321
|
+
# category = nil,
|
|
322
|
+
# description = nil,
|
|
323
|
+
# description_locales = {},
|
|
324
|
+
# email_address = nil,
|
|
325
|
+
# field_type = nil,
|
|
326
|
+
# github_url = nil,
|
|
327
|
+
# keyname = nil,
|
|
328
|
+
# learn_more_url = nil,
|
|
329
|
+
# name = nil,
|
|
330
|
+
# youtube_url = nil
|
|
331
|
+
# >,
|
|
332
|
+
# custom_fields = [
|
|
333
|
+
# {
|
|
334
|
+
# "keyname" => "user_location",
|
|
335
|
+
# "field_type" => "string",
|
|
336
|
+
# "name" => "Weather Location",
|
|
337
|
+
# "placeholder" => "New York, NY",
|
|
338
|
+
# "description" => "Choose a location",
|
|
339
|
+
# "help_text" => "Please be precise...",
|
|
340
|
+
# "required" => true
|
|
341
|
+
# },
|
|
342
|
+
# {
|
|
343
|
+
# "keyname" => "metric",
|
|
344
|
+
# "name" => "Temperature Metric",
|
|
345
|
+
# "description" => "Celsius or Fahrenheit?",
|
|
346
|
+
# "field_type" => "select",
|
|
347
|
+
# "options" => [
|
|
348
|
+
# "Fahrenheit",
|
|
349
|
+
# "Celsius"
|
|
350
|
+
# ],
|
|
351
|
+
# "default" => "Fahrenheit"
|
|
352
|
+
# }
|
|
353
|
+
# ],
|
|
354
|
+
# icon_content_type = "image/png",
|
|
355
|
+
# icon_url = "https://trmnl-public.s3.us-east-2.amazonaws.com/ajjlbek4cabcvhk3s1lxggn8cgon",
|
|
356
|
+
# id = 49610,
|
|
357
|
+
# name = "Weather Chum",
|
|
358
|
+
# published_at = 2025-05-14 05:32:00 UTC,
|
|
359
|
+
# screenshot_url = "https://trmnl.s3.us-east-2.amazonaws.com...",
|
|
360
|
+
# statistics = #<data TRMNL::API::Models::Recipes::Statistics:0x00011170
|
|
361
|
+
# forks = 1710,
|
|
362
|
+
# installs = 1
|
|
363
|
+
# >
|
|
364
|
+
# >
|
|
365
|
+
# ],
|
|
366
|
+
# meta = #<data TRMNL::API::Models::Recipes::Meta:0x00016e20
|
|
367
|
+
# current_page = 1,
|
|
368
|
+
# from = 1,
|
|
369
|
+
# next_page_url = "/recipes.json?page=2&sort_by=popularity",
|
|
370
|
+
# per_page = 25,
|
|
371
|
+
# prev_page_url = nil,
|
|
372
|
+
# to = 25,
|
|
373
|
+
# total = 678
|
|
374
|
+
# >
|
|
375
|
+
# >
|
|
379
376
|
# )
|
|
380
377
|
----
|
|
381
378
|
|
|
382
|
-
|
|
379
|
+
⚠️ This _does not_ use the {trmnl_api_link} like every other endpoint documented here. Instead, you must customize the settings URI to point to the root of the TRMNL application (i.e. `https://usetrmnl.com`) instead of using the default API endpoint.
|
|
380
|
+
|
|
381
|
+
You'll always get a `data` array which may or may not be filled and `meta` (metadata) for handling pagination information. You can also combine the `page`, `search`, and `page` parameters as you see fit.
|
|
383
382
|
|
|
384
383
|
==== Setup
|
|
385
384
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "inspectable"
|
|
4
4
|
require "pipeable"
|
|
5
|
+
require "refinements/hash"
|
|
5
6
|
|
|
6
7
|
module TRMNL
|
|
7
8
|
module API
|
|
@@ -17,9 +18,13 @@ module TRMNL
|
|
|
17
18
|
include Inspectable[contract: :type]
|
|
18
19
|
include Pipeable
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
using Refinements::Hash
|
|
22
|
+
|
|
23
|
+
def call(**parameters)
|
|
24
|
+
parameters.transform_keys! sort: "sort-by"
|
|
25
|
+
|
|
21
26
|
pipe(
|
|
22
|
-
requester.get("recipes.json", **),
|
|
27
|
+
requester.get("recipes.json", **parameters),
|
|
23
28
|
try(:parse, catch: JSON::ParserError),
|
|
24
29
|
validate(contract, as: :to_h),
|
|
25
30
|
to(model, :for)
|
|
@@ -4,7 +4,7 @@ module TRMNL
|
|
|
4
4
|
module API
|
|
5
5
|
module Models
|
|
6
6
|
# Models the data of the API response.
|
|
7
|
-
CurrentScreen = Data.define :refresh_rate, :image_url, :filename do
|
|
7
|
+
CurrentScreen = ::Data.define :refresh_rate, :image_url, :filename do
|
|
8
8
|
def self.for(attributes) = new(**attributes)
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -4,7 +4,7 @@ module TRMNL
|
|
|
4
4
|
module API
|
|
5
5
|
module Models
|
|
6
6
|
# Models the data of the API response.
|
|
7
|
-
IPAddress = Data.define :version_4, :version_6 do
|
|
7
|
+
IPAddress = ::Data.define :version_4, :version_6 do
|
|
8
8
|
def self.for attributes
|
|
9
9
|
new(**attributes.transform_keys(ipv4: :version_4, ipv6: :version_6))
|
|
10
10
|
end
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
module TRMNL
|
|
4
4
|
module API
|
|
5
5
|
module Models
|
|
6
|
-
# Models the
|
|
7
|
-
Recipe = Data.define
|
|
8
|
-
:data,
|
|
9
|
-
:total,
|
|
10
|
-
:from,
|
|
11
|
-
:to,
|
|
12
|
-
:per_page,
|
|
13
|
-
:current_page,
|
|
14
|
-
:prev_page_url,
|
|
15
|
-
:next_page_url
|
|
16
|
-
) do
|
|
6
|
+
# Models the payload of the API response.
|
|
7
|
+
Recipe = ::Data.define :data, :meta do
|
|
17
8
|
def self.for(**attributes)
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
meta = attributes.slice :from,
|
|
10
|
+
:to,
|
|
11
|
+
:current_page,
|
|
12
|
+
:per_page,
|
|
13
|
+
:total,
|
|
14
|
+
:prev_page_url,
|
|
15
|
+
:next_page_url
|
|
16
|
+
|
|
17
|
+
data = attributes[:data].map { Recipes::Data.for(**it) }
|
|
18
|
+
|
|
19
|
+
new meta: Recipes::Meta[**meta], data:
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TRMNL
|
|
4
|
+
module API
|
|
5
|
+
module Models
|
|
6
|
+
module Recipes
|
|
7
|
+
# Models the metadata of the API response.
|
|
8
|
+
Meta = ::Data.define(
|
|
9
|
+
:from,
|
|
10
|
+
:to,
|
|
11
|
+
:current_page,
|
|
12
|
+
:per_page,
|
|
13
|
+
:total,
|
|
14
|
+
:prev_page_url,
|
|
15
|
+
:next_page_url
|
|
16
|
+
) do
|
|
17
|
+
def initialize from: 0,
|
|
18
|
+
to: 0,
|
|
19
|
+
current_page: 0,
|
|
20
|
+
per_page: 0,
|
|
21
|
+
total: 0,
|
|
22
|
+
prev_page_url: nil,
|
|
23
|
+
next_page_url: nil
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def more? = to.positive? && to < total
|
|
28
|
+
|
|
29
|
+
def next_page = current_page + 1
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -4,7 +4,7 @@ module TRMNL
|
|
|
4
4
|
module API
|
|
5
5
|
module Models
|
|
6
6
|
# Models the data of the API response.
|
|
7
|
-
Setup = Data.define :api_key, :friendly_id, :image_url, :message do
|
|
7
|
+
Setup = ::Data.define :api_key, :friendly_id, :image_url, :message do
|
|
8
8
|
def self.for(attributes) = new(**attributes)
|
|
9
9
|
end
|
|
10
10
|
end
|
data/trmnl-api.gemspec
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trmnl-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- TRMNL
|
|
@@ -222,7 +222,8 @@ files:
|
|
|
222
222
|
- lib/trmnl/api/models/palette.rb
|
|
223
223
|
- lib/trmnl/api/models/recipe.rb
|
|
224
224
|
- lib/trmnl/api/models/recipes/author.rb
|
|
225
|
-
- lib/trmnl/api/models/recipes/
|
|
225
|
+
- lib/trmnl/api/models/recipes/data.rb
|
|
226
|
+
- lib/trmnl/api/models/recipes/meta.rb
|
|
226
227
|
- lib/trmnl/api/models/recipes/statistics.rb
|
|
227
228
|
- lib/trmnl/api/models/setup.rb
|
|
228
229
|
- lib/trmnl/api/requester.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|