(SWT22-17)
# GitTalk
An incomplete, possibly hazardous implementation of the GitHub REST-API in SqueakSmalltalk.
Works with Squeak 5.3+.
[](https://github.com/hpi-swa-teaching/GitHub-API/actions/workflows/ci.yml)
[](https://coveralls.io/github/hpi-swa-teaching/GitHub-API)
# Installation
Download the newest release and install the ```.sar``` file within your Squeak environment! Alternatively, you can clone the repo using the default Git Browser.
## Adding necessary functionality to the WebClient
You may need to add the following method to the ````WebClient```` class included in the ````WebClient-Core```` package, for the client to run as expected:
````
httpPatch: urlString content: postData type: contentType do: aBlock
"PATCH the data to the given url"
| request |
self initializeFromUrl: urlString.
request := self requestWithUrl: urlString.
request method: 'PATCH'.
contentType ifNotNil:[request contentType: contentType].
request contentLength: postData size.
userAgent ifNotNil:[request headerAt: 'User-Agent' put: userAgent].
aBlock value: request.
^ self sendRequest: request content: postData readStream size: postData size
````
# Usage
Instanciate a new GitHubAPI-Object in your workspace by running
````
api := GitHubApi new.
````
Head on over to your [GitHub User Settings](https://github.com/settings/tokens/new) and generate a new access token (make sure to selected your correct scopes and write down your access token). \
Now run your first API request and get your current user profile (inspect the result, to see your data):
````
api user get
````
## Examples
````
api user repos create: (Dictionary newFrom: {'name' -> 'TestRepo'. 'private' -> true}).
repo := api user repos: 'TestRepo'.
repo get.
repo issues create: (Dictionary newFrom: {'title' -> 'New issue!'}).
issue := repo issues: 'New issue!'.
issue update: (Dictionary newFrom: {'state' -> 'closed'}).
````
All available endpoints and parameters can be explored in the offical [GitHub Rest API Documenatation](https://docs.github.com/en/rest).
(Please keep in mind, that not all endpoints are implemented so far!)