Skip to content
This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Commit 56d2b6b

Browse files
committed
Version 3
0 parents  commit 56d2b6b

27 files changed

+6783
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [jamesrweb]

.github/workflows/CI.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI workflow
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.head_ref }}
16+
17+
- name: Update composer.lock
18+
run: composer update --no-install --no-autoloader --no-progress
19+
20+
- name: Validate composer.json and composer.lock
21+
run: composer validate
22+
23+
- name: Cache Composer packages
24+
id: composer-cache
25+
uses: actions/cache@v2
26+
with:
27+
path: vendor
28+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-php-
31+
32+
- name: Install dependencies
33+
if: steps.composer-cache.outputs.cache-hit != 'true'
34+
run: composer install --prefer-dist --no-progress --optimize-autoloader
35+
36+
- name: Commit composer.lock updates
37+
uses: stefanzweifel/git-auto-commit-action@v4.1.2
38+
with:
39+
commit_message: Apply composer.lock updates
40+
branch: ${{ github.head_ref }}
41+
42+
- name: Lint files
43+
run: composer run-script lint
44+
45+
- name: Run test suite
46+
run: composer run-script test
47+
48+
- name: Format files
49+
run: composer run-script format
50+
51+
- name: Commit formatting changes
52+
uses: stefanzweifel/git-auto-commit-action@v4.1.2
53+
with:
54+
commit_message: Apply formatting changes
55+
branch: ${{ github.head_ref }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea/
2+
vendor/
3+
coverage/
4+
.env
5+
*.cache
6+
*.bak
7+
index.php

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 James Robb
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Codewars API Client
2+
3+
[![Test coverage](https://img.shields.io/badge/test%20coverage-100%25-brightgreen.svg)](https://github.com/jamesrweb/codewars-api-client)
4+
[![GitHub license](https://img.shields.io/github/license/jamesrweb/codewars-api-client.svg)](https://github.com/jamesrweb/codewars-api-client/blob/master/LICENSE)
5+
[![GitHub contributors](https://img.shields.io/github/contributors/jamesrweb/codewars-api-client.svg)](https://GitHub.com/jamesrweb/codewars-api-client/graphs/contributors/)
6+
[![GitHub issues](https://img.shields.io/github/issues/jamesrweb/codewars-api-client.svg)](https://GitHub.com/jamesrweb/codewars-api-client/issues/)
7+
[![GitHub pull requests](https://img.shields.io/github/issues-pr/jamesrweb/codewars-api-client.svg)](https://GitHub.com/jamesrweb/codewars-api-client/pulls/)
8+
9+
A library built to interact with the Codewars API and platform.
10+
11+
## Installation
12+
13+
Use the package manager [composer](https://getcomposer.org/) to install the library using the following command.
14+
15+
```bash
16+
composer require jamesrweb/codewars-api-client
17+
```
18+
19+
## Basic Usage
20+
21+
Once the package has been installed, we can create the required clients like.
22+
23+
```php
24+
<?php
25+
26+
declare(strict_types=1);
27+
28+
require __DIR__ . '/vendor/autoload.php';
29+
30+
use CodewarsApiClient\Client;
31+
32+
$client = new Client("your-api-key");
33+
```
34+
35+
## The `Client`
36+
37+
A `Client` instance allows us to interact with the codewars API in a consistent manner.
38+
39+
### Methods
40+
41+
#### Get information about the user
42+
43+
To get information regarding the user, you can run:
44+
45+
```php
46+
$client->user(string $username);
47+
```
48+
49+
#### Get challenges created by the user
50+
51+
To get a list of challenges the user created, you can run:
52+
```php
53+
$client->authored(string $username);
54+
```
55+
56+
#### Get challenges completed by the user
57+
58+
To get a list of challenges the user completed, you can run:
59+
60+
```php
61+
$client->completed(string $username);
62+
```
63+
64+
#### Get information about a specific challenge
65+
66+
To get an overview regarding a specific challenge, you can run:
67+
68+
```php
69+
$client->challenge(string $id);
70+
```
71+
72+
#### Get information about multiple challenges
73+
74+
To get an overview of multiple challenges at once, you can run:
75+
76+
```php
77+
$client->challenges(array<string> $ids);
78+
```
79+
80+
## Interfaces
81+
82+
There are a number of interfaces exposed for you to use if required. These are namespaced under the `CodewarsApiClient\Interfaces` namespace.
83+
84+
### The `ChallengeInterface`
85+
86+
This interface is for the methods that access challenge specific data.
87+
88+
### The `UserInterface`
89+
90+
This interface is for the methods that access user specific data.
91+
92+
### The `ClientInterface`
93+
94+
This interface is for the methods that are accessible to use via a `Client` instance and is contains all methods defined in the `ChallengeInterface` and `UserInterface` interfaces.
95+
96+
## Contributing
97+
98+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
99+
100+
Please make sure to update tests as appropriate.
101+
102+
## License
103+
104+
This project uses [an MIT license](https://choosealicense.com/licenses/mit/). If you wish to view [the license](https://github.com/jamesrweb/codewars-api-client/blob/master/LICENSE), it can be found in the project root.

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-cayman

composer.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "jamesrweb/codewars-api-client",
3+
"description": "A client for the Codewars API",
4+
"type": "library",
5+
"license": "MIT",
6+
"keywords": [
7+
"codewars",
8+
"api-client"
9+
],
10+
"readme": "README.md",
11+
"homepage": "https://jamesrweb.github.io/codewars-api-client",
12+
"repositories": [
13+
{
14+
"type": "composer",
15+
"url": "https://repo.packagist.org"
16+
},
17+
{
18+
"type": "vcs",
19+
"url": "https://github.com/jamesrweb/codewars-api-client"
20+
}
21+
],
22+
"authors": [
23+
{
24+
"name": "James Robb",
25+
"email": "james@jamesrobb.co.uk"
26+
}
27+
],
28+
"scripts": {
29+
"lint": "phpstan analyse -c ./config/phpstan/phpstan.neon",
30+
"format": "php-cs-fixer fix --config ./config/php-cs-fixer/.php_cs --using-cache no",
31+
"start": "php -t public -S localhost:8080",
32+
"test": "phpunit tests --testdox --configuration ./config/phpunit/phpunit.xml",
33+
"test:watch": "phpunit-watcher watch tests --testdox --configuration phpunit.xml"
34+
},
35+
"minimum-stability": "stable",
36+
"require": {
37+
"php": ">=8.0",
38+
"symfony/http-client": "^5.2",
39+
"psr/http-client": "^1.0",
40+
"psr/http-message": "^1.0",
41+
"nyholm/psr7": "^1.4",
42+
"thecodingmachine/safe": "^1.3"
43+
},
44+
"require-dev": {
45+
"phpunit/phpunit": "^9",
46+
"spatie/phpunit-watcher": "^1.23",
47+
"friendsofphp/php-cs-fixer": "^2.18",
48+
"madewithlove/php-cs-fixer-config": "^2.0",
49+
"phpstan/phpstan": "^0.12.76",
50+
"phpstan/extension-installer": "^1.1",
51+
"phpstan/phpstan-strict-rules": "^0.12.9",
52+
"nette/schema": "^1.2"
53+
},
54+
"autoload": {
55+
"psr-4": {
56+
"CodewarsApiClient\\": "src/"
57+
}
58+
},
59+
"autoload-dev": {
60+
"files": ["tests/Helpers/Regex.php"],
61+
"psr-4": {
62+
"Tests\\": "tests/"
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)