diff --git a/src/Gender.php b/src/Gender.php index dab8b8b..1372b9d 100644 --- a/src/Gender.php +++ b/src/Gender.php @@ -9,6 +9,10 @@ class Gender extends Model implements Nullable { protected $guarded = []; + public static function getNullValue() { + return 23; + } + public static function fromNami($item) { $item = collect($item) ->only(['descriptor', 'id']) @@ -25,7 +29,7 @@ class Gender extends Model implements Nullable { } public function getIsNullAttribute() { - return $this->attributes['name'] == 'keine Angabe'; + return $this->attributes['id'] == self::getNullValue(); } } diff --git a/src/Member.php b/src/Member.php index 3c5df3f..28758fd 100644 --- a/src/Member.php +++ b/src/Member.php @@ -29,6 +29,7 @@ class Member extends Model { 'telefon3' => 'work_phone', 'telefax' => 'fax', 'email' => 'email', + 'geschlechtId' => 'gender_id', 'emailVertretungsberechtigter' => 'email_parents' ]; @@ -49,4 +50,8 @@ class Member extends Model { parent::__construct($member); } + public function getGenderIdAttribute() { + return $this->attributes['gender_id'] == Gender::getNullValue() ? null : $this->attributes['gender_id']; + } + } diff --git a/src/Nullable.php b/src/Nullable.php index f2eed24..68bcff9 100644 --- a/src/Nullable.php +++ b/src/Nullable.php @@ -6,4 +6,6 @@ interface Nullable { public function getIsNullAttribute(); + public static function getNullValue(); + } diff --git a/tests/Unit/MemberFakeTest.php b/tests/Unit/MemberFakeTest.php deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Unit/PullMemberTest.php b/tests/Unit/PullMemberTest.php index 910f68a..88d1b23 100644 --- a/tests/Unit/PullMemberTest.php +++ b/tests/Unit/PullMemberTest.php @@ -30,6 +30,7 @@ class PullMemberTest extends TestCase 'fax' => ['fax', ['+55111', '+55222']], 'email' => ['email', ['test@example.com', 'test2@example.com']], 'email_parents' => ['email_parents', ['testp@example.com', 'test2p@example.com']], + 'gender_id' => ['gender_id', [19, null]], ]; } diff --git a/tests/json/member-17.json b/tests/json/member-17.json index 11a2c8b..f0420c1 100644 --- a/tests/json/member-17.json +++ b/tests/json/member-17.json @@ -47,7 +47,7 @@ "zahlungsKonditionId": null, "zahlungsKondition": null }, - "geschlechtId": 19, + "geschlechtId": 23, "land": "Deutschland", "email": "test2@example.com", "telefon1": "+49668",