OrganizationCreationRequest.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <?php
  2. namespace App\ApiResources\Organization;
  3. use ApiPlatform\Metadata\ApiProperty;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use ApiPlatform\Metadata\Post;
  6. use App\Enum\Organization\LegalEnum;
  7. use App\Enum\Organization\OrganizationIdsEnum;
  8. use App\Enum\Organization\PrincipalTypeEnum;
  9. use App\Enum\Organization\SettingsProductEnum;
  10. use App\State\Processor\Organization\OrganizationCreationRequestProcessor;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13. * Requête de création d'une nouvelle organisation.
  14. */
  15. #[ApiResource(
  16. operations: [
  17. new Post(
  18. uriTemplate: '/internal/organization/create',
  19. ),
  20. ],
  21. processor: OrganizationCreationRequestProcessor::class
  22. )]
  23. class OrganizationCreationRequest
  24. {
  25. private const FRANCE_COUNTRY_INTERNAL_ID = 72;
  26. public const STATUS_PENDING = 'pending';
  27. public const STATUS_OK = 'ok';
  28. public const STATUS_OK_WITH_ERRORS = 'ok with errors';
  29. /**
  30. * Id 'bidon' ajouté par défaut pour permettre la construction
  31. * de l'IRI par api platform.
  32. */
  33. #[ApiProperty(identifier: true)]
  34. private int $id = 0;
  35. /**
  36. * A quelle adresse email notifier la création de l'organisation, ou d'éventuelles erreurs ?
  37. */
  38. #[Assert\Email(message: 'The email {{ value }} is not a valid email.')]
  39. private ?string $sendConfirmationEmailAt = null;
  40. private string $name;
  41. /**
  42. * Matricule (obligatoire dans le réseau CMF).
  43. */
  44. #[Assert\Regex(pattern: '/^|(FR\d{12})$/')]
  45. private string $identifier = '';
  46. #[Assert\Regex(pattern: '/^|(\d+)$/')]
  47. private string $siretNumber = '';
  48. #[Assert\Regex(pattern: '/^|(W\d+)$/')]
  49. private string $waldecNumber = '';
  50. private ?LegalEnum $legalStatus = null;
  51. private SettingsProductEnum $product;
  52. #[Assert\Length(
  53. min: 1,
  54. minMessage: 'Street address must be at least {{ limit }} characters long',
  55. )]
  56. private string $streetAddress1;
  57. private ?string $streetAddress2 = null;
  58. private ?string $streetAddress3 = null;
  59. #[Assert\Length(
  60. min: 3,
  61. minMessage: 'Postal code must be at least {{ limit }} characters long',
  62. )]
  63. private string $postalCode;
  64. #[Assert\Length(
  65. min: 1,
  66. minMessage: 'City must be at least {{ limit }} characters long',
  67. )]
  68. private string $city;
  69. private int $countryId = self::FRANCE_COUNTRY_INTERNAL_ID;
  70. #[Assert\Length(
  71. min: 10,
  72. minMessage: 'Phone number must be at least {{ limit }} characters long',
  73. )]
  74. private string $phoneNumber;
  75. #[Assert\Email(
  76. message: 'The email {{ value }} is not a valid email.',
  77. )]
  78. private string $email;
  79. #[Assert\Length(
  80. min: 2,
  81. minMessage: 'Subdomain must be at least {{ limit }} characters long',
  82. )]
  83. private string $subdomain;
  84. #[Assert\Positive]
  85. private int $parentId = OrganizationIdsEnum::_2IOS->value;
  86. private ?PrincipalTypeEnum $principalType = null;
  87. /**
  88. * Id d'une Person existante ou requête de création d'un nouvel access qui aura le
  89. * rôle de président(e) de la nouvelle structure.
  90. */
  91. private int|OrganizationMemberCreationRequest|null $president = null;
  92. /**
  93. * Id d'une Person existante ou requête de création d'un nouvel access qui aura le
  94. * rôle de directeur / directrice de la nouvelle structure.
  95. */
  96. private int|OrganizationMemberCreationRequest|null $director = null;
  97. /**
  98. * Faut-il créer un site typo3 pour la nouvelle structure.
  99. */
  100. private bool $createWebsite = true;
  101. /**
  102. * La structure est-elle cliente de Opentalent.
  103. */
  104. private bool $client = false;
  105. /**
  106. * Statut de l'opération.
  107. */
  108. private string $status = self::STATUS_PENDING;
  109. private ?\DateTime $creationDate = null;
  110. private ?int $authorId = null;
  111. /**
  112. * For testing purposes only.
  113. */
  114. private bool $async = true;
  115. public function getId(): int
  116. {
  117. return $this->id;
  118. }
  119. public function setId(int $id): self
  120. {
  121. $this->id = $id;
  122. return $this;
  123. }
  124. public function getSendConfirmationEmailAt(): ?string
  125. {
  126. return $this->sendConfirmationEmailAt;
  127. }
  128. public function setSendConfirmationEmailAt(?string $sendConfirmationEmailAt): self
  129. {
  130. $this->sendConfirmationEmailAt = $sendConfirmationEmailAt;
  131. return $this;
  132. }
  133. public function getName(): string
  134. {
  135. return $this->name;
  136. }
  137. public function setName(string $name): self
  138. {
  139. $this->name = $name;
  140. return $this;
  141. }
  142. public function getIdentifier(): string
  143. {
  144. return $this->identifier;
  145. }
  146. public function setIdentifier(string $identifier): self
  147. {
  148. $this->identifier = $identifier;
  149. return $this;
  150. }
  151. public function getSiretNumber(): string
  152. {
  153. return $this->siretNumber;
  154. }
  155. public function setSiretNumber(string $siretNumber): self
  156. {
  157. $this->siretNumber = $siretNumber;
  158. return $this;
  159. }
  160. public function getWaldecNumber(): string
  161. {
  162. return $this->waldecNumber;
  163. }
  164. public function setWaldecNumber(string $waldecNumber): self
  165. {
  166. $this->waldecNumber = $waldecNumber;
  167. return $this;
  168. }
  169. public function getLegalStatus(): LegalEnum
  170. {
  171. return $this->legalStatus;
  172. }
  173. public function setLegalStatus(LegalEnum $legalStatus): self
  174. {
  175. $this->legalStatus = $legalStatus;
  176. return $this;
  177. }
  178. public function getProduct(): SettingsProductEnum
  179. {
  180. return $this->product;
  181. }
  182. public function setProduct(SettingsProductEnum $product): self
  183. {
  184. $this->product = $product;
  185. return $this;
  186. }
  187. public function getStreetAddress1(): string
  188. {
  189. return $this->streetAddress1;
  190. }
  191. public function setStreetAddress1(string $streetAddress1): self
  192. {
  193. $this->streetAddress1 = $streetAddress1;
  194. return $this;
  195. }
  196. public function getStreetAddress2(): ?string
  197. {
  198. return $this->streetAddress2;
  199. }
  200. public function setStreetAddress2(?string $streetAddress2): self
  201. {
  202. $this->streetAddress2 = $streetAddress2;
  203. return $this;
  204. }
  205. public function getStreetAddress3(): ?string
  206. {
  207. return $this->streetAddress3;
  208. }
  209. public function setStreetAddress3(?string $streetAddress3): self
  210. {
  211. $this->streetAddress3 = $streetAddress3;
  212. return $this;
  213. }
  214. public function getPostalCode(): string
  215. {
  216. return $this->postalCode;
  217. }
  218. public function setPostalCode(string $postalCode): self
  219. {
  220. $this->postalCode = $postalCode;
  221. return $this;
  222. }
  223. public function getCity(): string
  224. {
  225. return $this->city;
  226. }
  227. public function setCity(string $city): self
  228. {
  229. $this->city = $city;
  230. return $this;
  231. }
  232. public function getCountryId(): int
  233. {
  234. return $this->countryId;
  235. }
  236. public function setCountryId(int $countryId): self
  237. {
  238. $this->countryId = $countryId;
  239. return $this;
  240. }
  241. public function getPhoneNumber(): string
  242. {
  243. return $this->phoneNumber;
  244. }
  245. public function setPhoneNumber(string $phoneNumber): self
  246. {
  247. $this->phoneNumber = $phoneNumber;
  248. return $this;
  249. }
  250. public function getEmail(): string
  251. {
  252. return $this->email;
  253. }
  254. public function setEmail(string $email): self
  255. {
  256. $this->email = $email;
  257. return $this;
  258. }
  259. public function getSubdomain(): string
  260. {
  261. return $this->subdomain;
  262. }
  263. public function setSubdomain(string $subdomain): self
  264. {
  265. $this->subdomain = $subdomain;
  266. return $this;
  267. }
  268. public function getParentId(): int
  269. {
  270. return $this->parentId;
  271. }
  272. public function setParentId(int $parentId): self
  273. {
  274. $this->parentId = $parentId;
  275. return $this;
  276. }
  277. public function getPrincipalType(): PrincipalTypeEnum
  278. {
  279. return $this->principalType;
  280. }
  281. public function setPrincipalType(PrincipalTypeEnum $principalType): self
  282. {
  283. $this->principalType = $principalType;
  284. return $this;
  285. }
  286. public function getPresident(): ?OrganizationMemberCreationRequest
  287. {
  288. return $this->president;
  289. }
  290. public function setPresident(?OrganizationMemberCreationRequest $president): self
  291. {
  292. $this->president = $president;
  293. return $this;
  294. }
  295. public function getDirector(): ?OrganizationMemberCreationRequest
  296. {
  297. return $this->director;
  298. }
  299. public function setDirector(?OrganizationMemberCreationRequest $director): self
  300. {
  301. $this->director = $director;
  302. return $this;
  303. }
  304. public function getCreateWebsite(): bool
  305. {
  306. return $this->createWebsite;
  307. }
  308. public function setCreateWebsite(bool $createWebsite): self
  309. {
  310. $this->createWebsite = $createWebsite;
  311. return $this;
  312. }
  313. public function isClient(): bool
  314. {
  315. return $this->client;
  316. }
  317. public function setClient(bool $client): self
  318. {
  319. $this->client = $client;
  320. return $this;
  321. }
  322. public function getStatus(): string
  323. {
  324. return $this->status;
  325. }
  326. public function setStatus(string $status): self
  327. {
  328. $this->status = $status;
  329. return $this;
  330. }
  331. public function getCreationDate(): \DateTime
  332. {
  333. return $this->creationDate;
  334. }
  335. public function setCreationDate(?\DateTime $creationDate): self
  336. {
  337. $this->creationDate = $creationDate;
  338. return $this;
  339. }
  340. public function getAuthorId(): ?int
  341. {
  342. return $this->authorId;
  343. }
  344. public function setAuthorId(?int $authorId): self
  345. {
  346. $this->authorId = $authorId;
  347. return $this;
  348. }
  349. public function isAsync(): bool
  350. {
  351. return $this->async;
  352. }
  353. public function setAsync(bool $async): self
  354. {
  355. $this->async = $async;
  356. return $this;
  357. }
  358. }