mirror of
https://github.com/usetrmnl/trmnl-api.git
synced 2026-04-29 13:35:13 -07:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user