trmnl-api 0.9.0 → 0.11.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 +74 -74
- data/lib/trmnl/api/configuration/loader.rb +1 -1
- data/lib/trmnl/api/contracts/display.rb +1 -0
- data/lib/trmnl/api/endpoints/recipe.rb +7 -2
- data/lib/trmnl/api/models/current_screen.rb +1 -1
- data/lib/trmnl/api/models/display.rb +1 -0
- 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 +1 -2
- 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: ff7ecb483d86f9e68a550342e7e923e08ac1ef5d7330a12f4631e94e7a517438
|
|
4
|
+
data.tar.gz: a249a3fd8c173416d35fb2da4a15be7accf19e29e6505e667c90b4f440866047
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40d5b26f6f84761379eb2078048ed792eb376506c3e7bc4d59bd05f08215008be16ccff61548cbd63a302350b357174c479fefcce692cd0d34c6fac3d280dd05
|
|
7
|
+
data.tar.gz: c8ac0a599cf3743f67f58ac0e9021277b08327110b952b4b7c0aabf45ad3679eeae05b0bfe44dc2ea39e191c6370a857558b3422193d01edb82d49c2b4b2d4d3
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.adoc
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
:toclevels: 5
|
|
3
3
|
:figure-caption!:
|
|
4
4
|
|
|
5
|
-
:trmnl_link: link:https://
|
|
6
|
-
:trmnl_api_link: link:https://
|
|
5
|
+
:trmnl_link: link:https://trmnl.com[TRMNL]
|
|
6
|
+
:trmnl_api_link: link:https://trmnl.com/api-docs/index.html[TRMNL API]
|
|
7
7
|
:dry_monads_link: link:https://dry-rb.org/gems/dry-monads[Dry Monads]
|
|
8
8
|
|
|
9
9
|
= TRMNL API
|
|
@@ -113,7 +113,7 @@ client.current_screen token: "secret"
|
|
|
113
113
|
# Success(
|
|
114
114
|
# #<data TRMNL::API::Models::CurrentScreen
|
|
115
115
|
# refresh_rate=1773,
|
|
116
|
-
# image_url="https://
|
|
116
|
+
# image_url="https://trmnl.com/plugin-2025-04-10T11-34-38Z-380c77",
|
|
117
117
|
# filename="plugin-2025-04-10T11-34-38Z-380c77"
|
|
118
118
|
# >
|
|
119
119
|
# )
|
|
@@ -132,6 +132,7 @@ client.display token: "secret"
|
|
|
132
132
|
# #<struct TRMNL::API::Models::Display
|
|
133
133
|
# filename="plugin-1745348489",
|
|
134
134
|
# firmware_url="https://trmnl-fw.s3.us-east-2.amazonaws.com/FW1.4.8.bin",
|
|
135
|
+
# firmware_version="1.4.8",
|
|
135
136
|
# image_url="https://trmnl.s3.us-east-2.amazonaws.com/plugin-1745348489",
|
|
136
137
|
# image_url_timeout=0,
|
|
137
138
|
# refresh_rate=1771,
|
|
@@ -302,84 +303,83 @@ Success(
|
|
|
302
303
|
|
|
303
304
|
==== Recipes
|
|
304
305
|
|
|
305
|
-
Allows you to obtain information about link:https://
|
|
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.
|
|
306
|
+
Allows you to obtain information about link:https://trmnl.com/recipes[Recipes]. Example:
|
|
308
307
|
|
|
309
308
|
[source,ruby]
|
|
310
309
|
----
|
|
311
|
-
client = TRMNL::API.new { |settings| settings.uri = "https://
|
|
310
|
+
client = TRMNL::API.new { |settings| settings.uri = "https://trmnl.com" }
|
|
312
311
|
|
|
313
|
-
client.recipes
|
|
314
|
-
client.recipes page: 10
|
|
315
|
-
client.recipes search: "comic"
|
|
316
|
-
client.recipes
|
|
312
|
+
client.recipes # Answers first page.
|
|
313
|
+
client.recipes page: 10 # Answers page ten.
|
|
314
|
+
client.recipes search: "comic" # Answers first page of comics.
|
|
315
|
+
client.recipes sort: "popularity" # Answers first page sorted by popularity.
|
|
317
316
|
|
|
318
317
|
# 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
|
-
# >
|
|
318
|
+
# #<data TRMNL::API::Models::Recipe:0x00010fc0
|
|
319
|
+
# data = [
|
|
320
|
+
# #<Struct:TRMNL::API::Models::Recipes::Data:0x00010fe0
|
|
321
|
+
# author = #<Struct:TRMNL::API::Models::Recipes::Author:0x00010ff0
|
|
322
|
+
# category = nil,
|
|
323
|
+
# description = nil,
|
|
324
|
+
# description_locales = {},
|
|
325
|
+
# email_address = nil,
|
|
326
|
+
# field_type = nil,
|
|
327
|
+
# github_url = nil,
|
|
328
|
+
# keyname = nil,
|
|
329
|
+
# learn_more_url = nil,
|
|
330
|
+
# name = nil,
|
|
331
|
+
# youtube_url = nil
|
|
332
|
+
# >,
|
|
333
|
+
# custom_fields = [
|
|
334
|
+
# {
|
|
335
|
+
# "keyname" => "user_location",
|
|
336
|
+
# "field_type" => "string",
|
|
337
|
+
# "name" => "Weather Location",
|
|
338
|
+
# "placeholder" => "New York, NY",
|
|
339
|
+
# "description" => "Choose a location",
|
|
340
|
+
# "help_text" => "Please be precise...",
|
|
341
|
+
# "required" => true
|
|
342
|
+
# },
|
|
343
|
+
# {
|
|
344
|
+
# "keyname" => "metric",
|
|
345
|
+
# "name" => "Temperature Metric",
|
|
346
|
+
# "description" => "Celsius or Fahrenheit?",
|
|
347
|
+
# "field_type" => "select",
|
|
348
|
+
# "options" => [
|
|
349
|
+
# "Fahrenheit",
|
|
350
|
+
# "Celsius"
|
|
351
|
+
# ],
|
|
352
|
+
# "default" => "Fahrenheit"
|
|
353
|
+
# }
|
|
354
|
+
# ],
|
|
355
|
+
# icon_content_type = "image/png",
|
|
356
|
+
# icon_url = "https://trmnl-public.s3.us-east-2.amazonaws.com/ajjlbek4cabcvhk3s1lxggn8cgon",
|
|
357
|
+
# id = 49610,
|
|
358
|
+
# name = "Weather Chum",
|
|
359
|
+
# published_at = 2025-05-14 05:32:00 UTC,
|
|
360
|
+
# screenshot_url = "https://trmnl.s3.us-east-2.amazonaws.com...",
|
|
361
|
+
# statistics = #<data TRMNL::API::Models::Recipes::Statistics:0x00011170
|
|
362
|
+
# forks = 1710,
|
|
363
|
+
# installs = 1
|
|
364
|
+
# >
|
|
365
|
+
# >
|
|
366
|
+
# ],
|
|
367
|
+
# meta = #<data TRMNL::API::Models::Recipes::Meta:0x00016e20
|
|
368
|
+
# current_page = 1,
|
|
369
|
+
# from = 1,
|
|
370
|
+
# next_page_url = "/recipes.json?page=2&sort_by=popularity",
|
|
371
|
+
# per_page = 25,
|
|
372
|
+
# prev_page_url = nil,
|
|
373
|
+
# to = 25,
|
|
374
|
+
# total = 678
|
|
375
|
+
# >
|
|
376
|
+
# >
|
|
379
377
|
# )
|
|
380
378
|
----
|
|
381
379
|
|
|
382
|
-
|
|
380
|
+
⚠️ 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://trmnl.com`) instead of using the default API endpoint.
|
|
381
|
+
|
|
382
|
+
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
383
|
|
|
384
384
|
==== Setup
|
|
385
385
|
|
|
@@ -394,7 +394,7 @@ client.setup id: "A1:B2:C3:D4:E5:F6"
|
|
|
394
394
|
# #<data TRMNL::API::Models::Setup
|
|
395
395
|
# api_key="secret",
|
|
396
396
|
# friendly_id="F51FDE",
|
|
397
|
-
# image_url="https://
|
|
397
|
+
# image_url="https://trmnl.com/images/setup/setup-logo.bmp",
|
|
398
398
|
# message="Register at usetrmnl.com/signup with Device ID 'F51FDE'"
|
|
399
399
|
# >
|
|
400
400
|
# )
|
|
@@ -430,4 +430,4 @@ bin/rake
|
|
|
430
430
|
== Credits
|
|
431
431
|
|
|
432
432
|
* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
|
|
433
|
-
* Engineered by link:https://
|
|
433
|
+
* Engineered by link:https://trmnl.com/developers[TRMNL].
|
|
@@ -13,7 +13,7 @@ module TRMNL
|
|
|
13
13
|
def call
|
|
14
14
|
model[
|
|
15
15
|
content_type: environment.fetch("TRMNL_API_CONTENT_TYPE", "application/json"),
|
|
16
|
-
uri: environment.fetch("TRMNL_API_URI", "https://
|
|
16
|
+
uri: environment.fetch("TRMNL_API_URI", "https://trmnl.com/api")
|
|
17
17
|
]
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -9,6 +9,7 @@ module TRMNL
|
|
|
9
9
|
Display = Dry::Schema.JSON do
|
|
10
10
|
required(:filename).filled :string
|
|
11
11
|
required(:firmware_url).filled :string
|
|
12
|
+
optional(:firmware_version).maybe :string
|
|
12
13
|
required(:image_url).filled :string
|
|
13
14
|
required(:refresh_rate).filled :integer
|
|
14
15
|
required(:reset_firmware).filled :bool
|
|
@@ -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
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
�# � �%���n#�w�JO.��tο�4�?�`��YA��Ϧv������ݸ��%�A�$�C��G
|
|
1
|
+
gU����|��߷k1mҟoSZ)Qx��q��"h��֠F�3�kA]�Drʴ\<Ϗ��f�T� -��f��J�x��K�q����ul��e´���j!�P��k`"��1�ZK��-������dԻ$l���9SQ�����S���^�*;��4���j�3L'�W����'�e��y,� 2��.�'��o��6����Ð�$"J����w��G�NR*p��(u���G�[G����/8�s�a0����]���(�����CPP��C$my٦=�ziw�r�b��A�$b�F�*�n�~c�#[�Їv`\�d���ɝ:�-�(��O�ޟJ��ٷs����Zop��2�r艉loHX�'�ZG��{���z�)Vx�mx�r���9
|
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.11.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
|