Commit6c06e0b1Recorded29 Mar 2026Repositorysigil-lemonsqueezy

Use shared API client helpers from (sigil http client)

Message

Replace local ls-api-url and check-ls-response with build-api-url and make-response-checker from the shared library. The custom ls-error function is used via the parse-error parameter.

Changed
 src/lemonsqueezy.sgl | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
Diff
src/lemonsqueezy.sglmodified
@@ -79,8 +79,7 @@
79
80
;;; Build an API URL from the client base URL and path segments.
81
(define (ls-api-url client . parts)
82
(apply string-append (ls-client-base-url client)
83
(map (lambda (p) (string-append "/" p)) parts)))
+82
(apply build-api-url (ls-client-base-url client) parts))
83
84
;;; Normalize a JSON null value to #f.
85
;;; json-decode returns the symbol 'null' for JSON null, which is
@@ -121,17 +120,11 @@
120
"Lemon Squeezy API error " (number->string status)
121
": " detail))))))
122
124
;;; Check an HTTP response and return parsed JSON or raise an error.
125
(define (check-ls-response response)
126
(if (not (http-response? response))
127
(error "Lemon Squeezy API request failed: no response"))
128
(let ((status (http-response-status response))
129
(body (http-response-body response)))
130
(if (>= status 400)
131
(ls-error status body)
132
(if (and body (not (string=? body "")))
133
(json-decode body)
134
#t))))
+123
;;; Response checker with Lemon Squeezy JSON:API error parsing.
+124
(define check-ls-response
+125
(make-response-checker
+126
name: "Lemon Squeezy API"
+127
parse-error: ls-error))
128
129
;;; Authenticated JSON GET request.
130
(define (ls-get/json client url)