--wip-- [skip ci]
This commit is contained in:
parent
e8d26ab774
commit
7b336882d9
|
@ -13,7 +13,7 @@
|
||||||
"guzzlehttp/guzzle": "^6.3.1|^7.0",
|
"guzzlehttp/guzzle": "^6.3.1|^7.0",
|
||||||
"laravel/framework": "^9.0",
|
"laravel/framework": "^9.0",
|
||||||
"laravel/ui": "^3.4",
|
"laravel/ui": "^3.4",
|
||||||
"spatie/data-transfer-object": "^3.7"
|
"spatie/laravel-data": "^2.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "456a8c775e0524d9b5be373e4177cbff",
|
"content-hash": "346a5a2a97f685b2c63ce6fb3d29b2be",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
|
@ -1866,6 +1866,109 @@
|
||||||
},
|
},
|
||||||
"time": "2022-01-24T11:29:14+00:00"
|
"time": "2022-01-24T11:29:14+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpdocumentor/reflection-common",
|
||||||
|
"version": "2.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
|
||||||
|
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
||||||
|
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2 || ^8.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-2.x": "2.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"phpDocumentor\\Reflection\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jaap van Otterdijk",
|
||||||
|
"email": "opensource@ijaap.nl"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
|
||||||
|
"homepage": "http://www.phpdoc.org",
|
||||||
|
"keywords": [
|
||||||
|
"FQSEN",
|
||||||
|
"phpDocumentor",
|
||||||
|
"phpdoc",
|
||||||
|
"reflection",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
|
||||||
|
},
|
||||||
|
"time": "2020-06-27T09:03:43+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "phpdocumentor/type-resolver",
|
||||||
|
"version": "1.6.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpDocumentor/TypeResolver.git",
|
||||||
|
"reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706",
|
||||||
|
"reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2 || ^8.0",
|
||||||
|
"phpdocumentor/reflection-common": "^2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-tokenizer": "*",
|
||||||
|
"psalm/phar": "^4.8"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-1.x": "1.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"phpDocumentor\\Reflection\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Mike van Riel",
|
||||||
|
"email": "me@mikevanriel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0"
|
||||||
|
},
|
||||||
|
"time": "2022-01-04T19:58:01+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpoption/phpoption",
|
"name": "phpoption/phpoption",
|
||||||
"version": "1.8.1",
|
"version": "1.8.1",
|
||||||
|
@ -2523,32 +2626,51 @@
|
||||||
"time": "2021-09-25T23:10:38+00:00"
|
"time": "2021-09-25T23:10:38+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spatie/data-transfer-object",
|
"name": "spatie/laravel-data",
|
||||||
"version": "3.7.3",
|
"version": "2.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/spatie/data-transfer-object.git",
|
"url": "https://github.com/spatie/laravel-data.git",
|
||||||
"reference": "341f72c77e0fce40ea2e0dcb212cb54dc27bbe72"
|
"reference": "17d1ddfc5170e85f69bf92498e4b7fc09cf30792"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/spatie/data-transfer-object/zipball/341f72c77e0fce40ea2e0dcb212cb54dc27bbe72",
|
"url": "https://api.github.com/repos/spatie/laravel-data/zipball/17d1ddfc5170e85f69bf92498e4b7fc09cf30792",
|
||||||
"reference": "341f72c77e0fce40ea2e0dcb212cb54dc27bbe72",
|
"reference": "17d1ddfc5170e85f69bf92498e4b7fc09cf30792",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0"
|
"illuminate/contracts": "^8.71|^9.0",
|
||||||
|
"php": "^8.1",
|
||||||
|
"phpdocumentor/type-resolver": "^1.5",
|
||||||
|
"spatie/laravel-package-tools": "^1.9.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"illuminate/collections": "^8.36",
|
"fakerphp/faker": "^1.14",
|
||||||
"jetbrains/phpstorm-attributes": "^1.0",
|
"friendsofphp/php-cs-fixer": "^3.0",
|
||||||
"larapack/dd": "^1.1",
|
"inertiajs/inertia-laravel": "^0.6.3",
|
||||||
"phpunit/phpunit": "^9.0"
|
"nette/php-generator": "^3.5",
|
||||||
|
"nunomaduro/larastan": "^2.0|^1.0.3",
|
||||||
|
"orchestra/testbench": "^6.24|^7.5",
|
||||||
|
"phpstan/extension-installer": "^1.1",
|
||||||
|
"phpunit/phpunit": "^9.3",
|
||||||
|
"spatie/invade": "^1.0",
|
||||||
|
"spatie/laravel-typescript-transformer": "^2.0",
|
||||||
|
"spatie/phpunit-snapshot-assertions": "^4.2",
|
||||||
|
"spatie/test-time": "^1.2"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Spatie\\LaravelData\\LaravelDataServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Spatie\\DataTransferObject\\": "src"
|
"Spatie\\LaravelData\\": "src",
|
||||||
|
"Spatie\\LaravelData\\Database\\Factories\\": "database/factories"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
@ -2557,33 +2679,87 @@
|
||||||
],
|
],
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Brent Roose",
|
"name": "Ruben Van Assche",
|
||||||
"email": "brent@spatie.be",
|
"email": "ruben@spatie.be",
|
||||||
"homepage": "https://spatie.be",
|
|
||||||
"role": "Developer"
|
"role": "Developer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Data transfer objects with batteries included",
|
"description": "Create unified resources and data transfer objects",
|
||||||
"homepage": "https://github.com/spatie/data-transfer-object",
|
"homepage": "https://github.com/spatie/laravel-data",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"data-transfer-object",
|
"laravel",
|
||||||
|
"laravel-data",
|
||||||
"spatie"
|
"spatie"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/spatie/data-transfer-object/issues",
|
"source": "https://github.com/spatie/laravel-data/tree/2.0.2"
|
||||||
"source": "https://github.com/spatie/data-transfer-object/tree/3.7.3"
|
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
|
||||||
"url": "https://spatie.be/open-source/support-us",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"url": "https://github.com/spatie",
|
"url": "https://github.com/spatie",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-12-30T20:31:10+00:00"
|
"time": "2022-07-29T09:32:53+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spatie/laravel-package-tools",
|
||||||
|
"version": "1.12.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/spatie/laravel-package-tools.git",
|
||||||
|
"reference": "09f80fa240d44fafb1c70657c74ee44ffa929357"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/09f80fa240d44fafb1c70657c74ee44ffa929357",
|
||||||
|
"reference": "09f80fa240d44fafb1c70657c74ee44ffa929357",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/contracts": "^7.0|^8.0|^9.0",
|
||||||
|
"php": "^7.4|^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "^1.4",
|
||||||
|
"orchestra/testbench": "^5.0|^6.23|^7.0",
|
||||||
|
"phpunit/phpunit": "^9.4",
|
||||||
|
"spatie/test-time": "^1.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Spatie\\LaravelPackageTools\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Freek Van der Herten",
|
||||||
|
"email": "freek@spatie.be",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Tools for creating Laravel packages",
|
||||||
|
"homepage": "https://github.com/spatie/laravel-package-tools",
|
||||||
|
"keywords": [
|
||||||
|
"laravel-package-tools",
|
||||||
|
"spatie"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/spatie/laravel-package-tools/issues",
|
||||||
|
"source": "https://github.com/spatie/laravel-package-tools/tree/1.12.1"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/spatie",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-06-28T14:29:26+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/console",
|
"name": "symfony/console",
|
||||||
|
@ -6297,59 +6473,6 @@
|
||||||
},
|
},
|
||||||
"time": "2022-02-21T01:04:05+00:00"
|
"time": "2022-02-21T01:04:05+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "phpdocumentor/reflection-common",
|
|
||||||
"version": "2.2.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
|
|
||||||
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
|
||||||
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2 || ^8.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-2.x": "2.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"phpDocumentor\\Reflection\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Jaap van Otterdijk",
|
|
||||||
"email": "opensource@ijaap.nl"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
|
|
||||||
"homepage": "http://www.phpdoc.org",
|
|
||||||
"keywords": [
|
|
||||||
"FQSEN",
|
|
||||||
"phpDocumentor",
|
|
||||||
"phpdoc",
|
|
||||||
"reflection",
|
|
||||||
"static analysis"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
|
|
||||||
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
|
|
||||||
},
|
|
||||||
"time": "2020-06-27T09:03:43+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/reflection-docblock",
|
"name": "phpdocumentor/reflection-docblock",
|
||||||
"version": "5.3.0",
|
"version": "5.3.0",
|
||||||
|
@ -6407,56 +6530,6 @@
|
||||||
},
|
},
|
||||||
"time": "2021-10-19T17:43:47+00:00"
|
"time": "2021-10-19T17:43:47+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "phpdocumentor/type-resolver",
|
|
||||||
"version": "1.6.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/phpDocumentor/TypeResolver.git",
|
|
||||||
"reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706",
|
|
||||||
"reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2 || ^8.0",
|
|
||||||
"phpdocumentor/reflection-common": "^2.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"ext-tokenizer": "*",
|
|
||||||
"psalm/phar": "^4.8"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-1.x": "1.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"phpDocumentor\\Reflection\\": "src"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Mike van Riel",
|
|
||||||
"email": "me@mikevanriel.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
|
||||||
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0"
|
|
||||||
},
|
|
||||||
"time": "2022-01-04T19:58:01+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "phpspec/prophecy",
|
"name": "phpspec/prophecy",
|
||||||
"version": "v1.15.0",
|
"version": "v1.15.0",
|
||||||
|
|
|
@ -10,6 +10,7 @@ use Illuminate\Support\Str;
|
||||||
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
||||||
use Zoomyboy\LaravelNami\Data\Baustein;
|
use Zoomyboy\LaravelNami\Data\Baustein;
|
||||||
use Zoomyboy\LaravelNami\Data\Course;
|
use Zoomyboy\LaravelNami\Data\Course;
|
||||||
|
use Zoomyboy\LaravelNami\Data\Member;
|
||||||
use Zoomyboy\LaravelNami\Data\Membership;
|
use Zoomyboy\LaravelNami\Data\Membership;
|
||||||
use Zoomyboy\LaravelNami\Data\MembershipEntry;
|
use Zoomyboy\LaravelNami\Data\MembershipEntry;
|
||||||
use Zoomyboy\LaravelNami\Exceptions\NotAuthenticatedException;
|
use Zoomyboy\LaravelNami\Exceptions\NotAuthenticatedException;
|
||||||
|
@ -289,14 +290,12 @@ class Api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function member(int $groupId, int $memberId): array
|
public function member(int $groupId, int $memberId): Member
|
||||||
{
|
{
|
||||||
$this->assertLoggedIn();
|
$this->assertLoggedIn();
|
||||||
$url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
|
$url = $this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
|
||||||
$response = $this->http()->get($url);
|
$response = $this->http()->get($url);
|
||||||
|
|
||||||
Logger::http($url, $response, 'Show member '.$memberId, ['memberId' => $memberId]);
|
|
||||||
|
|
||||||
if (false === $response->json()['success'] && Str::startsWith($response['message'], 'Access denied')) {
|
if (false === $response->json()['success'] && Str::startsWith($response['message'], 'Access denied')) {
|
||||||
return $this->singleMemberFallback($groupId, $memberId);
|
return $this->singleMemberFallback($groupId, $memberId);
|
||||||
}
|
}
|
||||||
|
@ -309,7 +308,7 @@ class Api
|
||||||
$this->exception('Fetching member failed', $url, $response->json());
|
$this->exception('Fetching member failed', $url, $response->json());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response->json()['data'];
|
return Member::from($response->json()['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasGroup(int $groupId): bool
|
public function hasGroup(int $groupId): bool
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zoomyboy\LaravelNami\Data;
|
||||||
|
|
||||||
|
use Spatie\LaravelData\Attributes\MapInputName;
|
||||||
|
use Spatie\LaravelData\Data;
|
||||||
|
|
||||||
|
class Member extends Data
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
#[MapInputName('vorname')]
|
||||||
|
public string $firstname,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use App\Nami\HasNamiField;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Gender extends Model
|
||||||
|
{
|
||||||
|
use HasNamiField;
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
public $fillable = ['name', 'nami_id'];
|
||||||
|
|
||||||
|
public function getSalutationAttribute(): string
|
||||||
|
{
|
||||||
|
return match ($this->name) {
|
||||||
|
'Männlich' => 'Herr',
|
||||||
|
'Weiblich' => 'Frau',
|
||||||
|
default => ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
173
src/Member.php
173
src/Member.php
|
@ -1,173 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Zoomyboy\LaravelNami;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Zoomyboy\LaravelNami\Data\Membership;
|
|
||||||
use Zoomyboy\LaravelNami\Data\MembershipEntry;
|
|
||||||
use Zoomyboy\LaravelNami\Exceptions\RightException;
|
|
||||||
|
|
||||||
class Member extends Model
|
|
||||||
{
|
|
||||||
public $timestamps = false;
|
|
||||||
|
|
||||||
public $geschlechtMaps = [
|
|
||||||
'männlich' => 19,
|
|
||||||
'weiblich' => 20,
|
|
||||||
'keine Angabe' => 23,
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static $overviewAttributes = [
|
|
||||||
'vorname' => 'firstname',
|
|
||||||
'nachname' => 'lastname',
|
|
||||||
'spitzname' => 'nickname',
|
|
||||||
'staatsangehoerigkeitText' => 'other_country',
|
|
||||||
'staatangehoerigkeitText' => 'other_country',
|
|
||||||
'strasse' => 'address',
|
|
||||||
'nameZusatz' => 'further_address',
|
|
||||||
'plz' => 'zip',
|
|
||||||
'ort' => 'location',
|
|
||||||
'id' => 'id',
|
|
||||||
'telefon1' => 'main_phone',
|
|
||||||
'telefon2' => 'mobile_phone',
|
|
||||||
'telefon3' => 'work_phone',
|
|
||||||
'telefax' => 'fax',
|
|
||||||
'email' => 'email',
|
|
||||||
'geschlecht' => 'geschlecht_text',
|
|
||||||
'geschlechtId' => 'gender_id',
|
|
||||||
'emailVertretungsberechtigter' => 'email_parents',
|
|
||||||
'staatsangehoerigkeitId' => 'nationality_id',
|
|
||||||
'konfessionId' => 'confession_id',
|
|
||||||
'geburtsDatum' => 'birthday',
|
|
||||||
'eintrittsdatum' => 'joined_at',
|
|
||||||
'gruppierungId' => 'group_id',
|
|
||||||
'lastUpdated' => 'updated_at',
|
|
||||||
'mitgliedsNummer' => 'mitgliedsnr',
|
|
||||||
'zeitschriftenversand' => 'send_newspaper',
|
|
||||||
'regionId' => 'region_id',
|
|
||||||
'landId' => 'country_id',
|
|
||||||
'beitragsartId' => 'fee_id',
|
|
||||||
'version' => 'version',
|
|
||||||
'gruppierung' => 'group_name',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $casts = [];
|
|
||||||
|
|
||||||
protected $nullable = ['further_address', 'other_country', 'nickname', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents'];
|
|
||||||
|
|
||||||
protected $guarded = [];
|
|
||||||
|
|
||||||
public static function fromNami($item): self
|
|
||||||
{
|
|
||||||
$item = collect($item)
|
|
||||||
->only(array_keys(static::$overviewAttributes))
|
|
||||||
->mapWithKeys(function ($item, $key) {
|
|
||||||
return [data_get(static::$overviewAttributes, $key, $key) => $item];
|
|
||||||
})
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
return new self($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function fromAttributes(array $attributes): self
|
|
||||||
{
|
|
||||||
return new self($attributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toNami(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'vorname' => $this->firstname,
|
|
||||||
'nachname' => $this->lastname,
|
|
||||||
'spitzname' => $this->nickname ?: '',
|
|
||||||
'strasse' => $this->address,
|
|
||||||
'plz' => $this->zip,
|
|
||||||
'ort' => $this->location,
|
|
||||||
'eintrittsdatum' => $this->joined_at.'T00:00:00',
|
|
||||||
'version' => $this->version,
|
|
||||||
'beitragsartId' => $this->fee_id,
|
|
||||||
'regionId' => $this->region_id ?: Region::getNullValue(),
|
|
||||||
'landId' => $this->country_id,
|
|
||||||
'staatsangehoerigkeitId' => $this->nationality_id,
|
|
||||||
'geburtsDatum' => $this->birthday,
|
|
||||||
'geschlechtId' => $this->gender_id ?: Gender::getNullValue(),
|
|
||||||
'gruppierungId' => $this->group_id,
|
|
||||||
'id' => $this->id,
|
|
||||||
'zeitschriftenversand' => $this->send_newspaper,
|
|
||||||
'telefon1' => $this->main_phone ?: '',
|
|
||||||
'telefon2' => $this->mobile_phone ?: '',
|
|
||||||
'telefon3' => $this->work_phone ?: '',
|
|
||||||
'telefax' => $this->fax ?: '',
|
|
||||||
'email' => $this->email ?: '',
|
|
||||||
'emailVertretungsberechtigter' => $this->email_parents ?: '',
|
|
||||||
'geburtsDatum' => $this->birthday.' 00:00:00',
|
|
||||||
'nameZusatz' => $this->further_address ?: '',
|
|
||||||
'konfessionId' => $this->confession_id,
|
|
||||||
'staatsangehoerigkeitText' => $this->other_country ?: '',
|
|
||||||
'ersteTaetigkeitId' => $this->first_activity_id ?: null,
|
|
||||||
'ersteUntergliederungId' => $this->first_subactivity_id ?: null,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBirthdayAttribute(): ?string
|
|
||||||
{
|
|
||||||
return Carbon::parse($this->attributes['birthday'])->format('Y-m-d');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getJoinedAtAttribute(): ?string
|
|
||||||
{
|
|
||||||
$date = $this->attributes['joined_at'];
|
|
||||||
|
|
||||||
return empty($date)
|
|
||||||
? null
|
|
||||||
: Carbon::parse($date)->format('Y-m-d');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getGenderIdAttribute(): ?int
|
|
||||||
{
|
|
||||||
return $this->attributes['gender_id'] == Gender::getNullValue() ? null : $this->attributes['gender_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setGeschlechtTextAttribute($v)
|
|
||||||
{
|
|
||||||
$this->attributes['gender_id'] = data_get($this->geschlechtMaps, $v, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAttribute($key, $value)
|
|
||||||
{
|
|
||||||
if (in_array($key, $this->nullable) && '' === $value) {
|
|
||||||
return parent::setAttribute($key, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::setAttribute($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection<int, MembershipEntry>
|
|
||||||
*/
|
|
||||||
public function memberships(): Collection
|
|
||||||
{
|
|
||||||
return Nami::membershipsOf($this->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function putMembership(Membership $membership): int
|
|
||||||
{
|
|
||||||
return Nami::putMembership($this->id, $membership);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteMembership(int $id): void
|
|
||||||
{
|
|
||||||
Nami::deleteMembership($this->id, $this->membership($id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function membership(int $id): ?Membership
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return Nami::membership($this->id, $id);
|
|
||||||
} catch (RightException $e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Zoomyboy\LaravelNami\Tests;
|
namespace Zoomyboy\LaravelNami\Tests;
|
||||||
|
|
||||||
|
use Spatie\LaravelData\LaravelDataServiceProvider;
|
||||||
use Zoomyboy\LaravelNami\Api;
|
use Zoomyboy\LaravelNami\Api;
|
||||||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||||
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
||||||
|
@ -19,7 +20,7 @@ class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
|
|
||||||
protected function getPackageProviders($app)
|
protected function getPackageProviders($app)
|
||||||
{
|
{
|
||||||
return [NamiServiceProvider::class];
|
return [LaravelDataServiceProvider::class, NamiServiceProvider::class];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAnnotations(): array
|
public function getAnnotations(): array
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
namespace Zoomyboy\LaravelNami\Tests\Unit\Member;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
||||||
use Zoomyboy\LaravelNami\NamiException;
|
use Zoomyboy\LaravelNami\NamiException;
|
||||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||||
|
|
||||||
class PullMemberTest extends TestCase
|
class PullTest extends TestCase
|
||||||
{
|
{
|
||||||
public string $groupsResponse = '{"success":true,"data":[{"descriptor":"Group","name":"","representedClass":"de.iconcept.nami.entity.org.Gruppierung","id":103}],"responseType":"OK"}';
|
public string $groupsResponse = '{"success":true,"data":[{"descriptor":"Group","name":"","representedClass":"de.iconcept.nami.entity.org.Gruppierung","id":103}],"responseType":"OK"}';
|
||||||
public string $unauthorizedResponse = '{"success":false,"data":null,"responseType":"EXCEPTION","message":"Access denied - no right for requested operation","title":"Exception"}';
|
public string $unauthorizedResponse = '{"success":false,"data":null,"responseType":"EXCEPTION","message":"Access denied - no right for requested operation","title":"Exception"}';
|
||||||
|
@ -81,9 +81,6 @@ class PullMemberTest extends TestCase
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider dataProvider
|
|
||||||
*/
|
|
||||||
public function testGetASingleMember(array $input, array $check): void
|
public function testGetASingleMember(array $input, array $check): void
|
||||||
{
|
{
|
||||||
Http::fake([
|
Http::fake([
|
||||||
|
@ -91,13 +88,11 @@ class PullMemberTest extends TestCase
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response($this->fakeJson('member-16.json', ['data' => $input]), 200),
|
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response($this->fakeJson('member-16.json', ['data' => $input]), 200),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$group = $this->login()->group(103);
|
$member = $this->login()->member(103, 16);
|
||||||
|
|
||||||
foreach ($check as $key => $value) {
|
$this->assertEquals('Max', $member->firstname);
|
||||||
$this->assertSame($value, $group->member(16)->toArray()[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Http::assertSentCount(2);
|
Http::assertSentCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Zoomyboy\LaravelNami\Tests\Unit\Member;
|
namespace Zoomyboy\LaravelNami\Tests\Unit\Membership;
|
||||||
|
|
||||||
use Zoomyboy\LaravelNami\Fakes\MembershipFake;
|
use Zoomyboy\LaravelNami\Fakes\MembershipFake;
|
||||||
use Zoomyboy\LaravelNami\Member;
|
use Zoomyboy\LaravelNami\Member;
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Zoomyboy\LaravelNami\Tests\Unit\Member;
|
namespace Zoomyboy\LaravelNami\Tests\Unit\Membership;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
Loading…
Reference in New Issue