Skip to content
/ webapi Public
forked from fukamachi/webapi

CLOS-based wrapper builder for Web APIs.

License

Notifications You must be signed in to change notification settings

pokepay/webapi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebAPI

CLOS-based wrapper builder for Web APIs.

Usage

(ql:quickload '(:webapi :jonathan))

;; Define GitHub API request class.
(defclass github-request () ()
  (:default-initargs :base-uri "https://api.github.com"))
  
(defmethod webapi:parse ((request github-request) response)
  (jojo:parse (webapi:response-body response) :as :alist))

;; Request class for /users/:name/repos.
(defclass user-repositories (github-request)
  ((user :initarg :user))
  (:metaclass webapi:request-class)
  (:http :get))
  
(defmethod webapi:request-path ((request user-repositories))
  (format nil "/users/~A/repos" (slot-value request 'user)))

;; Request class for /search/repositories.
(defclass search-repositories (github-request)
  ((q :initarg :q))
  (:metaclass webapi:request-class)
  (:http :get "/search/repositories"))
  
(defmethod webapi:query-parameters ((request search-repositories))
  `(("q" . ,(slot-value request 'q))))
  
;;
;; Send a request

;; Get repositories of "fukamachi".
(webapi:send (make-instance 'user-repositories :user "fukamachi"))

;; Search repositories with related to "Common Lisp".
(webapi:send (make-instance 'search-repositories :q "Common Lisp"))

Author

Copyright

Copyright (c) 2017 Eitaro Fukamachi ([email protected])

License

Licensed under the BSD 2-Clause License.

About

CLOS-based wrapper builder for Web APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Common Lisp 100.0%