diff --git a/src/Api.php b/src/Api.php index 5635f3d..a5cadc2 100644 --- a/src/Api.php +++ b/src/Api.php @@ -92,9 +92,11 @@ class Api { $member = Member::fromAttributes($attributes); $response = $this->http()->put(self::$url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->group_id.'/'.$member->id, $member->toNami()); - if (!data_get($response->json(), 'id')) { - $this->exception('Update failed', $response->json(), $member->toNami()); + if (data_get($response->json(), 'success') !== true) { + $this->exception('Update failed', $member->toNami(), $response->json()); } + + return $response->json()['data']; } public function membershipsOf($memberId): Collection { diff --git a/src/Member.php b/src/Member.php index f1853f6..eb3dc10 100644 --- a/src/Member.php +++ b/src/Member.php @@ -80,13 +80,24 @@ class Member extends Model { 'eintrittsdatum' => $this->joined_at.'T00:00:00', 'version' => $this->version, 'beitragsartId' => $this->fee_id, - 'regionId' => $this->region_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 ?: '', ]; } diff --git a/src/NamiUser.php b/src/NamiUser.php index e3e1bb8..de74bd5 100644 --- a/src/NamiUser.php +++ b/src/NamiUser.php @@ -30,7 +30,7 @@ class NamiUser implements Authenticatable { } public function getNamiGroupId() { - return $this->groupid; + return $this->api()->findNr($this->mglnr)->group_id; } public function getAuthIdentifierName() {