diff --git a/src/Mappers/ContactIdentifiers/ContactIdentifierMapper.php b/src/Mappers/ContactIdentifiers/ContactIdentifierMapper.php index 56f2fea..c884613 100644 --- a/src/Mappers/ContactIdentifiers/ContactIdentifierMapper.php +++ b/src/Mappers/ContactIdentifiers/ContactIdentifierMapper.php @@ -15,6 +15,7 @@ class ContactIdentifierMapper public function map(stdClass $data): ContactIdentifier { $contact = null; + if (property_exists($data, 'contact') && $data->contact != null) { $contactMapper = new ContactMapper(); $contact = $contactMapper->map($data->contact); @@ -23,7 +24,7 @@ public function map(stdClass $data): ContactIdentifier return new ContactIdentifier( $data->value, $data->active ?? null, - $data->name ?? '', + $data->name ?? null, $contact ); } diff --git a/src/Mappers/Contacts/AttributeMapper.php b/src/Mappers/Contacts/AttributeMapper.php index 0527cf0..5c221da 100644 --- a/src/Mappers/Contacts/AttributeMapper.php +++ b/src/Mappers/Contacts/AttributeMapper.php @@ -26,7 +26,7 @@ public function map(stdClass $data): Attribute $options[] = get_object_vars($item); } } - + return new Attribute( $data->name, $data->label, diff --git a/src/Mappers/Loyalty/RewardAttributes/RewardAttributeMapper.php b/src/Mappers/Loyalty/RewardAttributes/RewardAttributeMapper.php index 459b868..412967b 100644 --- a/src/Mappers/Loyalty/RewardAttributes/RewardAttributeMapper.php +++ b/src/Mappers/Loyalty/RewardAttributes/RewardAttributeMapper.php @@ -15,13 +15,14 @@ class RewardAttributeMapper public function map(stdClass $rewardAttribute): RewardAttribute { $fieldType = $rewardAttribute->type; + $isSoftReadOnly = property_exists($rewardAttribute, 'is_soft_read_only') && $rewardAttribute->is_soft_read_only; $isHardReadOnly = property_exists($rewardAttribute, 'is_hard_read_only') && $rewardAttribute->is_hard_read_only; $isPiggyDefined = property_exists($rewardAttribute, 'is_piggy_defined') && $rewardAttribute->is_piggy_defined; - $options = null; - if (property_exists($rewardAttribute, 'options') && $rewardAttribute->options != null) { + $options = []; + if (property_exists($rewardAttribute, 'options') && $rewardAttribute->options != null) { foreach ($rewardAttribute->options as $item) { $options[] = get_object_vars($item); } diff --git a/src/Mappers/Loyalty/RewardAttributes/RewardAttributesMapper.php b/src/Mappers/Loyalty/RewardAttributes/RewardAttributesMapper.php index 4c11f49..ff3a436 100644 --- a/src/Mappers/Loyalty/RewardAttributes/RewardAttributesMapper.php +++ b/src/Mappers/Loyalty/RewardAttributes/RewardAttributesMapper.php @@ -11,6 +11,7 @@ class RewardAttributesMapper public function map(array $data): array { $rewardAttributeMapper = new RewardAttributeMapper; + $rewardAttributes = []; foreach ($data as $item) { diff --git a/tests/OAuth/ContactAttributes/ContactAttributesResourceTest.php b/tests/OAuth/Contacts/ContactAttributesResourceTest.php similarity index 99% rename from tests/OAuth/ContactAttributes/ContactAttributesResourceTest.php rename to tests/OAuth/Contacts/ContactAttributesResourceTest.php index 6fc7a9a..ab3f464 100644 --- a/tests/OAuth/ContactAttributes/ContactAttributesResourceTest.php +++ b/tests/OAuth/Contacts/ContactAttributesResourceTest.php @@ -1,6 +1,6 @@