Skip to content

Commit 2a7f37c

Browse files
authored
Functional php client
1 parent 21a5953 commit 2a7f37c

File tree

77 files changed

+20113
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+20113
-0
lines changed

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run unit tests
2+
on: [push]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- name: Cache Composer dependencies
9+
uses: actions/cache@v2
10+
with:
11+
path: /tmp/composer-cache
12+
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
13+
- name: Install dependancies
14+
uses: php-actions/composer@v5
15+
with:
16+
php_version: 7.3
17+
- name: PHPUnit tests
18+
uses: php-actions/phpunit@v2
19+
env:
20+
API_KEY: ${{ secrets.API_KEY }}
21+
BASE_URI: https://api.dismoi.io/v4
22+
with:
23+
args: tests

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
2+
3+
/vendor/
4+
composer.phar
5+
6+
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
7+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
8+
# composer.lock
9+
10+
.openapi-generator
11+
.openapi-generator-ignore
12+
13+
# php-cs-fixer cache
14+
.php_cs.cache
15+
16+
# PHPUnit cache
17+
.phpunit.result.cache

.php_cs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->in(__DIR__)
7+
->path('src/')
8+
->path('test/')
9+
;
10+
11+
return PhpCsFixer\Config::create()
12+
->setRiskyAllowed(true)
13+
->setRules([
14+
'@DoctrineAnnotation' => true,
15+
'@PHP71Migration' => true,
16+
'@PHP71Migration:risky' => true,
17+
'@PHPUnit60Migration:risky' => true,
18+
'@Symfony' => true,
19+
'@Symfony:risky' => true,
20+
'single_line_comment_style' => true,
21+
'comment_to_phpdoc' => true,
22+
'align_multiline_comment' => [
23+
'comment_type' => 'phpdocs_like',
24+
],
25+
'array_indentation' => true,
26+
'array_syntax' => [
27+
'syntax' => 'short',
28+
],
29+
'compact_nullable_typehint' => true,
30+
'doctrine_annotation_array_assignment' => [
31+
'operator' => '=',
32+
],
33+
'doctrine_annotation_spaces' => [
34+
'after_array_assignments_equals' => false,
35+
'before_array_assignments_equals' => false,
36+
],
37+
'explicit_indirect_variable' => true,
38+
'fully_qualified_strict_types' => true,
39+
'logical_operators' => true,
40+
'multiline_comment_opening_closing' => true,
41+
'multiline_whitespace_before_semicolons' => [
42+
'strategy' => 'no_multi_line',
43+
],
44+
'no_alternative_syntax' => true,
45+
'no_extra_blank_lines' => [
46+
'tokens' => [
47+
'break',
48+
'continue',
49+
'curly_brace_block',
50+
'extra',
51+
'parenthesis_brace_block',
52+
'return',
53+
'square_brace_block',
54+
'throw',
55+
'use',
56+
],
57+
],
58+
'no_superfluous_elseif' => true,
59+
'no_superfluous_phpdoc_tags' => [
60+
'allow_mixed' => true,
61+
],
62+
'no_unset_cast' => true,
63+
'no_unset_on_property' => true,
64+
'no_useless_else' => true,
65+
'no_useless_return' => true,
66+
'not_operator_with_space' => true,
67+
'ordered_imports' => [
68+
'imports_order' => [
69+
'class',
70+
'function',
71+
'const',
72+
],
73+
'sort_algorithm' => 'alpha',
74+
],
75+
'php_unit_method_casing' => [
76+
'case' => 'camel_case',
77+
],
78+
'php_unit_set_up_tear_down_visibility' => true,
79+
'php_unit_test_annotation' => [
80+
'style' => 'prefix',
81+
],
82+
'phpdoc_add_missing_param_annotation' => [
83+
'only_untyped' => true,
84+
],
85+
'phpdoc_no_alias_tag' => false, // Set the rule to true when https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/5357 is fixed
86+
'phpdoc_order' => true,
87+
'phpdoc_trim_consecutive_blank_line_separation' => true,
88+
'phpdoc_var_annotation_correct_order' => true,
89+
'return_assignment' => true,
90+
'strict_param' => true,
91+
'visibility_required' => [
92+
'elements' => [
93+
'const',
94+
'method',
95+
'property',
96+
],
97+
],
98+
'void_return' => true,
99+
])
100+
->setFinder($finder)
101+
;

README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# dismoi/api-client
2+
3+
OpenAPI documentation and _sandbox_ for **DisMoi** (_Tell Me_ in french),
4+
a FLOSS web annotations project to turn the tide of the opinion wars back in favor of the internauts.
5+
6+
- [Official Website](https://www.dismoi.io/)
7+
- [Source Code](https://github.com/dis-moi)
8+
- [Report Issues](https://github.com/dis-moi/backend/issues) (_please!_)
9+
10+
11+
12+
## Installation & Usage
13+
14+
### Requirements
15+
16+
PHP 7.3 and later.
17+
Should also work with PHP 8.0 but has not been tested.
18+
19+
### Composer
20+
21+
To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`:
22+
23+
```json
24+
{
25+
"repositories": [
26+
{
27+
"type": "vcs",
28+
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
29+
}
30+
],
31+
"require": {
32+
"GIT_USER_ID/GIT_REPO_ID": "*@dev"
33+
}
34+
}
35+
```
36+
37+
Then run `composer install`
38+
39+
### Manual Installation
40+
41+
Download the files and include `autoload.php`:
42+
43+
```php
44+
<?php
45+
require_once('/path/to/dismoi/api-client/vendor/autoload.php');
46+
```
47+
48+
## Getting Started
49+
50+
Please follow the [installation procedure](#installation--usage) and then run the following:
51+
52+
```php
53+
<?php
54+
require_once(__DIR__ . '/vendor/autoload.php');
55+
56+
57+
58+
// Configure API key authorization: apiKey
59+
$config = DisMoi\Client\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY');
60+
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
61+
// $config = DisMoi\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Bearer');
62+
63+
64+
$apiInstance = new DisMoi\Client\Api\AuthenticationApi(
65+
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
66+
// This is optional, `GuzzleHttp\Client` will be used as default.
67+
new GuzzleHttp\Client(),
68+
$config
69+
);
70+
$credentials = new \DisMoi\Client\Model\Credentials(); // \DisMoi\Client\Model\Credentials | Generate a new Json Web Token (JWT)
71+
72+
try {
73+
$result = $apiInstance->postCredentialsItem($credentials);
74+
print_r($result);
75+
} catch (Exception $e) {
76+
echo 'Exception when calling AuthenticationApi->postCredentialsItem: ', $e->getMessage(), PHP_EOL;
77+
}
78+
79+
```
80+
81+
## API Endpoints
82+
83+
All URIs are relative to *http://localhost*
84+
85+
Class | Method | HTTP request | Description
86+
------------ | ------------- | ------------- | -------------
87+
*AuthenticationApi* | [**postCredentialsItem**](docs/Api/AuthenticationApi.md#postcredentialsitem) | **POST** /api/v4/_jwt | Returns an authentication token (JWT) from login credentials.
88+
*ContributorApi* | [**getContributorItem**](docs/Api/ContributorApi.md#getcontributoritem) | **GET** /v4/contributors/{id} | Retrieves a Contributor resource.
89+
*MatchingContextApi* | [**apiNoticesMatchingContextsGetSubresourceNoticeSubresource**](docs/Api/MatchingContextApi.md#apinoticesmatchingcontextsgetsubresourcenoticesubresource) | **GET** /v4/notices/{id}/matching_contexts | Retrieves a Notice resource.
90+
*MatchingContextApi* | [**getMatchingContextCollection**](docs/Api/MatchingContextApi.md#getmatchingcontextcollection) | **GET** /v4/matching_contexts | Retrieves the collection of MatchingContext resources.
91+
*MatchingContextApi* | [**getMatchingContextItem**](docs/Api/MatchingContextApi.md#getmatchingcontextitem) | **GET** /v4/matching_contexts/{id} | Retrieves a MatchingContext resource.
92+
*MatchingContextApi* | [**postMatchingContextCollection**](docs/Api/MatchingContextApi.md#postmatchingcontextcollection) | **POST** /v4/matching_contexts | Creates a MatchingContext resource.
93+
*NoticeApi* | [**apiNoticesMatchingContextsGetSubresourceNoticeSubresource**](docs/Api/NoticeApi.md#apinoticesmatchingcontextsgetsubresourcenoticesubresource) | **GET** /v4/notices/{id}/matching_contexts | Retrieves a Notice resource.
94+
*NoticeApi* | [**deleteNoticeItem**](docs/Api/NoticeApi.md#deletenoticeitem) | **DELETE** /v4/notices/{id} | Removes the Notice resource.
95+
*NoticeApi* | [**getNoticeCollection**](docs/Api/NoticeApi.md#getnoticecollection) | **GET** /v4/notices | Retrieves the collection of Notice resources.
96+
*NoticeApi* | [**getNoticeItem**](docs/Api/NoticeApi.md#getnoticeitem) | **GET** /v4/notices/{id} | Retrieves a Notice resource.
97+
*NoticeApi* | [**postNoticeCollection**](docs/Api/NoticeApi.md#postnoticecollection) | **POST** /v4/notices | Creates a Notice resource.
98+
99+
## Models
100+
101+
- [ContributorJsonldRead](docs/Model/ContributorJsonldRead.md)
102+
- [Credentials](docs/Model/Credentials.md)
103+
- [InlineResponse200](docs/Model/InlineResponse200.md)
104+
- [InlineResponse2001](docs/Model/InlineResponse2001.md)
105+
- [InlineResponse200HydraSearch](docs/Model/InlineResponse200HydraSearch.md)
106+
- [InlineResponse200HydraSearchHydraMapping](docs/Model/InlineResponse200HydraSearchHydraMapping.md)
107+
- [InlineResponse200HydraView](docs/Model/InlineResponse200HydraView.md)
108+
- [MatchingContextCreate](docs/Model/MatchingContextCreate.md)
109+
- [MatchingContextJsonldCreate](docs/Model/MatchingContextJsonldCreate.md)
110+
- [MatchingContextJsonldRead](docs/Model/MatchingContextJsonldRead.md)
111+
- [MatchingContextRead](docs/Model/MatchingContextRead.md)
112+
- [NoticeCreate](docs/Model/NoticeCreate.md)
113+
- [NoticeJsonldCreate](docs/Model/NoticeJsonldCreate.md)
114+
- [NoticeJsonldRead](docs/Model/NoticeJsonldRead.md)
115+
- [NoticeRead](docs/Model/NoticeRead.md)
116+
- [Token](docs/Model/Token.md)
117+
118+
## Authorization
119+
120+
### apiKey
121+
122+
- **Type**: API key
123+
- **API key parameter name**: Authorization
124+
- **Location**: HTTP header
125+
126+
127+
## Tests
128+
129+
To run the tests, use:
130+
131+
```bash
132+
composer install
133+
vendor/bin/phpunit
134+
```
135+
136+
## Author
137+
138+
139+
140+
## About this package
141+
142+
This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
143+
144+
- API version: `4.0.0`
145+
- Package version: `0.0.1`
146+
- Build package: `io.dismoi.codegen.PhpClientCodegen`

composer.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "dismoi/api-client",
3+
"version": "0.0.1",
4+
"description": "OpenAPI documentation and _sandbox_ for **DisMoi** (_Tell Me_ in french), a FLOSS web annotations project to turn the tide of the opinion wars back in favor of the internauts. - [Official Website](https://www.dismoi.io/) - [Source Code](https://github.com/dis-moi) - [Report Issues](https://github.com/dis-moi/backend/issues) (_please!_)",
5+
"keywords": [
6+
"openapitools",
7+
"openapi-generator",
8+
"openapi",
9+
"php",
10+
"sdk",
11+
"rest",
12+
"api"
13+
],
14+
"homepage": "https://dismoi.io",
15+
"license": "AGPL-3.0-or-later",
16+
"type": "library",
17+
"authors": [
18+
{
19+
"name": "DisMoi",
20+
"homepage": "https://dismoi.io"
21+
}
22+
],
23+
"require": {
24+
"php": "^7.3 || ^8.0",
25+
"ext-curl": "*",
26+
"ext-json": "*",
27+
"ext-mbstring": "*",
28+
"guzzlehttp/guzzle": "^6.2"
29+
},
30+
"require-dev": {
31+
"phpunit/phpunit": "^8.0 || ^9.0",
32+
"friendsofphp/php-cs-fixer": "^2.12"
33+
},
34+
"autoload": {
35+
"psr-4": { "DisMoi\\Client\\" : "src/" }
36+
},
37+
"autoload-dev": {
38+
"psr-4": { "DisMoi\\Client\\Test\\" : "test/" }
39+
},
40+
"scripts": {
41+
"fix-cs": [
42+
"php-cs-fixer fix"
43+
],
44+
"check-cs": [
45+
"php-cs-fixer fix --dry-run --stop-on-violation"
46+
],
47+
"test": [
48+
"phpunit test/"
49+
]
50+
}
51+
}

0 commit comments

Comments
 (0)