trmnl-api 0.21.0 → 0.22.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: 8efedaa295b0c387a87ff3ae179bc8179e21485505de33474d1b5e00bb694e15
4
+ data.tar.gz: ca6875d143b129e2b42114289a3be856e41b5581b4e7ba5286292e6829b3c940
5
5
  SHA512:
6
- metadata.gz: 8099e1466106d6a33afec9ec777e378bee3805ea7f0abbf2e73044373705b9eae36c2c6290c6748c2e592dfadb9e16d734f67a2aba3a50a936fde136c35ff11e
7
- data.tar.gz: f6b487d1e3ee7b3f1bb55cf992d88c106427093fe6bcb84937a19a47ef0031bc4a35c6d2413ceb8c2be9f37404280ed78227b2488cc1aee54e4bcf95437e4e66
6
+ metadata.gz: d2ba42f64f6e549c6852b5326d7ef0e1a1a8356baff3010fa88e2fe7469fcc82986b3b15ade6fe9734cc1d7df36474139b8c6345733eb8bf932e900ddd04f791
7
+ data.tar.gz: 0d7e7e1ade6a86c1f689ac783ba5160dd87544306e295b9befe9150c86cb26d410f15e0efa64ee867be9e2a06ef06bd82c6ff19a6502a53709da4a2f863db570
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -232,6 +232,38 @@ client.firmware_latest
232
232
  # )
233
233
  ----
234
234
 
235
+ You can also tweak the result to answer current (or past) versions, specific model names, and/or both. Examples:
236
+
237
+ **By Version**
238
+
239
+ [source,ruby]
240
+ ----
241
+ client = TRMNL::API.new
242
+ client.firmware_latest "1.8.0"
243
+
244
+ # Success(
245
+ # #<data TRMNL::API::Models::Firmware::Latest
246
+ # url="https://trmnl-fw.s3.us-east-2.amazonaws.com/trmnl_og/FW1.8.0.bin",
247
+ # version="1.8.0">
248
+ # )
249
+ ----
250
+
251
+ **By Model Name**
252
+
253
+ [source,ruby]
254
+ ----
255
+ client = TRMNL::API.new
256
+ client.firmware_latest model_name: "trmnl_x"
257
+
258
+ # Success(
259
+ # #<data TRMNL::API::Models::Firmware::Latest
260
+ # url="https://trmnl-fw.s3.us-east-2.amazonaws.com/trmnl_x/FW1.8.17.bin",
261
+ # version="1.8.17">
262
+ # )
263
+ ----
264
+
265
+ ⚠️ 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.
266
+
235
267
  ==== IP Addresses
236
268
 
237
269
  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:
@@ -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
 
@@ -18,12 +18,28 @@ module TRMNL
18
18
  include Inspectable[schema: :type]
19
19
  include Pipeable
20
20
 
21
- def call
21
+ ASSET_URI = "https://trmnl-fw.s3.us-east-2.amazonaws.com/%<model_name>s/FW%<version>s.bin"
22
+
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
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.22.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.22.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.22
276
276
  specification_version: 4
277
277
  summary: A monadic TRMNL API client.
278
278
  test_files: []
metadata.gz.sig CHANGED
Binary file