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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb8a2557d167924338d70a68b91207d89f48b72a44e66e252fd0760fc3ffc035
4
- data.tar.gz: 4c3329056c42c1b57347eb00b748f0baf384720c67aeacf938ce2dcecee4a2e3
3
+ metadata.gz: ff7ecb483d86f9e68a550342e7e923e08ac1ef5d7330a12f4631e94e7a517438
4
+ data.tar.gz: a249a3fd8c173416d35fb2da4a15be7accf19e29e6505e667c90b4f440866047
5
5
  SHA512:
6
- metadata.gz: 6b7a621e59c10820c52b5dbad143b03399544297fba3faa89078a938539ef53cbb7c823a1028f24930fa4edd56d21c2788a440bdf5b3310ccba8d8dac1fc7f06
7
- data.tar.gz: b67362a9aa48c7a4009e5b7f59201378c69bca85de6bb560e4c1b208ab6c5bc15c64e6edceb17d3d6a163b7f1fae00fffb3052c987cb9ee4a851c131b713ead9
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://usetrmnl.com[TRMNL]
6
- :trmnl_api_link: link:https://usetrmnl.com/api-docs/index.html[TRMNL API]
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://usetrmnl.com/plugin-2025-04-10T11-34-38Z-380c77",
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://usetrmnl.com/recipes[Recipes]. Example:
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://usetrmnl.com" }
310
+ client = TRMNL::API.new { |settings| settings.uri = "https://trmnl.com" }
312
311
 
313
- client.recipes # Answers first page.
314
- client.recipes page: 10 # Answers page ten.
315
- client.recipes search: "comic" # Answers first page of comics.
316
- client.recipes "sort-by": "popularity" # Answers first page sorted by popularity.
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
- # #<data TRMNL::API::Models::Recipe:0x0000b4d0
320
- # current_page = 1,
321
- # data = [
322
- # #<Struct:TRMNL::API::Models::Recipes::Entry:0x0000b4f0
323
- # author = #<Struct:TRMNL::API::Models::Recipes::Author:0x0000b500
324
- # category = "travel",
325
- # description = "Displays upcoming...",
326
- # description_locales = {},
327
- # email_address = nil,
328
- # field_type = "author_bio",
329
- # github_url = "https://github.com/CaptainProton42/trmnl-bustimes-org",
330
- # keyname = "readme",
331
- # learn_more_url = nil,
332
- # name = "About This Plugin",
333
- # youtube_url = nil
334
- # >,
335
- # custom_fields = [
336
- # {
337
- # "keyname" => "readme",
338
- # "name" => "About This Plugin",
339
- # "category" => "travel",
340
- # "field_type" => "author_bio",
341
- # "description" => "Displays upcoming...",
342
- # "github_url" => "https://github.com/CaptainProton42/trmnl-bustimes-org"
343
- # },
344
- # {
345
- # "keyname" => "atco",
346
- # "field_type" => "string",
347
- # "name" => "Bus Stop",
348
- # "description" => "The <a href=\"https://mullinscr.github.io/naptan/atco_codes/\">ATCO</a> code for your bus stop.",
349
- # "help_text" => "You can find this..."
350
- # },
351
- # {
352
- # "keyname" => "bus",
353
- # "field_type" => "multi_string",
354
- # "name" => "Busses",
355
- # "description" => "Optionally, choose specific bus services you want to display departures for.",
356
- # "help_text" => "Use the name of the service, e.g. '10' or '3A'.",
357
- # "optional" => true
358
- # }
359
- # ],
360
- # icon_content_type = "image/png",
361
- # icon_url = "https://trmnl-public.s3.us-east-2.amazonaws.com/59lqujqwid1cvzsd7sr3erfuexur",
362
- # id = 222328,
363
- # name = "UK Bus Departures (bustimes.org)",
364
- # published_at = 2026-01-14 22:53:07.587 UTC,
365
- # screenshot_url = "https://trmnl.s3.us-east-2.amazonaws.com...",
366
- # statistics = #<data TRMNL::API::Models::Recipes::Statistics:0x0000b710
367
- # forks = 0,
368
- # installs = 1
369
- # >
370
- # >
371
- # ],
372
- # from = 1,
373
- # next_page_url = "/recipes.json?page=2",
374
- # per_page = 25,
375
- # prev_page_url = nil,
376
- # to = 25,
377
- # total = 658
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
- You'll always get a `data` array with may or may not be filled. Pagination information is listed at the bottom.
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://usetrmnl.com/images/setup/setup-logo.bmp",
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://usetrmnl.com/developers[TRMNL].
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://usetrmnl.com/api")
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
- def call(**)
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
@@ -7,6 +7,7 @@ module TRMNL
7
7
  Display = Struct.new(
8
8
  :filename,
9
9
  :firmware_url,
10
+ :firmware_version,
10
11
  :image_url,
11
12
  :image_url_timeout,
12
13
  :refresh_rate,
@@ -4,7 +4,7 @@ module TRMNL
4
4
  module API
5
5
  module Models
6
6
  # Models the data of the API response.
7
- Firmware = Data.define :url, :version do
7
+ Firmware = ::Data.define :url, :version 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 data of the API response.
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
- data = attributes[:data].map { Recipes::Entry.for(**it) }
19
- new(**attributes.merge!(data:))
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
@@ -5,7 +5,7 @@ module TRMNL
5
5
  module Models
6
6
  module Recipes
7
7
  # Models the data of the API response.
8
- Entry = Struct.new(
8
+ Data = Struct.new(
9
9
  :id,
10
10
  :name,
11
11
  :icon_url,
@@ -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
@@ -5,7 +5,7 @@ module TRMNL
5
5
  module Models
6
6
  module Recipes
7
7
  # Models the statistics of the API response.
8
- Statistics = Data.define :installs, :forks
8
+ Statistics = ::Data.define :installs, :forks
9
9
  end
10
10
  end
11
11
  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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "trmnl-api"
5
- spec.version = "0.9.0"
5
+ spec.version = "0.11.0"
6
6
  spec.authors = ["TRMNL"]
7
7
  spec.email = ["engineering@usetrmnl.com"]
8
8
  spec.homepage = "https://github.com/usetrmnl/trmnl-api"
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- m�ڡN!A�*��v�*����U�}��7��$ⳟYXz��_��*����~���]?��(⚚17��tzdLFǬ�?o8�,�I.�@��G�>kY'`-��w��P��'r1C.�=����uL�iF��M��MSٽ���Ϯ)�������<*t$9�s�^P�=�(����1i�8KI»`����\Jb��G��͒.S���䔫�D���Kz��v����gu[Y��
2
- �# � �%���n#�w�JO.��tο�4�?�`��YA��Ϧv������ݸ��%�A�$�C��G
1
+ gU����|��߷k1mҟoSZ)Qx��q��"h��֠F3kA]�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��GNR*p��(u ���G�[G����/8�s�a0����]���(�����CPP��C$my٦=�ziwr�b��A�$bF�*�n�~c�#[�Їv`\�d���ɝ:�-�(��O�ޟJ��ٷs����Zop��2r艉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.9.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/entry.rb
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