Fixed recipe endpoint to use sort key

Use of `sort-by` -- as provied by the API -- is awkward so this simplifies usage so you can use the `sort` key as a symbol which is consistent with existing keys.

Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2026-01-22 15:20:06 -07:00
parent 97bf0e3c30
commit 268ac8d4e0
+7 -2
View File
@@ -2,6 +2,7 @@
require "inspectable"
require "pipeable"
require "refinements/hash"
module TRMNL
module API
@@ -17,9 +18,13 @@ module TRMNL
include Inspectable[contract: :type]
include Pipeable
def call(**)
using Refinements::Hash
def call(**parameters)
parameters.transform_keys! sort: "sort-by"
pipe(
requester.get("recipes.json", **),
requester.get("recipes.json", **parameters),
try(:parse, catch: JSON::ParserError),
validate(contract, as: :to_h),
to(model, :for)