#lang scheme
(require (planet cce/scheme:7/planet)
(this-package-in method)
(this-package-in flickr-reflection))
(provide (all-defined-out))
(current-api-key "138427ce2d97d6a2d0c4a2f045a59bfa")
(define all-method-names (parameterize ((non-text-tags (list* 'methods (non-text-tags))))
(match (flickr.reflection.getMethods)
[(list (list-rest 'methods _ (list (list 'method _ name) ...))) name])))
(define (get-method-info method-name) (parameterize ((non-text-tags (list* 'method 'arguments 'errors (non-text-tags))))
(match (flickr.reflection.getMethodInfo #:method_name method-name)
[(list (list-rest 'method (list (list 'name name)
(list 'needslogin needs-login)
(list 'needssigning needs-signing)
(list 'requiredperms required-perms))
(list-rest 'description '() description)
method-spec)
(list-rest 'arguments '() argument-specs)
(list-rest 'errors '() error-specs))
(make-method-info
name
(flickr-true? needs-login)
(flickr-true? needs-signing)
required-perms (apply string-append description)
(match method-spec
[(list-no-order (list-rest 'response '() response) _ ...)
(apply string-append response)]
[_ #f])
(match method-spec
[(list-no-order (list-rest 'explanation '() explan) _ ...)
(apply string-append explan)]
[_ #f])
(map (match-lambda
[(list-rest 'argument (list (list 'name name) (list 'optional opt)) description)
(make-argument-info name (flickr-true? opt) (apply string-append description))])
argument-specs)
(map (match-lambda
[(list-rest 'error (list (list 'code code) (list 'message msg)) explan)
(make-error-info code msg (apply string-append explan))])
error-specs))])))
(define all-method-infos
(delay (map get-method-info all-method-names)))