trmnl-api 0.21.0 → 0.23.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 +48 -14
- data/lib/trmnl/api/client.rb +4 -4
- data/lib/trmnl/api/endpoints/firmware/latest.rb +17 -1
- data/lib/trmnl/api/models/display.rb +12 -10
- data/lib/trmnl/api/models/model.rb +9 -1
- data/lib/trmnl/api/schemas/display.rb +8 -3
- data/lib/trmnl/api/schemas/model.rb +1 -0
- data/trmnl-api.gemspec +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -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: f0980ab987d84b0a2b433ba2e51c940debf05ab8300b68fdabb957bd5d193f8c
|
|
4
|
+
data.tar.gz: e879629070c4aa3790fee398e737c095818e47db0e182fe68dd19b96679ee731
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f68e6cbf30b644f3c931d184f709cdca9d412880bbd369fc21aabd407879c4e959f2d6067be5a6bba647bd6ef8970ec2dfab29bff49e07069a7e909dbd253cfc
|
|
7
|
+
data.tar.gz: 92f25649191286a0a4bc9b17a75cc69330f366daa4b67033335a50d0a95ed504823e6460f3a8dbc83781b5beead560b1343d1967332524cc832fa771aa0dfcfc
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/README.adoc
CHANGED
|
@@ -137,20 +137,21 @@ client = TRMNL::API.new
|
|
|
137
137
|
client.display token: "secret"
|
|
138
138
|
|
|
139
139
|
# Success(
|
|
140
|
-
#
|
|
141
|
-
#
|
|
142
|
-
#
|
|
143
|
-
#
|
|
144
|
-
#
|
|
145
|
-
#
|
|
146
|
-
#
|
|
147
|
-
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
#
|
|
152
|
-
#
|
|
153
|
-
#
|
|
140
|
+
# #<data TRMNL::API::Models::Display
|
|
141
|
+
# filename="plugin-0ac339-1794250527",
|
|
142
|
+
# image_url="https://trmnl.s3.us-east-2.amazonaws.com/...",
|
|
143
|
+
# image_url_timeout=0,
|
|
144
|
+
# refresh_rate=1769,
|
|
145
|
+
# firmware_version="1.8.18",
|
|
146
|
+
# firmware_url="https://trmnl-fw.s3.us-east-2.amazonaws.com/trmnl_og/FW1.8.18.bin",
|
|
147
|
+
# update_firmware=true,
|
|
148
|
+
# reset_firmware=false,
|
|
149
|
+
# maximum_compatibility=false,
|
|
150
|
+
# temperature_profile="default",
|
|
151
|
+
# touchbar_mode="tap",
|
|
152
|
+
# action=nil,
|
|
153
|
+
# playlist_image_names=["plugin-0ac339", "plugin-f60d70", "plugin-499f35"]
|
|
154
|
+
# >
|
|
154
155
|
# )
|
|
155
156
|
----
|
|
156
157
|
|
|
@@ -232,6 +233,38 @@ client.firmware_latest
|
|
|
232
233
|
# )
|
|
233
234
|
----
|
|
234
235
|
|
|
236
|
+
You can also tweak the result to answer current (or past) versions, specific model names, and/or both. Examples:
|
|
237
|
+
|
|
238
|
+
**By Version**
|
|
239
|
+
|
|
240
|
+
[source,ruby]
|
|
241
|
+
----
|
|
242
|
+
client = TRMNL::API.new
|
|
243
|
+
client.firmware_latest "1.8.0"
|
|
244
|
+
|
|
245
|
+
# Success(
|
|
246
|
+
# #<data TRMNL::API::Models::Firmware::Latest
|
|
247
|
+
# url="https://trmnl-fw.s3.us-east-2.amazonaws.com/trmnl_og/FW1.8.0.bin",
|
|
248
|
+
# version="1.8.0">
|
|
249
|
+
# )
|
|
250
|
+
----
|
|
251
|
+
|
|
252
|
+
**By Model Name**
|
|
253
|
+
|
|
254
|
+
[source,ruby]
|
|
255
|
+
----
|
|
256
|
+
client = TRMNL::API.new
|
|
257
|
+
client.firmware_latest model_name: "trmnl_x"
|
|
258
|
+
|
|
259
|
+
# Success(
|
|
260
|
+
# #<data TRMNL::API::Models::Firmware::Latest
|
|
261
|
+
# url="https://trmnl-fw.s3.us-east-2.amazonaws.com/trmnl_x/FW1.8.17.bin",
|
|
262
|
+
# version="1.8.17">
|
|
263
|
+
# )
|
|
264
|
+
----
|
|
265
|
+
|
|
266
|
+
⚠️ This isn't officially supported by the TRMNL API since the endpoint only knows how to provide the latest firmware for OG models so the above allows you to obtain what you need by dynamically formatting the URI based on version and model name. This also means if you make a typo, you might get a URI that doesn't exist since no verification happens.
|
|
267
|
+
|
|
235
268
|
==== IP Addresses
|
|
236
269
|
|
|
237
270
|
Allows you obtain a list of public IP addresses for all TRMNL core servers because plugin poll requests will only originate from these IPs. Example:
|
|
@@ -354,6 +387,7 @@ client.models
|
|
|
354
387
|
# "gray-4",
|
|
355
388
|
# "bw"
|
|
356
389
|
# ],
|
|
390
|
+
# default_palette_name = "gray-16"
|
|
357
391
|
# rotation = 0,
|
|
358
392
|
# scale_factor = 1.8,
|
|
359
393
|
# width = 1872
|
data/lib/trmnl/api/client.rb
CHANGED
|
@@ -6,9 +6,6 @@ module TRMNL
|
|
|
6
6
|
module API
|
|
7
7
|
# Provides the primary client for making API requests.
|
|
8
8
|
class Client
|
|
9
|
-
include Dependencies[:settings]
|
|
10
|
-
include Inspectable[:endpoints]
|
|
11
|
-
|
|
12
9
|
ENDPOINTS = {
|
|
13
10
|
categories: Endpoints::Category,
|
|
14
11
|
current_screen: Endpoints::CurrentScreen,
|
|
@@ -23,6 +20,9 @@ module TRMNL
|
|
|
23
20
|
setup: Endpoints::Setup
|
|
24
21
|
}.freeze
|
|
25
22
|
|
|
23
|
+
include Dependencies[:settings]
|
|
24
|
+
include Inspectable[:endpoints]
|
|
25
|
+
|
|
26
26
|
def initialize(requester: Requester, endpoints: ENDPOINTS, **)
|
|
27
27
|
super(**)
|
|
28
28
|
|
|
@@ -43,7 +43,7 @@ module TRMNL
|
|
|
43
43
|
|
|
44
44
|
def firmware_flashes = endpoints.fetch(__method__).call
|
|
45
45
|
|
|
46
|
-
def firmware_latest = endpoints.fetch(__method__).call
|
|
46
|
+
def firmware_latest(...) = endpoints.fetch(__method__).call(...)
|
|
47
47
|
|
|
48
48
|
def ip_addresses = endpoints.fetch(__method__).call
|
|
49
49
|
|
|
@@ -9,6 +9,8 @@ module TRMNL
|
|
|
9
9
|
module Firmware
|
|
10
10
|
# Handles API request/response.
|
|
11
11
|
class Latest
|
|
12
|
+
ASSET_URI = "https://trmnl-fw.s3.us-east-2.amazonaws.com/%<model_name>s/FW%<version>s.bin"
|
|
13
|
+
|
|
12
14
|
include TRMNL::API::Dependencies[
|
|
13
15
|
:requester,
|
|
14
16
|
schema: "schemas.firmware.latest",
|
|
@@ -18,12 +20,26 @@ module TRMNL
|
|
|
18
20
|
include Inspectable[schema: :type]
|
|
19
21
|
include Pipeable
|
|
20
22
|
|
|
21
|
-
def
|
|
23
|
+
def initialize(asset_uri: ASSET_URI, **)
|
|
24
|
+
@asset_uri = asset_uri
|
|
25
|
+
super(**)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def call version = nil, model_name: "trmnl_og"
|
|
22
29
|
pipe requester.get("firmware/latest"),
|
|
23
30
|
try(:parse, catch: JSON::ParserError),
|
|
24
31
|
validate(schema, as: :to_h),
|
|
32
|
+
fmap { transform_uri it, (version || it[:version]), model_name },
|
|
25
33
|
to(model, :for)
|
|
26
34
|
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
attr_reader :asset_uri
|
|
39
|
+
|
|
40
|
+
def transform_uri data, version, model_name
|
|
41
|
+
data.merge! url: format(asset_uri, model_name:, version:), version:
|
|
42
|
+
end
|
|
27
43
|
end
|
|
28
44
|
end
|
|
29
45
|
end
|
|
@@ -6,32 +6,34 @@ module TRMNL
|
|
|
6
6
|
# Models the data of the API response.
|
|
7
7
|
Display = Data.define(
|
|
8
8
|
:filename,
|
|
9
|
-
:firmware_url,
|
|
10
|
-
:firmware_version,
|
|
11
9
|
:image_url,
|
|
12
10
|
:image_url_timeout,
|
|
13
|
-
:maximum_compatibility,
|
|
14
11
|
:refresh_rate,
|
|
12
|
+
:firmware_version,
|
|
13
|
+
:firmware_url,
|
|
14
|
+
:update_firmware,
|
|
15
15
|
:reset_firmware,
|
|
16
|
-
:
|
|
16
|
+
:maximum_compatibility,
|
|
17
17
|
:temperature_profile,
|
|
18
18
|
:touchbar_mode,
|
|
19
|
-
:
|
|
19
|
+
:action,
|
|
20
|
+
:playlist_image_names
|
|
20
21
|
) do
|
|
21
22
|
def self.for(attributes) = new(**attributes)
|
|
22
23
|
|
|
23
24
|
def initialize filename: nil,
|
|
24
|
-
firmware_url: nil,
|
|
25
|
-
firmware_version: nil,
|
|
26
25
|
image_url: nil,
|
|
27
26
|
image_url_timeout: 0,
|
|
28
|
-
maximum_compatibility: false,
|
|
29
27
|
refresh_rate: 300,
|
|
28
|
+
firmware_version: nil,
|
|
29
|
+
firmware_url: nil,
|
|
30
|
+
update_firmware: false,
|
|
30
31
|
reset_firmware: false,
|
|
31
|
-
|
|
32
|
+
maximum_compatibility: false,
|
|
32
33
|
temperature_profile: "default",
|
|
33
34
|
touchbar_mode: "tap",
|
|
34
|
-
|
|
35
|
+
action: nil,
|
|
36
|
+
playlist_image_names: nil
|
|
35
37
|
super
|
|
36
38
|
end
|
|
37
39
|
|
|
@@ -21,9 +21,17 @@ module TRMNL
|
|
|
21
21
|
:offset_x,
|
|
22
22
|
:offset_y,
|
|
23
23
|
:palette_names,
|
|
24
|
+
:default_palette_name,
|
|
24
25
|
:css
|
|
25
26
|
) do
|
|
26
|
-
def self.for
|
|
27
|
+
def self.for attributes
|
|
28
|
+
new(
|
|
29
|
+
**attributes.transform_keys!(
|
|
30
|
+
palette_ids: :palette_names,
|
|
31
|
+
default_palette_id: :default_palette_name
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
end
|
|
27
35
|
|
|
28
36
|
def initialize(**)
|
|
29
37
|
super
|
|
@@ -8,13 +8,18 @@ module TRMNL
|
|
|
8
8
|
# Validates API response.
|
|
9
9
|
Display = Dry::Schema.JSON do
|
|
10
10
|
required(:filename).filled :string
|
|
11
|
-
required(:firmware_url).filled :string
|
|
12
|
-
optional(:firmware_version).maybe :string
|
|
13
11
|
required(:image_url).filled :string
|
|
12
|
+
optional(:image_url_timeout).filled :integer
|
|
14
13
|
required(:refresh_rate).filled :integer
|
|
14
|
+
optional(:firmware_version).filled :string
|
|
15
|
+
required(:firmware_url).filled :string
|
|
15
16
|
required(:reset_firmware).filled :bool
|
|
16
|
-
required(:special_function).filled :string
|
|
17
17
|
required(:update_firmware).filled :bool
|
|
18
|
+
optional(:maximum_compatibility).filled :bool
|
|
19
|
+
optional(:temperature_profile).filled :string
|
|
20
|
+
optional(:touchbar_mode).filled :string
|
|
21
|
+
optional(:action).filled :string
|
|
22
|
+
optional(:playlist_image_names).filled(:array).each(:string)
|
|
18
23
|
end
|
|
19
24
|
end
|
|
20
25
|
end
|
|
@@ -22,6 +22,7 @@ module TRMNL
|
|
|
22
22
|
required(:offset_x).filled :integer
|
|
23
23
|
required(:offset_y).filled :integer
|
|
24
24
|
required(:palette_ids).array(:string)
|
|
25
|
+
required(:default_palette_id).filled :string
|
|
25
26
|
optional(:css).hash do
|
|
26
27
|
optional(:classes).hash do
|
|
27
28
|
required(:density).filled :string
|
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.23.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
272
272
|
- !ruby/object:Gem::Version
|
|
273
273
|
version: '0'
|
|
274
274
|
requirements: []
|
|
275
|
-
rubygems_version: 4.0.
|
|
275
|
+
rubygems_version: 4.0.24
|
|
276
276
|
specification_version: 4
|
|
277
277
|
summary: A monadic TRMNL API client.
|
|
278
278
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|