Add: Pull Confession from member
This commit is contained in:
parent
ca09bd7560
commit
5a4fa4d5ec
15
src/Api.php
15
src/Api.php
|
@ -106,6 +106,12 @@ class Api {
|
|||
});
|
||||
}
|
||||
|
||||
public function confessions(): Collection {
|
||||
return collect($this->http()->get(self::$url."/ica/rest/baseadmin/konfession")['data'])->map(function($gender) {
|
||||
return Confession::fromNami($gender);
|
||||
});
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
public function fees() {
|
||||
|
@ -116,15 +122,6 @@ class Api {
|
|||
return json_decode((string)$response->getBody());
|
||||
}
|
||||
|
||||
public function confessions() {
|
||||
$response = $this->client->get("/ica/rest/baseadmin/konfession", [
|
||||
'cookies' => $this->cookie
|
||||
]);
|
||||
|
||||
return json_decode((string)$response->getBody());
|
||||
}
|
||||
|
||||
|
||||
public function regions() {
|
||||
$response = $this->client->get("/ica/rest/baseadmin/region", [
|
||||
'cookies' => $this->cookie
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Confession extends Model {
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public static function fromNami($item) {
|
||||
$item = collect($item)
|
||||
->only(['descriptor', 'id'])
|
||||
->mapWithKeys(function($item,$key) {
|
||||
if ($key == 'id') { return ['id' => $item]; }
|
||||
return ['name' => $item];
|
||||
})->toArray();
|
||||
|
||||
return (new self($item));
|
||||
}
|
||||
|
||||
}
|
|
@ -31,7 +31,8 @@ class Member extends Model {
|
|||
'email' => 'email',
|
||||
'geschlechtId' => 'gender_id',
|
||||
'emailVertretungsberechtigter' => 'email_parents',
|
||||
'staatsangehoerigkeitId' => 'nationality_id'
|
||||
'staatsangehoerigkeitId' => 'nationality_id',
|
||||
'konfessionId' => 'confession_id'
|
||||
];
|
||||
|
||||
protected $guarded = [];
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
|
||||
class PullConfessionTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_get_all_confessions() {
|
||||
Http::fake(array_merge($this->login(), [
|
||||
'https://nami.dpsg.de/ica/rest/baseadmin/konfession' => Http::response($this->fakeJson('confession.json'), 200)
|
||||
]));
|
||||
|
||||
$this->setCredentials();
|
||||
|
||||
Nami::login();
|
||||
|
||||
$this->assertEquals([
|
||||
1 => 'römisch-katholisch'
|
||||
], Nami::confessions()->pluck('name', 'id')->toArray());
|
||||
|
||||
Http::assertSentCount(3);
|
||||
}
|
||||
|
||||
}
|
|
@ -32,6 +32,7 @@ class PullMemberTest extends TestCase
|
|||
'email_parents' => ['email_parents', ['testp@example.com', 'test2p@example.com']],
|
||||
'gender_id' => ['gender_id', [19, null]],
|
||||
'nationality_id' => ['nationality_id', [1054, null]],
|
||||
'confession_id' => ['confession_id', [1, null]],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"success": true,
|
||||
"data":
|
||||
[
|
||||
{
|
||||
"descriptor": "römisch-katholisch",
|
||||
"name": "",
|
||||
"representedClass": "de.iconcept.nami.entity.base.Konfession",
|
||||
"id": 1
|
||||
}
|
||||
],
|
||||
"responseType": "OK",
|
||||
"totalEntries": 10,
|
||||
"metaData":
|
||||
{
|
||||
"totalProperty": "totalEntries",
|
||||
"root": "data",
|
||||
"id": "id",
|
||||
"fields":
|
||||
[
|
||||
{
|
||||
"name": "id",
|
||||
"header": null,
|
||||
"hidden": false,
|
||||
"width": 80
|
||||
},
|
||||
{
|
||||
"name": "descriptor",
|
||||
"header": null,
|
||||
"hidden": false,
|
||||
"flex": 3
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"header": null,
|
||||
"hidden": false,
|
||||
"flex": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@
|
|||
"status": "Aktiv",
|
||||
"konfession": null,
|
||||
"fixBeitrag": null,
|
||||
"konfessionId": null,
|
||||
"konfessionId": 1,
|
||||
"zeitschriftenversand": true,
|
||||
"pfadfinder": null,
|
||||
"telefon3": "+11111",
|
||||
|
|
Loading…
Reference in New Issue