Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional php client #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run unit tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Install dependancies
uses: php-actions/composer@v5
with:
php_version: 7.3
- name: PHPUnit tests
uses: php-actions/phpunit@v2
env:
API_KEY: ${{ secrets.API_KEY }}
BASE_URI: https://api.dismoi.io/v4
with:
args: tests
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

/vendor/
composer.phar

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock

.openapi-generator
.openapi-generator-ignore

# php-cs-fixer cache
.php_cs.cache

# PHPUnit cache
.phpunit.result.cache
101 changes: 101 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->path('src/')
->path('test/')
;

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'single_line_comment_style' => true,
'comment_to_phpdoc' => true,
'align_multiline_comment' => [
'comment_type' => 'phpdocs_like',
],
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short',
],
'compact_nullable_typehint' => true,
'doctrine_annotation_array_assignment' => [
'operator' => '=',
],
'doctrine_annotation_spaces' => [
'after_array_assignments_equals' => false,
'before_array_assignments_equals' => false,
],
'explicit_indirect_variable' => true,
'fully_qualified_strict_types' => true,
'logical_operators' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'no_alternative_syntax' => true,
'no_extra_blank_lines' => [
'tokens' => [
'break',
'continue',
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'throw',
'use',
],
],
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => true,
],
'no_unset_cast' => true,
'no_unset_on_property' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'not_operator_with_space' => true,
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
'sort_algorithm' => 'alpha',
],
'php_unit_method_casing' => [
'case' => 'camel_case',
],
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_test_annotation' => [
'style' => 'prefix',
],
'phpdoc_add_missing_param_annotation' => [
'only_untyped' => true,
],
'phpdoc_no_alias_tag' => false, // Set the rule to true when https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/5357 is fixed
'phpdoc_order' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_var_annotation_correct_order' => true,
'return_assignment' => true,
'strict_param' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],
'void_return' => true,
])
->setFinder($finder)
;
144 changes: 144 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# dismoi/api-client

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!_)



## Installation & Usage

### Requirements

PHP 7.3 and later.
Should also work with PHP 8.0 but has not been tested.

### Composer

To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`:

```json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
}
],
"require": {
"GIT_USER_ID/GIT_REPO_ID": "*@dev"
}
}
```

Then run `composer install`

### Manual Installation

Download the files and include `autoload.php`:

```php
<?php
require_once('/path/to/dismoi/api-client/vendor/autoload.php');
```

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');



// Configure API key authorization: apiKey
$config = DisMoi\Client\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY');


$apiInstance = new DisMoi\Client\Api\AuthenticationApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$credentials = new \DisMoi\Client\Model\Credentials(); // \DisMoi\Client\Model\Credentials | Generate a new Json Web Token (JWT)

try {
$result = $apiInstance->postCredentialsItem($credentials);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AuthenticationApi->postCredentialsItem: ', $e->getMessage(), PHP_EOL;
}

```

## API Endpoints

All URIs are relative to *http://localhost:8088*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AuthenticationApi* | [**postCredentialsItem**](docs/Api/AuthenticationApi.md#postcredentialsitem) | **POST** /v4/_jwt | Returns an authentication token (JWT) from login credentials.
*ContributorApi* | [**getContributorItem**](docs/Api/ContributorApi.md#getcontributoritem) | **GET** /v4/contributors/{id} | Retrieves a Contributor resource.
*MatchingContextApi* | [**apiNoticesMatchingContextsGetSubresourceNoticeSubresource**](docs/Api/MatchingContextApi.md#apinoticesmatchingcontextsgetsubresourcenoticesubresource) | **GET** /v4/notices/{id}/matching_contexts | Retrieves a Notice resource.
*MatchingContextApi* | [**getMatchingContextCollection**](docs/Api/MatchingContextApi.md#getmatchingcontextcollection) | **GET** /v4/matching_contexts | Retrieves the collection of MatchingContext resources.
*MatchingContextApi* | [**getMatchingContextItem**](docs/Api/MatchingContextApi.md#getmatchingcontextitem) | **GET** /v4/matching_contexts/{id} | Retrieves a MatchingContext resource.
*MatchingContextApi* | [**postMatchingContextCollection**](docs/Api/MatchingContextApi.md#postmatchingcontextcollection) | **POST** /v4/matching_contexts | Creates a MatchingContext resource.
*NoticeApi* | [**apiNoticesMatchingContextsGetSubresourceNoticeSubresource**](docs/Api/NoticeApi.md#apinoticesmatchingcontextsgetsubresourcenoticesubresource) | **GET** /v4/notices/{id}/matching_contexts | Retrieves a Notice resource.
*NoticeApi* | [**deleteNoticeItem**](docs/Api/NoticeApi.md#deletenoticeitem) | **DELETE** /v4/notices/{id} | Removes the Notice resource.
*NoticeApi* | [**getNoticeCollection**](docs/Api/NoticeApi.md#getnoticecollection) | **GET** /v4/notices | Retrieves the collection of Notice resources.
*NoticeApi* | [**getNoticeItem**](docs/Api/NoticeApi.md#getnoticeitem) | **GET** /v4/notices/{id} | Retrieves a Notice resource.
*NoticeApi* | [**postNoticeCollection**](docs/Api/NoticeApi.md#postnoticecollection) | **POST** /v4/notices | Creates a Notice resource.

## Models

- [ContributorJsonldRead](docs/Model/ContributorJsonldRead.md)
- [Credentials](docs/Model/Credentials.md)
- [InlineResponse200](docs/Model/InlineResponse200.md)
- [InlineResponse2001](docs/Model/InlineResponse2001.md)
- [InlineResponse200HydraSearch](docs/Model/InlineResponse200HydraSearch.md)
- [InlineResponse200HydraSearchHydraMapping](docs/Model/InlineResponse200HydraSearchHydraMapping.md)
- [InlineResponse200HydraView](docs/Model/InlineResponse200HydraView.md)
- [MatchingContextCreate](docs/Model/MatchingContextCreate.md)
- [MatchingContextJsonldCreate](docs/Model/MatchingContextJsonldCreate.md)
- [MatchingContextJsonldRead](docs/Model/MatchingContextJsonldRead.md)
- [MatchingContextRead](docs/Model/MatchingContextRead.md)
- [NoticeCreate](docs/Model/NoticeCreate.md)
- [NoticeJsonldCreate](docs/Model/NoticeJsonldCreate.md)
- [NoticeJsonldRead](docs/Model/NoticeJsonldRead.md)
- [NoticeRead](docs/Model/NoticeRead.md)
- [Token](docs/Model/Token.md)

## Authorization

### apiKey

- **Type**: API key
- **API key parameter name**: Authorization
- **Location**: HTTP header


## Tests

To run the tests, use:

```bash
composer install
vendor/bin/phpunit
```

## Author



## About this package

This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: `4.0.0`
- Package version: `0.0.1`
- Build package: `io.dismoi.codegen.PhpClientCodegen`
54 changes: 54 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "dismoi/api-client",
"version": "0.0.1",
"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!_)",
"keywords": [
"openapitools",
"openapi-generator",
"openapi",
"php",
"sdk",
"rest",
"api"
],
"homepage": "https://dismoi.io",
"license": "AGPL-3.0-or-later",
"type": "library",
"authors": [
{
"name": "DisMoi",
"homepage": "https://dismoi.io"
}
],
"require": {
"php": "^7.3 || ^8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0",
"friendsofphp/php-cs-fixer": "^2.12"
},
"autoload": {
"psr-4": { "DisMoi\\Client\\" : "src/" }
},
"autoload-dev": {
"psr-4": { "DisMoi\\Client\\Test\\" : "test/" }
},
"scripts": {
"fix-cs": [
"php-cs-fixer fix"
],
"check-cs": [
"php-cs-fixer fix --dry-run --stop-on-violation"
],
"test": [
"phpunit test/ --exclude-group dev"
],
"test-dev": [
"phpunit test/ --group dev"
]
}
}
Loading