Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #5 from bennn/personal-token
Browse files Browse the repository at this point in the history
add contract for identity type
  • Loading branch information
eu90h committed Sep 11, 2018
2 parents fd542d7 + 6a7a5a1 commit 2079df4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions scribblings/github-api.scrbl
Expand Up @@ -18,12 +18,12 @@ Before you begin making requests to the GitHub api, you must create an identity.
@defstruct[github-identity ([type symbol?] [data list?])]{
This struct holds your GitHub identity.

@racket[type] must be one of the following symbols: @racket['password 'personal-access-token 'oauth]
@racket[type] must be one of the following symbols: @racket['password 'personal-token 'oauth]

@racket['password] authentication
simply uses your GitHub username and password.

@racket['personal-access-token] authentication allows you
@racket['personal-token] authentication allows you
to send your GitHub username and a personal access token (created on your GitHub settings page.)

@racket['oauth] uses an OAuth token for authorization.
Expand Down Expand Up @@ -580,4 +580,4 @@ name of the webhook.
(define delete-response (del-hook))
(if (= 204 (github-response-code delete-response))
(displayln "successfully removed webhook")
(displayln "trouble removing webhook"))]
(displayln "trouble removing webhook"))]
9 changes: 6 additions & 3 deletions utils.rkt
Expand Up @@ -4,10 +4,10 @@
github-api-req/c
github-api-resp/c
(contract-out
[struct github-identity ([type symbol?] [data (listof string?)])]
[struct github-identity ([type github-identity-type/c] [data (listof string?)])]
[struct github-response ([code number?] [data jsexpr?])]
[get-status-code (-> string? number?)]
[make-auth-header (-> symbol? (listof string?) string?)]
[make-auth-header (-> github-identity-type/c (listof string?) string?)]
[port->jsexpr (-> input-port? jsexpr?)]
[->string (-> any/c string?)]))

Expand All @@ -18,6 +18,9 @@
(define github-api-resp/c github-response?)
(define github-api-req/c (->* (string?) [#:method string? #:data string? #:media-type string?] github-api-resp/c))

(define github-identity-type/c
(or/c 'password 'personal-token 'oauth2))

(module+ test (require rackunit))

(define (base64-encode-string s)
Expand Down Expand Up @@ -100,4 +103,4 @@
(module+ test
(check-true (jsexpr? (port->jsexpr (open-input-string ""))))
(check-true (jsexpr? (port->jsexpr
(open-input-string "{\"test\": 3}")))))
(open-input-string "{\"test\": 3}")))))

0 comments on commit 2079df4

Please sign in to comment.