Add member overview getter
This commit is contained in:
parent
a5881ffe5f
commit
817c939978
14
src/Api.php
14
src/Api.php
|
@ -169,6 +169,20 @@ class Api {
|
|||
});
|
||||
}
|
||||
|
||||
public function memberOverviewOf($groupId) {
|
||||
$url = self::$url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/flist';
|
||||
$response = $this->http()->get($url);
|
||||
|
||||
return collect($response['data'])->map(function($member) use ($groupId) {
|
||||
$member = collect($member)->mapWithKeys(function($value, $key) {
|
||||
return [ str_replace('entries_', '', $key) => $value ];
|
||||
});
|
||||
$member['gruppierungId'] = $groupId;
|
||||
|
||||
return $member;
|
||||
});
|
||||
}
|
||||
|
||||
private function singleMemberFallback($groupId, $memberId) {
|
||||
$url = self::$url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/flist';
|
||||
$response = $this->http()->get($url);
|
||||
|
|
|
@ -45,6 +45,12 @@ class Group implements Arrayable {
|
|||
return Member::fromNami(Nami::member($this->id, $id));
|
||||
}
|
||||
|
||||
public function memberOverview() {
|
||||
return Nami::memberOverviewOf($this->id)->map(function($member) {
|
||||
return Member::fromNami($member);
|
||||
});
|
||||
}
|
||||
|
||||
public function activities(): Collection {
|
||||
return Nami::activities($this->id);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class PullMemberTest extends TestCase
|
|||
/**
|
||||
* @dataProvider dataProvider
|
||||
*/
|
||||
public function test_get_attribute_of_overview($key, $values) {
|
||||
public function test_get_attribute_of_member_collection($key, $values) {
|
||||
Http::fake(array_merge($this->login(), [
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/flist' => Http::response($this->fakeJson('member_overview.json'), 200),
|
||||
|
@ -110,6 +110,27 @@ class PullMemberTest extends TestCase
|
|||
Http::assertSentCount(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider overviewDataProvider
|
||||
*/
|
||||
public function test_get_attribute_of_member_overview($key, $values) {
|
||||
Http::fake(array_merge($this->login(), [
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/flist' => Http::response($this->fakeJson('member_overview.json'), 200)
|
||||
]));
|
||||
|
||||
$this->setCredentials();
|
||||
|
||||
Nami::login();
|
||||
|
||||
$members = Nami::group(103)->memberOverview();
|
||||
foreach ($members as $i => $m) {
|
||||
$this->assertSame($values[$i], $m->toArray()[$key]);
|
||||
}
|
||||
|
||||
Http::assertSentCount(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider relationProvider
|
||||
*/
|
||||
|
|
|
@ -43,7 +43,45 @@
|
|||
"entries_telefax":"+55111"
|
||||
},
|
||||
{
|
||||
"id": 17
|
||||
"id": 17,
|
||||
"entries_ersteTaetigkeitId":null,
|
||||
"entries_genericField1":"",
|
||||
"entries_version":58,
|
||||
"entries_telefon3":"+22222",
|
||||
"entries_telefon2":"+49172",
|
||||
"entries_telefon1":"+49668",
|
||||
"descriptor":"Nach2, Jane",
|
||||
"entries_id":16,
|
||||
"entries_staatsangehoerigkeit":"deutsch",
|
||||
"representedClass":"de.iconcept.nami.entity.mitglied.Mitglied",
|
||||
"entries_rover":"",
|
||||
"entries_pfadfinder":"",
|
||||
"entries_mitgliedsNummer":90166,
|
||||
"entries_wiederverwendenFlag":false,
|
||||
"entries_ersteUntergliederungId":null,
|
||||
"entries_rowCssClass":" ",
|
||||
"entries_vorname":"Jane",
|
||||
"entries_woelfling":"",
|
||||
"entries_beitragsarten":"",
|
||||
"entries_stufe":"Wölfling",
|
||||
"entries_email":"test2@example.com",
|
||||
"entries_konfession":"",
|
||||
"entries_fixBeitrag":"",
|
||||
"entries_emailVertretungsberechtigter":"test2p@example.com",
|
||||
"entries_lastUpdated":"2015-02-03 15:20:07",
|
||||
"entries_status":"Aktiv",
|
||||
"entries_jungpfadfinder":"",
|
||||
"entries_mglType":"Mitglied",
|
||||
"entries_kontoverbindung":"",
|
||||
"entries_geschlecht":"",
|
||||
"entries_spitzname":"",
|
||||
"entries_geburtsDatum":"1984-01-17 00:00:00",
|
||||
"entries_staatangehoerigkeitText":"",
|
||||
"entries_nachname":"Nach2",
|
||||
"entries_eintrittsdatum":"",
|
||||
"entries_austrittsDatum":"",
|
||||
"entries_genericField2":"",
|
||||
"entries_telefax":"+55222"
|
||||
}
|
||||
],
|
||||
"responseType": "OK",
|
||||
|
|
Loading…
Reference in New Issue