Created
October 15, 2010 14:53
-
-
Save outworlder/628310 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (use ssax) | |
| (use uri-common) | |
| (use http-client) | |
| (use intarweb) | |
| (determine-proxy | |
| (lambda (uri) | |
| (uri-reference "http://localhost:3128"))) | |
| (define *method-urls* | |
| '((marketstat . "http://api.eve-central.com/api/marketstat") | |
| (quicklook . "http://eve-central.com/api/quicklook"))) | |
| (define (request-api method params) | |
| (write params) | |
| (write (filter-false params)) | |
| (with-input-from-request | |
| (make-request method: 'POST | |
| uri: (uri-reference (cdr (assq method *method-urls*)))) | |
| (filter-false params) | |
| (lambda () | |
| (ssax:xml->sxml (current-input-port) '())))) | |
| (define (marketstat item #!key hours minq regionlimit) | |
| (request-api 'marketstat | |
| `((typeid . ,item) | |
| (hours . ,hours) | |
| (minQ . ,minq) | |
| (regionlimit . ,regionlimit)))) | |
| (define (quicklook item #!key sethours regionlimit usesystem minq) | |
| (request-api 'quicklook | |
| `((typeid . ,item) | |
| (sethours . ,sethours) | |
| (regionlimit . ,regionlimit) | |
| (usesystem . ,usesystem) | |
| (setminQ . ,minq)))) | |
| ;; Utility functions | |
| ;; Filter unused (#f) parameters in the given alist | |
| (define (filter-false alist) | |
| (compress (map | |
| (lambda (item) | |
| (not (eq? (cdr item) #f))) alist) | |
| alist)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment