OrganizationCreationRequest.php 8.5 KB

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