Skip to content

Commit

Permalink
fix(lib): generate code from braze-specification
Browse files Browse the repository at this point in the history
Fixes #37
  • Loading branch information
dependabot[bot] authored and remarkablemark committed Dec 22, 2023
1 parent 242e2c9 commit 3abc609
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 60 deletions.
12 changes: 9 additions & 3 deletions lib/Model/CampaignsTriggerSendPostBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function isInitialized($property): bool
*/
protected $sendId;
/**
* @var string
* @var array<string, mixed>
*/
protected $triggerProperties;
/**
Expand Down Expand Up @@ -72,12 +72,18 @@ public function setSendId(string $sendId): self
return $this;
}

public function getTriggerProperties(): string
/**
* @return array<string, mixed>
*/
public function getTriggerProperties(): iterable
{
return $this->triggerProperties;
}

public function setTriggerProperties(string $triggerProperties): self
/**
* @param array<string, mixed> $triggerProperties
*/
public function setTriggerProperties(iterable $triggerProperties): self
{
$this->initialized['triggerProperties'] = true;
$this->triggerProperties = $triggerProperties;
Expand Down
12 changes: 9 additions & 3 deletions lib/Model/CampaignsTriggerSendPostBodyRecipientsItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function isInitialized($property): bool
*/
protected $externalUserId;
/**
* @var string
* @var array<string, mixed>
*/
protected $triggerProperties;
/**
Expand Down Expand Up @@ -68,12 +68,18 @@ public function setExternalUserId(string $externalUserId): self
return $this;
}

public function getTriggerProperties(): string
/**
* @return array<string, mixed>
*/
public function getTriggerProperties(): iterable
{
return $this->triggerProperties;
}

public function setTriggerProperties(string $triggerProperties): self
/**
* @param array<string, mixed> $triggerProperties
*/
public function setTriggerProperties(iterable $triggerProperties): self
{
$this->initialized['triggerProperties'] = true;
$this->triggerProperties = $triggerProperties;
Expand Down
12 changes: 9 additions & 3 deletions lib/Model/CanvasTriggerScheduleCreatePostBodyRecipientsItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function isInitialized($property): bool
*/
protected $externalUserId;
/**
* @var string
* @var array<string, mixed>
*/
protected $triggerProperties;
/**
Expand Down Expand Up @@ -64,12 +64,18 @@ public function setExternalUserId(string $externalUserId): self
return $this;
}

public function getTriggerProperties(): string
/**
* @return array<string, mixed>
*/
public function getTriggerProperties(): iterable
{
return $this->triggerProperties;
}

public function setTriggerProperties(string $triggerProperties): self
/**
* @param array<string, mixed> $triggerProperties
*/
public function setTriggerProperties(iterable $triggerProperties): self
{
$this->initialized['triggerProperties'] = true;
$this->triggerProperties = $triggerProperties;
Expand Down
12 changes: 9 additions & 3 deletions lib/Model/CanvasTriggerSendPostBodyRecipientsItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function isInitialized($property): bool
*/
protected $externalUserId;
/**
* @var string
* @var array<string, mixed>
*/
protected $triggerProperties;
/**
Expand Down Expand Up @@ -72,12 +72,18 @@ public function setExternalUserId(string $externalUserId): self
return $this;
}

public function getTriggerProperties(): string
/**
* @return array<string, mixed>
*/
public function getTriggerProperties(): iterable
{
return $this->triggerProperties;
}

public function setTriggerProperties(string $triggerProperties): self
/**
* @param array<string, mixed> $triggerProperties
*/
public function setTriggerProperties(iterable $triggerProperties): self
{
$this->initialized['triggerProperties'] = true;
$this->triggerProperties = $triggerProperties;
Expand Down
40 changes: 24 additions & 16 deletions lib/Normalizer/CampaignsTriggerSendPostBodyNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public function denormalize($data, $class, $format = null, array $context = [])
unset($data['send_id']);
}
if (\array_key_exists('trigger_properties', $data)) {
$object->setTriggerProperties($data['trigger_properties']);
$values = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
foreach ($data['trigger_properties'] as $key => $value) {
$values[$key] = $value;
}
$object->setTriggerProperties($values);
unset($data['trigger_properties']);
}
if (\array_key_exists('broadcast', $data)) {
Expand All @@ -70,16 +74,16 @@ public function denormalize($data, $class, $format = null, array $context = [])
unset($data['audience']);
}
if (\array_key_exists('recipients', $data)) {
$values = [];
foreach ($data['recipients'] as $value) {
$values[] = $this->denormalizer->denormalize($value, 'Braze\\Model\\CampaignsTriggerSendPostBodyRecipientsItem', 'json', $context);
$values_1 = [];
foreach ($data['recipients'] as $value_1) {
$values_1[] = $this->denormalizer->denormalize($value_1, 'Braze\\Model\\CampaignsTriggerSendPostBodyRecipientsItem', 'json', $context);
}
$object->setRecipients($values);
$object->setRecipients($values_1);
unset($data['recipients']);
}
foreach ($data as $key => $value_1) {
if (preg_match('/.*/', (string) $key)) {
$object[$key] = $value_1;
foreach ($data as $key_1 => $value_2) {
if (preg_match('/.*/', (string) $key_1)) {
$object[$key_1] = $value_2;
}
}

Expand All @@ -99,7 +103,11 @@ public function normalize($object, $format = null, array $context = [])
$data['send_id'] = $object->getSendId();
}
if ($object->isInitialized('triggerProperties') && null !== $object->getTriggerProperties()) {
$data['trigger_properties'] = $object->getTriggerProperties();
$values = [];
foreach ($object->getTriggerProperties() as $key => $value) {
$values[$key] = $value;
}
$data['trigger_properties'] = $values;
}
if ($object->isInitialized('broadcast') && null !== $object->getBroadcast()) {
$data['broadcast'] = $object->getBroadcast();
Expand All @@ -108,15 +116,15 @@ public function normalize($object, $format = null, array $context = [])
$data['audience'] = $this->normalizer->normalize($object->getAudience(), 'json', $context);
}
if ($object->isInitialized('recipients') && null !== $object->getRecipients()) {
$values = [];
foreach ($object->getRecipients() as $value) {
$values[] = $this->normalizer->normalize($value, 'json', $context);
$values_1 = [];
foreach ($object->getRecipients() as $value_1) {
$values_1[] = $this->normalizer->normalize($value_1, 'json', $context);
}
$data['recipients'] = $values;
$data['recipients'] = $values_1;
}
foreach ($object as $key => $value_1) {
if (preg_match('/.*/', (string) $key)) {
$data[$key] = $value_1;
foreach ($object as $key_1 => $value_2) {
if (preg_match('/.*/', (string) $key_1)) {
$data[$key_1] = $value_2;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public function denormalize($data, $class, $format = null, array $context = [])
unset($data['external_user_id']);
}
if (\array_key_exists('trigger_properties', $data)) {
$object->setTriggerProperties($data['trigger_properties']);
$values = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
foreach ($data['trigger_properties'] as $key => $value) {
$values[$key] = $value;
}
$object->setTriggerProperties($values);
unset($data['trigger_properties']);
}
if (\array_key_exists('send_to_existing_only', $data)) {
Expand All @@ -69,9 +73,9 @@ public function denormalize($data, $class, $format = null, array $context = [])
$object->setAttributes($this->denormalizer->denormalize($data['attributes'], 'Braze\\Model\\CampaignsTriggerSendPostBodyRecipientsItemAttributes', 'json', $context));
unset($data['attributes']);
}
foreach ($data as $key => $value) {
if (preg_match('/.*/', (string) $key)) {
$object[$key] = $value;
foreach ($data as $key_1 => $value_1) {
if (preg_match('/.*/', (string) $key_1)) {
$object[$key_1] = $value_1;
}
}

Expand All @@ -91,17 +95,21 @@ public function normalize($object, $format = null, array $context = [])
$data['external_user_id'] = $object->getExternalUserId();
}
if ($object->isInitialized('triggerProperties') && null !== $object->getTriggerProperties()) {
$data['trigger_properties'] = $object->getTriggerProperties();
$values = [];
foreach ($object->getTriggerProperties() as $key => $value) {
$values[$key] = $value;
}
$data['trigger_properties'] = $values;
}
if ($object->isInitialized('sendToExistingOnly') && null !== $object->getSendToExistingOnly()) {
$data['send_to_existing_only'] = $object->getSendToExistingOnly();
}
if ($object->isInitialized('attributes') && null !== $object->getAttributes()) {
$data['attributes'] = $this->normalizer->normalize($object->getAttributes(), 'json', $context);
}
foreach ($object as $key => $value) {
if (preg_match('/.*/', (string) $key)) {
$data[$key] = $value;
foreach ($object as $key_1 => $value_1) {
if (preg_match('/.*/', (string) $key_1)) {
$data[$key_1] = $value_1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,24 @@ public function denormalize($data, $class, $format = null, array $context = [])
unset($data['external_user_id']);
}
if (\array_key_exists('trigger_properties', $data)) {
$object->setTriggerProperties($data['trigger_properties']);
$values = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
foreach ($data['trigger_properties'] as $key => $value) {
$values[$key] = $value;
}
$object->setTriggerProperties($values);
unset($data['trigger_properties']);
}
if (\array_key_exists('canvas_entry_properties', $data)) {
$values = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
foreach ($data['canvas_entry_properties'] as $key => $value) {
$values[$key] = $value;
$values_1 = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
foreach ($data['canvas_entry_properties'] as $key_1 => $value_1) {
$values_1[$key_1] = $value_1;
}
$object->setCanvasEntryProperties($values);
$object->setCanvasEntryProperties($values_1);
unset($data['canvas_entry_properties']);
}
foreach ($data as $key_1 => $value_1) {
if (preg_match('/.*/', (string) $key_1)) {
$object[$key_1] = $value_1;
foreach ($data as $key_2 => $value_2) {
if (preg_match('/.*/', (string) $key_2)) {
$object[$key_2] = $value_2;
}
}

Expand All @@ -91,18 +95,22 @@ public function normalize($object, $format = null, array $context = [])
$data['external_user_id'] = $object->getExternalUserId();
}
if ($object->isInitialized('triggerProperties') && null !== $object->getTriggerProperties()) {
$data['trigger_properties'] = $object->getTriggerProperties();
}
if ($object->isInitialized('canvasEntryProperties') && null !== $object->getCanvasEntryProperties()) {
$values = [];
foreach ($object->getCanvasEntryProperties() as $key => $value) {
foreach ($object->getTriggerProperties() as $key => $value) {
$values[$key] = $value;
}
$data['canvas_entry_properties'] = $values;
$data['trigger_properties'] = $values;
}
if ($object->isInitialized('canvasEntryProperties') && null !== $object->getCanvasEntryProperties()) {
$values_1 = [];
foreach ($object->getCanvasEntryProperties() as $key_1 => $value_1) {
$values_1[$key_1] = $value_1;
}
$data['canvas_entry_properties'] = $values_1;
}
foreach ($object as $key_1 => $value_1) {
if (preg_match('/.*/', (string) $key_1)) {
$data[$key_1] = $value_1;
foreach ($object as $key_2 => $value_2) {
if (preg_match('/.*/', (string) $key_2)) {
$data[$key_2] = $value_2;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public function denormalize($data, $class, $format = null, array $context = [])
unset($data['external_user_id']);
}
if (\array_key_exists('trigger_properties', $data)) {
$object->setTriggerProperties($data['trigger_properties']);
$values = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
foreach ($data['trigger_properties'] as $key => $value) {
$values[$key] = $value;
}
$object->setTriggerProperties($values);
unset($data['trigger_properties']);
}
if (\array_key_exists('canvas_entry_properties', $data)) {
Expand All @@ -73,9 +77,9 @@ public function denormalize($data, $class, $format = null, array $context = [])
$object->setAttributes($this->denormalizer->denormalize($data['attributes'], 'Braze\\Model\\CanvasTriggerSendPostBodyRecipientsItemAttributes', 'json', $context));
unset($data['attributes']);
}
foreach ($data as $key => $value) {
if (preg_match('/.*/', (string) $key)) {
$object[$key] = $value;
foreach ($data as $key_1 => $value_1) {
if (preg_match('/.*/', (string) $key_1)) {
$object[$key_1] = $value_1;
}
}

Expand All @@ -95,7 +99,11 @@ public function normalize($object, $format = null, array $context = [])
$data['external_user_id'] = $object->getExternalUserId();
}
if ($object->isInitialized('triggerProperties') && null !== $object->getTriggerProperties()) {
$data['trigger_properties'] = $object->getTriggerProperties();
$values = [];
foreach ($object->getTriggerProperties() as $key => $value) {
$values[$key] = $value;
}
$data['trigger_properties'] = $values;
}
if ($object->isInitialized('canvasEntryProperties') && null !== $object->getCanvasEntryProperties()) {
$data['canvas_entry_properties'] = $object->getCanvasEntryProperties();
Expand All @@ -106,9 +114,9 @@ public function normalize($object, $format = null, array $context = [])
if ($object->isInitialized('attributes') && null !== $object->getAttributes()) {
$data['attributes'] = $this->normalizer->normalize($object->getAttributes(), 'json', $context);
}
foreach ($object as $key => $value) {
if (preg_match('/.*/', (string) $key)) {
$data[$key] = $value;
foreach ($object as $key_1 => $value_1) {
if (preg_match('/.*/', (string) $key_1)) {
$data[$key_1] = $value_1;
}
}

Expand Down

0 comments on commit 3abc609

Please sign in to comment.