| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- <?php
- namespace App\ApiResources\Organization;
- use ApiPlatform\Metadata\ApiProperty;
- use ApiPlatform\Metadata\ApiResource;
- use ApiPlatform\Metadata\Post;
- use App\Enum\Organization\LegalEnum;
- use App\Enum\Organization\OrganizationIdsEnum;
- use App\Enum\Organization\PrincipalTypeEnum;
- use App\Enum\Organization\SettingsProductEnum;
- use App\State\Processor\Organization\OrganizationCreationRequestProcessor;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * Requête de création d'une nouvelle organisation
- */
- #[ApiResource(
- operations: [
- new Post(
- uriTemplate: '/internal/organization/create',
- security: 'user.getSuperAdminAccess()'
- ),
- ],
- processor: OrganizationCreationRequestProcessor::class
- )]
- class OrganizationCreationRequest
- {
- private const FRANCE_COUNTRY_INTERNAL_ID = 72;
- private const OPENTALENT_ID = 1;
- /**
- * Id 'bidon' ajouté par défaut pour permettre la construction
- * de l'IRI par api platform.
- */
- #[ApiProperty(identifier: true)]
- private int $id = 0;
- /**
- * A quelle adresse email notifier la création de l'organisation, ou d'éventuelles erreurs ?
- * @var string|null
- */
- #[Assert\Email(message: 'The email {{ value }} is not a valid email.')]
- private ?string $sendConfirmationEmailAt = null;
- private string $name;
- private ?LegalEnum $legalStatus = null;
- private SettingsProductEnum $product;
- #[Assert\Length(
- min: 1,
- minMessage: 'Street address must be at least {{ limit }} characters long',
- )]
- private string $streetAddress1;
- private ?string $streetAddress2 = null;
- private ?string $streetAddress3 = null;
- #[Assert\Length(
- min: 3,
- minMessage: 'Postal code must be at least {{ limit }} characters long',
- )]
- private string $postalCode;
- #[Assert\Length(
- min: 1,
- minMessage: 'City must be at least {{ limit }} characters long',
- )]
- private string $city;
- private int $countryId = self::FRANCE_COUNTRY_INTERNAL_ID;
- #[Assert\Length(
- min: 10,
- minMessage: 'Phone number must be at least {{ limit }} characters long',
- )]
- private string $phoneNumber;
- #[Assert\Email(
- message: 'The email {{ value }} is not a valid email.',
- )]
- private string $email;
- #[Assert\Length(
- min: 2,
- minMessage: 'Subdomain must be at least {{ limit }} characters long',
- )]
- private string $subdomain;
- #[Assert\Positive]
- private int $parentId = OrganizationIdsEnum::_2IOS->value;
- private ?PrincipalTypeEnum $principalType = null;
- /**
- * Id d'une Person existante ou requête de création d'un nouvel access qui aura le
- * rôle de président(e) de la nouvelle structure.
- * @var int|OrganizationMemberCreationRequest|null
- */
- private int|OrganizationMemberCreationRequest|null $president = null;
- /**
- * Id d'une Person existante ou requête de création d'un nouvel access qui aura le
- * rôle de directeur / directrice de la nouvelle structure.
- * @var int|OrganizationMemberCreationRequest|null
- */
- private int|OrganizationMemberCreationRequest|null $director = null;
- /**
- * Faut-il créer un site typo3 pour la nouvelle structure
- * @var bool
- */
- private bool $createWebsite = true;
- /**
- * La structure est-elle cliente de Opentalent
- * @var bool
- */
- private bool $client = false;
- /**
- * For testing purposes only
- * @var bool
- */
- private bool $async = true;
- public function getId(): int
- {
- return $this->id;
- }
- public function setId(int $id): self
- {
- $this->id = $id;
- return $this;
- }
- public function getSendConfirmationEmailAt(): ?string
- {
- return $this->sendConfirmationEmailAt;
- }
- public function setSendConfirmationEmailAt(?string $sendConfirmationEmailAt): self
- {
- $this->sendConfirmationEmailAt = $sendConfirmationEmailAt;
- return $this;
- }
- public function getName(): string
- {
- return $this->name;
- }
- public function setName(string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getLegalStatus(): LegalEnum
- {
- return $this->legalStatus;
- }
- public function setLegalStatus(LegalEnum $legalStatus): self
- {
- $this->legalStatus = $legalStatus;
- return $this;
- }
- public function getProduct(): SettingsProductEnum
- {
- return $this->product;
- }
- public function setProduct(SettingsProductEnum $product): self
- {
- $this->product = $product;
- return $this;
- }
- public function getStreetAddress1(): string
- {
- return $this->streetAddress1;
- }
- public function setStreetAddress1(string $streetAddress1): self
- {
- $this->streetAddress1 = $streetAddress1;
- return $this;
- }
- public function getStreetAddress2(): ?string
- {
- return $this->streetAddress2;
- }
- public function setStreetAddress2(?string $streetAddress2): self
- {
- $this->streetAddress2 = $streetAddress2;
- return $this;
- }
- public function getStreetAddress3(): ?string
- {
- return $this->streetAddress3;
- }
- public function setStreetAddress3(?string $streetAddress3): self
- {
- $this->streetAddress3 = $streetAddress3;
- return $this;
- }
- public function getPostalCode(): string
- {
- return $this->postalCode;
- }
- public function setPostalCode(string $postalCode): self
- {
- $this->postalCode = $postalCode;
- return $this;
- }
- public function getCity(): string
- {
- return $this->city;
- }
- public function setCity(string $city): self
- {
- $this->city = $city;
- return $this;
- }
- public function getCountryId(): int
- {
- return $this->countryId;
- }
- public function setCountryId(int $countryId): self
- {
- $this->countryId = $countryId;
- return $this;
- }
- public function getPhoneNumber(): string
- {
- return $this->phoneNumber;
- }
- public function setPhoneNumber(string $phoneNumber): self
- {
- $this->phoneNumber = $phoneNumber;
- return $this;
- }
- public function getEmail(): string
- {
- return $this->email;
- }
- public function setEmail(string $email): self
- {
- $this->email = $email;
- return $this;
- }
- public function getSubdomain(): string
- {
- return $this->subdomain;
- }
- public function setSubdomain(string $subdomain): self
- {
- $this->subdomain = $subdomain;
- return $this;
- }
- public function getParentId(): int
- {
- return $this->parentId;
- }
- public function setParentId(int $parentId): self
- {
- $this->parentId = $parentId;
- return $this;
- }
- public function getPrincipalType(): PrincipalTypeEnum
- {
- return $this->principalType;
- }
- public function setPrincipalType(PrincipalTypeEnum $principalType): self
- {
- $this->principalType = $principalType;
- return $this;
- }
- public function getPresident(): ?OrganizationMemberCreationRequest
- {
- return $this->president;
- }
- public function setPresident(?OrganizationMemberCreationRequest $president): self
- {
- $this->president = $president;
- return $this;
- }
- public function getDirector(): ?OrganizationMemberCreationRequest
- {
- return $this->director;
- }
- public function setDirector(?OrganizationMemberCreationRequest $director): self
- {
- $this->director = $director;
- return $this;
- }
- public function getCreateWebsite(): bool
- {
- return $this->createWebsite;
- }
- public function setCreateWebsite(bool $createWebsite): self
- {
- $this->createWebsite = $createWebsite;
- return $this;
- }
- public function isClient(): bool
- {
- return $this->client;
- }
- public function setClient(bool $client): self
- {
- $this->client = $client;
- return $this;
- }
- public function isAsync(): bool
- {
- return $this->async;
- }
- public function setAsync(bool $async): self
- {
- $this->async = $async;
- return $this;
- }
- }
|