Skip to content

Commit

Permalink
Add group to customer
Browse files Browse the repository at this point in the history
  • Loading branch information
that-guy-iain committed Apr 25, 2023
1 parent e578a06 commit 1f935cd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Dto/CreateCustomerDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class CreateCustomerDto
#[SerializedName('name')]
private ?string $name = null;

#[Assert\NotBlank(allowNull: true)]
#[SerializedName('group')]
private ?string $group = null;

#[Assert\NotBlank]
#[Assert\Email]
#[SerializedName('email')]
Expand Down Expand Up @@ -86,4 +90,14 @@ public function setName(?string $name): void
{
$this->name = $name;
}

public function getGroup(): ?string
{
return $this->group;
}

public function setGroup(?string $group): void
{
$this->group = $group;
}
}
15 changes: 15 additions & 0 deletions src/Entity/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#[ORM\Table(name: 'customers')]
class Customer implements CustomerInterface
{
public const DEFAULT_GROUP = 'default';

#[ORM\Id]
#[ORM\Column(type: 'uuid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
Expand All @@ -45,6 +47,9 @@ class Customer implements CustomerInterface
#[ORM\Column(type: 'string', nullable: true)]
private ?string $name = null;

#[ORM\Column(type: 'string', nullable: false)]
private string $group = self::DEFAULT_GROUP;

#[ORM\Column(name: 'payment_provider_details_url', type: 'string', nullable: true)]
protected ?string $paymentProviderDetailsUrl;

Expand Down Expand Up @@ -223,4 +228,14 @@ public function setDisabled(bool $disabled): void
{
$this->disabled = $disabled;
}

public function getGroup(): string
{
return $this->group;
}

public function setGroup(string $group): void
{
$this->group = $group;
}
}
1 change: 1 addition & 0 deletions src/Factory/CustomerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function createCustomer(CreateCustomerDto $createCustomerDto, Customer $c
$customer->setReference($createCustomerDto->getReference());
$customer->setBillingAddress($address);
$customer->setName($createCustomerDto->getName());
$customer->setGroup($createCustomerDto->getGroup() ?? Customer::DEFAULT_GROUP);

$externalCustomerReference = $createCustomerDto->getExternalReference();

Expand Down

0 comments on commit 1f935cd

Please sign in to comment.