OrganizationCreationRequest.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. security: 'user.getSuperAdminAccess()'
  20. ),
  21. ],
  22. processor: OrganizationCreationRequestProcessor::class
  23. )]
  24. class OrganizationCreationRequest
  25. {
  26. private const FRANCE_COUNTRY_INTERNAL_ID = 72;
  27. private const OPENTALENT_ID = 1;
  28. /**
  29. * Id 'bidon' ajouté par défaut pour permettre la construction
  30. * de l'IRI par api platform.
  31. */
  32. #[ApiProperty(identifier: true)]
  33. private int $id = 0;
  34. /**
  35. * A quelle adresse email notifier la création de l'organisation, ou d'éventuelles erreurs ?
  36. * @var string|null
  37. */
  38. #[Assert\Email(message: 'The email {{ value }} is not a valid email.')]
  39. private ?string $sendConfirmationEmailAt = null;
  40. private string $name;
  41. private ?LegalEnum $legalStatus = null;
  42. private SettingsProductEnum $product;
  43. #[Assert\Length(
  44. min: 1,
  45. minMessage: 'Street address must be at least {{ limit }} characters long',
  46. )]
  47. private string $streetAddress1;
  48. private ?string $streetAddress2 = null;
  49. private ?string $streetAddress3 = null;
  50. #[Assert\Length(
  51. min: 3,
  52. minMessage: 'Postal code must be at least {{ limit }} characters long',
  53. )]
  54. private string $postalCode;
  55. #[Assert\Length(
  56. min: 1,
  57. minMessage: 'City must be at least {{ limit }} characters long',
  58. )]
  59. private string $city;
  60. private int $countryId = self::FRANCE_COUNTRY_INTERNAL_ID;
  61. #[Assert\Length(
  62. min: 10,
  63. minMessage: 'Phone number must be at least {{ limit }} characters long',
  64. )]
  65. private string $phoneNumber;
  66. #[Assert\Email(
  67. message: 'The email {{ value }} is not a valid email.',
  68. )]
  69. private string $email;
  70. #[Assert\Length(
  71. min: 2,
  72. minMessage: 'Subdomain must be at least {{ limit }} characters long',
  73. )]
  74. private string $subdomain;
  75. #[Assert\Positive]
  76. private int $parentId = OrganizationIdsEnum::_2IOS->value;
  77. private ?PrincipalTypeEnum $principalType = null;
  78. /**
  79. * Id d'une Person existante ou requête de création d'un nouvel access qui aura le
  80. * rôle de président(e) de la nouvelle structure.
  81. * @var int|OrganizationMemberCreationRequest|null
  82. */
  83. private int|OrganizationMemberCreationRequest|null $president = 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 directeur / directrice de la nouvelle structure.
  87. * @var int|OrganizationMemberCreationRequest|null
  88. */
  89. private int|OrganizationMemberCreationRequest|null $director = null;
  90. /**
  91. * Faut-il créer un site typo3 pour la nouvelle structure
  92. * @var bool
  93. */
  94. private bool $createWebsite = true;
  95. /**
  96. * La structure est-elle cliente de Opentalent
  97. * @var bool
  98. */
  99. private bool $client = false;
  100. /**
  101. * For testing purposes only
  102. * @var bool
  103. */
  104. private bool $async = true;
  105. public function getId(): int
  106. {
  107. return $this->id;
  108. }
  109. public function setId(int $id): self
  110. {
  111. $this->id = $id;
  112. return $this;
  113. }
  114. public function getSendConfirmationEmailAt(): ?string
  115. {
  116. return $this->sendConfirmationEmailAt;
  117. }
  118. public function setSendConfirmationEmailAt(?string $sendConfirmationEmailAt): self
  119. {
  120. $this->sendConfirmationEmailAt = $sendConfirmationEmailAt;
  121. return $this;
  122. }
  123. public function getName(): string
  124. {
  125. return $this->name;
  126. }
  127. public function setName(string $name): self
  128. {
  129. $this->name = $name;
  130. return $this;
  131. }
  132. public function getLegalStatus(): LegalEnum
  133. {
  134. return $this->legalStatus;
  135. }
  136. public function setLegalStatus(LegalEnum $legalStatus): self
  137. {
  138. $this->legalStatus = $legalStatus;
  139. return $this;
  140. }
  141. public function getProduct(): SettingsProductEnum
  142. {
  143. return $this->product;
  144. }
  145. public function setProduct(SettingsProductEnum $product): self
  146. {
  147. $this->product = $product;
  148. return $this;
  149. }
  150. public function getStreetAddress1(): string
  151. {
  152. return $this->streetAddress1;
  153. }
  154. public function setStreetAddress1(string $streetAddress1): self
  155. {
  156. $this->streetAddress1 = $streetAddress1;
  157. return $this;
  158. }
  159. public function getStreetAddress2(): ?string
  160. {
  161. return $this->streetAddress2;
  162. }
  163. public function setStreetAddress2(?string $streetAddress2): self
  164. {
  165. $this->streetAddress2 = $streetAddress2;
  166. return $this;
  167. }
  168. public function getStreetAddress3(): ?string
  169. {
  170. return $this->streetAddress3;
  171. }
  172. public function setStreetAddress3(?string $streetAddress3): self
  173. {
  174. $this->streetAddress3 = $streetAddress3;
  175. return $this;
  176. }
  177. public function getPostalCode(): string
  178. {
  179. return $this->postalCode;
  180. }
  181. public function setPostalCode(string $postalCode): self
  182. {
  183. $this->postalCode = $postalCode;
  184. return $this;
  185. }
  186. public function getCity(): string
  187. {
  188. return $this->city;
  189. }
  190. public function setCity(string $city): self
  191. {
  192. $this->city = $city;
  193. return $this;
  194. }
  195. public function getCountryId(): int
  196. {
  197. return $this->countryId;
  198. }
  199. public function setCountryId(int $countryId): self
  200. {
  201. $this->countryId = $countryId;
  202. return $this;
  203. }
  204. public function getPhoneNumber(): string
  205. {
  206. return $this->phoneNumber;
  207. }
  208. public function setPhoneNumber(string $phoneNumber): self
  209. {
  210. $this->phoneNumber = $phoneNumber;
  211. return $this;
  212. }
  213. public function getEmail(): string
  214. {
  215. return $this->email;
  216. }
  217. public function setEmail(string $email): self
  218. {
  219. $this->email = $email;
  220. return $this;
  221. }
  222. public function getSubdomain(): string
  223. {
  224. return $this->subdomain;
  225. }
  226. public function setSubdomain(string $subdomain): self
  227. {
  228. $this->subdomain = $subdomain;
  229. return $this;
  230. }
  231. public function getParentId(): int
  232. {
  233. return $this->parentId;
  234. }
  235. public function setParentId(int $parentId): self
  236. {
  237. $this->parentId = $parentId;
  238. return $this;
  239. }
  240. public function getPrincipalType(): PrincipalTypeEnum
  241. {
  242. return $this->principalType;
  243. }
  244. public function setPrincipalType(PrincipalTypeEnum $principalType): self
  245. {
  246. $this->principalType = $principalType;
  247. return $this;
  248. }
  249. public function getPresident(): ?OrganizationMemberCreationRequest
  250. {
  251. return $this->president;
  252. }
  253. public function setPresident(?OrganizationMemberCreationRequest $president): self
  254. {
  255. $this->president = $president;
  256. return $this;
  257. }
  258. public function getDirector(): ?OrganizationMemberCreationRequest
  259. {
  260. return $this->director;
  261. }
  262. public function setDirector(?OrganizationMemberCreationRequest $director): self
  263. {
  264. $this->director = $director;
  265. return $this;
  266. }
  267. public function getCreateWebsite(): bool
  268. {
  269. return $this->createWebsite;
  270. }
  271. public function setCreateWebsite(bool $createWebsite): self
  272. {
  273. $this->createWebsite = $createWebsite;
  274. return $this;
  275. }
  276. public function isClient(): bool
  277. {
  278. return $this->client;
  279. }
  280. public function setClient(bool $client): self
  281. {
  282. $this->client = $client;
  283. return $this;
  284. }
  285. public function isAsync(): bool
  286. {
  287. return $this->async;
  288. }
  289. public function setAsync(bool $async): self
  290. {
  291. $this->async = $async;
  292. return $this;
  293. }
  294. }