OrganizationCreationRequest.php 9.5 KB

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