trmnl-api 0.11.0 → 0.13.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: ff7ecb483d86f9e68a550342e7e923e08ac1ef5d7330a12f4631e94e7a517438
4
- data.tar.gz: a249a3fd8c173416d35fb2da4a15be7accf19e29e6505e667c90b4f440866047
3
+ metadata.gz: 1bf06832c324918b8f93b02b8a8700b617c57cd804e206b2b28b20dc0509c6f2
4
+ data.tar.gz: 5547395a2b3fe1abb54de0cee20a58bbb438bdfc9786a5a602eef40a8b12e147
5
5
  SHA512:
6
- metadata.gz: 40d5b26f6f84761379eb2078048ed792eb376506c3e7bc4d59bd05f08215008be16ccff61548cbd63a302350b357174c479fefcce692cd0d34c6fac3d280dd05
7
- data.tar.gz: c8ac0a599cf3743f67f58ac0e9021277b08327110b952b4b7c0aabf45ad3679eeae05b0bfe44dc2ea39e191c6370a857558b3422193d01edb82d49c2b4b2d4d3
6
+ metadata.gz: e8c73489d9f1334bbd721aab3c7c6270b4bb791982112245b57a9a1305d1e8f6f108e82356dcecf25db970e644ee9de3b626b1db5b4b741edcd633ed262e4e03
7
+ data.tar.gz: c511a0cd0e6ca2a15584ee84bf58b6f6556b503118b2a89075401e0c515217a9821ce1e249b1e77741e166bd432678e932d9d4416926174067381df50ebef848
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -76,8 +76,8 @@ end
76
76
 
77
77
  You can configure the client via the following environment variables:
78
78
 
79
- * `TRMNL_API_CONTENT_TYPE`: Defines the HTTP `Content-Type` header. You shouldn't need to change this but is here if you need it. Default: "application/json".
80
- * `TRMNL_API_URI`: Defines the API URI. Default: "https://trmnl.app/api".
79
+ * `TRMNL_API_CONTENT_TYPE`: Defines the HTTP `Content-Type` header. You shouldn't need to change this but is here if you need it. Default: `"application/json"`.
80
+ * `TRMNL_API_URI`: Defines the API URI. Default: `"https://trmnl.app/api"`.
81
81
 
82
82
  Any/all environment changes will be applied unless you override these settings via the client configuration block shown above.
83
83
 
@@ -227,46 +227,48 @@ client = TRMNL::API.new
227
227
  client.models
228
228
 
229
229
  # Success(
230
- # #<data TRMNL::API::Models::Model
231
- # name="test",
232
- # label="Test",
233
- # description="A test.",
234
- # kind="trmnl",
235
- # colors=2,
236
- # bit_depth=1,
237
- # scale_factor=1,
238
- # rotation=90,
239
- # mime_type="image/png",
240
- # width=800,
241
- # height=480,
242
- # offset_x=10,
243
- # offset_y=15,
244
- # palette_ids=["bw"],
245
- # css: {
246
- # classes: {
247
- # device: "screen--og_png",
248
- # size: "screen--md"
249
- # },
250
- # variables: [
251
- # [
252
- # "--screen-w",
253
- # "800px"
254
- # ],
255
- # [
256
- # "--screen-h",
257
- # "480px"
258
- # ],
259
- # [
260
- # "--ui-scale",
261
- # "1.0"
262
- # ],
263
- # [
264
- # "--gap-scale",
265
- # "1.0"
266
- # ]
267
- # ]
268
- # }
269
- # >
230
+ # [
231
+ # #<data TRMNL::API::Models::Model
232
+ # name="test",
233
+ # label="Test",
234
+ # description="A test.",
235
+ # kind="trmnl",
236
+ # colors=2,
237
+ # bit_depth=1,
238
+ # scale_factor=1,
239
+ # rotation=90,
240
+ # mime_type="image/png",
241
+ # width=800,
242
+ # height=480,
243
+ # offset_x=10,
244
+ # offset_y=15,
245
+ # palette_names=["bw"],
246
+ # css: {
247
+ # classes: {
248
+ # device: "screen--og_png",
249
+ # size: "screen--md"
250
+ # },
251
+ # variables: [
252
+ # [
253
+ # "--screen-w",
254
+ # "800px"
255
+ # ],
256
+ # [
257
+ # "--screen-h",
258
+ # "480px"
259
+ # ],
260
+ # [
261
+ # "--ui-scale",
262
+ # "1.0"
263
+ # ],
264
+ # [
265
+ # "--gap-scale",
266
+ # "1.0"
267
+ # ]
268
+ # ]
269
+ # }
270
+ # >
271
+ # ]
270
272
  # )
271
273
  ----
272
274
 
@@ -274,7 +276,7 @@ client.models
274
276
 
275
277
  ==== Palettes
276
278
 
277
- Allows you to obtain palettes details. The IDs correlate to the `palette_ids` as found in the Models API. Example:
279
+ Allows you to obtain palettes details. The names correlate to the `palette_names` as found in the Models API. Example:
278
280
 
279
281
  [source,ruby]
280
282
  ----
@@ -283,19 +285,30 @@ client.palettes
283
285
 
284
286
  Success(
285
287
  [
286
- #<data TRMNL::API::Models::Palette
287
- id="bw",
288
- name="Black & White (1-bit)",
289
- grays=2,
290
- colors=nil,
291
- framework_class="screen--1bit"
288
+ #<Struct:TRMNL::API::Models::Palette
289
+ name = "bw",
290
+ label = "Black & White (1-bit)",
291
+ grays = 2,
292
+ colors = [],
293
+ framework_class = "screen--1bit"
294
+ >,
295
+ #<Struct:TRMNL::API::Models::Palette
296
+ name = "color-3bwr",
297
+ label = "Color (3 colors)",
298
+ grays = 2,
299
+ colors = [
300
+ "#000000",
301
+ "#FF0000",
302
+ "#FFFFFF"
303
+ ],
304
+ framework_class = nil
292
305
  >,
293
- #<data TRMNL::API::Models::Palette
294
- id="color-24bit",
295
- name="Color (24-bit)",
296
- grays=nil,
297
- colors=nil,
298
- framework_class=""
306
+ #<Struct:TRMNL::API::Models::Palette
307
+ name = "color-24bit",
308
+ label = "Color (16777216 colors)",
309
+ grays = 2,
310
+ colors = [],
311
+ framework_class = nil
299
312
  >
300
313
  ]
301
314
  )
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/hash"
4
+
3
5
  module TRMNL
4
6
  module API
5
7
  module Models
@@ -18,10 +20,10 @@ module TRMNL
18
20
  :height,
19
21
  :offset_x,
20
22
  :offset_y,
21
- :palette_ids,
23
+ :palette_names,
22
24
  :css
23
25
  ) do
24
- def self.for(attributes) = new(**attributes)
26
+ def self.for(attributes) = new(**attributes.transform_keys(palette_ids: :palette_names))
25
27
 
26
28
  def initialize(**)
27
29
  super
@@ -34,6 +36,8 @@ module TRMNL
34
36
  private
35
37
 
36
38
  def apply_defaults
39
+ self[:palette_names] ||= []
40
+
37
41
  %i[colors bit_depth scale_factor rotation width height offset_x offset_y].each do |name|
38
42
  self[name] ||= 0
39
43
  end
@@ -1,11 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/hash"
4
+
3
5
  module TRMNL
4
6
  module API
5
7
  module Models
6
8
  # Models the data of the API response.
7
- Palette = Struct.new :id, :name, :grays, :colors, :framework_class do
8
- def self.for(attributes) = new(**attributes)
9
+ Palette = Struct.new :name, :label, :grays, :colors, :framework_class do
10
+ using Refinements::Hash
11
+
12
+ def self.for(attributes) = new(**attributes.transform_keys(name: :label, id: :name))
13
+
14
+ def initialize(**)
15
+ super
16
+ self[:grays] ||= 0
17
+ self[:colors] ||= []
18
+ freeze
19
+ end
9
20
  end
10
21
  end
11
22
  end
@@ -5,6 +5,8 @@ module TRMNL
5
5
  module Models
6
6
  # Models the payload of the API response.
7
7
  Recipe = ::Data.define :data, :meta do
8
+ def self.empty(meta: Recipes::Meta.new) = new(data: [], meta:)
9
+
8
10
  def self.for(**attributes)
9
11
  meta = attributes.slice :from,
10
12
  :to,
data/trmnl-api.gemspec CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "trmnl-api"
5
- spec.version = "0.11.0"
5
+ spec.version = "0.13.0"
6
6
  spec.authors = ["TRMNL"]
7
- spec.email = ["engineering@usetrmnl.com"]
7
+ spec.email = ["engineering@trmnl.com"]
8
8
  spec.homepage = "https://github.com/usetrmnl/trmnl-api"
9
9
  spec.summary = "A monadic TRMNL API client."
10
10
  spec.license = "MIT"
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.11.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TRMNL
@@ -176,7 +176,7 @@ dependencies:
176
176
  - !ruby/object:Gem::Version
177
177
  version: '2.7'
178
178
  email:
179
- - engineering@usetrmnl.com
179
+ - engineering@trmnl.com
180
180
  executables: []
181
181
  extensions: []
182
182
  extra_rdoc_files:
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  - !ruby/object:Gem::Version
254
254
  version: '0'
255
255
  requirements: []
256
- rubygems_version: 4.0.4
256
+ rubygems_version: 4.0.8
257
257
  specification_version: 4
258
258
  summary: A monadic TRMNL API client.
259
259
  test_files: []
metadata.gz.sig CHANGED
Binary file