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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4ad04625f2891041bc884419cfdf98484be6a3a6a45cec71a45353615b3280f
4
- data.tar.gz: eca25cf2510f0967c85960102396e4307a3f99054640d3ef07b0f288b22ccde1
3
+ metadata.gz: f0980ab987d84b0a2b433ba2e51c940debf05ab8300b68fdabb957bd5d193f8c
4
+ data.tar.gz: e879629070c4aa3790fee398e737c095818e47db0e182fe68dd19b96679ee731
5
5
  SHA512:
6
- metadata.gz: 8099e1466106d6a33afec9ec777e378bee3805ea7f0abbf2e73044373705b9eae36c2c6290c6748c2e592dfadb9e16d734f67a2aba3a50a936fde136c35ff11e
7
- data.tar.gz: f6b487d1e3ee7b3f1bb55cf992d88c106427093fe6bcb84937a19a47ef0031bc4a35c6d2413ceb8c2be9f37404280ed78227b2488cc1aee54e4bcf95437e4e66
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
- # #<struct TRMNL::API::Models::Display
141
- # filename="plugin-4c2660-1780411821",
142
- # firmware_url="https://trmnl-fw.s3.us-east-2.amazonaws.com/trmnl_og/FW1.8.5.bin",
143
- # firmware_version="1.8.5",
144
- # image_url="https://trmnl.s3.us-east-2.amazonaws.com/...",
145
- # image_url_timeout=0,
146
- # maximum_compatibility=false,
147
- # refresh_rate=1765,
148
- # reset_firmware=false,
149
- # special_function="none",
150
- # temperature_profile="default",
151
- # touchbar_mode="tap",
152
- # update_firmware=true
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
@@ -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 call
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
- :special_function,
16
+ :maximum_compatibility,
17
17
  :temperature_profile,
18
18
  :touchbar_mode,
19
- :update_firmware
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
- special_function: "none",
32
+ maximum_compatibility: false,
32
33
  temperature_profile: "default",
33
34
  touchbar_mode: "tap",
34
- update_firmware: false
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(attributes) = new(**attributes.transform_keys!(palette_ids: :palette_names))
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "trmnl-api"
5
- spec.version = "0.21.0"
5
+ spec.version = "0.23.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/trmnl-api"
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.21.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.21
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