Commit678f2fe1Recorded29 Mar 2026Repositorysigil-wise
Use shared API client helpers from (sigil http client)
Message
Replace local wise-api-url and wise-get/json with build-api-url and make-response-checker from the shared library.
Changed
src/wise.sgl | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)Diff
src/wise.sglmodified
@@ -98,38 +98,21 @@
98
99
;;; Build an API URL from the client base URL and path segments. 100
(define (wise-api-url client . parts)−101
(apply string-append (wise-client-base-url client)−102
(map (lambda (p) (string-append "/" p)) parts)))+101
(apply build-api-url (wise-client-base-url client) parts)) 102
103
+104
;;; Response checker with Wise-specific error context.+105
(define check-wise-response+106
(make-response-checker+107
name: "Wise API"+108
handlers: (list+109
(cons 403 "This may be an SCA restriction for UK/EEA accounts. See https://docs.wise.com for SCA re-authentication.")+110
(cons 429 "Rate limited. Retry after a delay."))))+111
112
;;; Perform an authenticated GET request and return parsed JSON.−106
;;; Raises an error on HTTP status >= 400, with Wise-specific context. 113
(define (wise-get/json client url)−108
(let ((response (http-get url headers: (wise-auth-headers client))))−109
(if (not (http-response? response))−110
(error "Wise API request failed: no response"))−111
(let ((status (http-response-status response))−112
(body (http-response-body response)))−113
(cond−114
((= status 403)−115
(error (string-append−116
"Wise API 403 Forbidden. "−117
"This may be an SCA restriction for UK/EEA accounts. "−118
"See https://docs.wise.com for SCA re-authentication. "−119
"Response: " (or body ""))))−120
((= status 429)−121
(error (string-append−122
"Wise API 429 rate limited. "−123
"Retry after a delay. "−124
"Response: " (or body ""))))−125
((>= status 400)−126
(error (string-append−127
"Wise API error " (number->string status) ": "−128
(or body ""))))−129
(else−130
(if (and body (not (string=? body "")))−131
(json-decode body)−132
#t))))))+114
(check-wise-response+115
(http-get url headers: (wise-auth-headers client)))) 116
117
;; --------------------------------------------------------------- 118
;; Response parsing