NewStructureArtistPremiumTrialRequest.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Shop;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Post;
  7. use App\Enum\Organization\LegalEnum;
  8. use App\Enum\Organization\PrincipalTypeEnum;
  9. use App\State\Processor\Shop\NewStructureArtistPremiumTrialRequestProcessor;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12. * New structure trial request for the artist premium product.
  13. *
  14. * This API resource represents a request for a trial of the Artist Premium product for a new structure.
  15. * It contains all the information needed to create a new organization and start a premium trial:
  16. * - Structure information (name, address, email, type, legal status, etc.)
  17. * - Representative information (name, function, email, phone, etc.)
  18. * - Acceptance of terms and conditions
  19. *
  20. * The resource is exposed through API Platform for submission via a POST endpoint.
  21. */
  22. #[ApiResource(
  23. operations: [
  24. new Post(
  25. uriTemplate: '/public/shop/new-structure-artist-premium-trial-request',
  26. processor: NewStructureArtistPremiumTrialRequestProcessor::class
  27. ),
  28. ]
  29. )]
  30. class NewStructureArtistPremiumTrialRequest
  31. {
  32. /**
  33. * Id 'bidon' ajouté par défaut pour permettre la construction
  34. * de l'IRI par api platform.
  35. */
  36. #[ApiProperty(identifier: true)]
  37. private int $id = 0;
  38. #[Assert\Length(
  39. min: 2,
  40. minMessage: "Structure's name must be at least {{ limit }} characters long",
  41. )]
  42. private string $structureName;
  43. #[Assert\NotBlank]
  44. private string $address;
  45. private ?string $addressComplement = null;
  46. #[Assert\Length(
  47. min: 3,
  48. minMessage: 'Postal code must be at least {{ limit }} characters long',
  49. )]
  50. private string $postalCode;
  51. #[Assert\Length(
  52. min: 1,
  53. minMessage: 'City must be at least {{ limit }} characters long',
  54. )]
  55. private string $city;
  56. #[Assert\NotBlank]
  57. #[Assert\Email(message: 'The email {{ value }} is not a valid email.')]
  58. private string $structureEmail;
  59. private PrincipalTypeEnum $structureType;
  60. private LegalEnum $legalStatus;
  61. #[Assert\NotBlank]
  62. #[Assert\Regex(pattern: '/^[a-z0-9][a-z0-9-]{0,28}[a-z0-9]$/')]
  63. private string $structureIdentifier;
  64. #[Assert\Regex(pattern: '/^|(\d{9})$/')]
  65. private string $siren;
  66. #[Assert\Length(
  67. min: 1,
  68. minMessage: 'Representative first name must be at least {{ limit }} characters long',
  69. )]
  70. private string $representativeFirstName;
  71. #[Assert\Length(
  72. min: 1,
  73. minMessage: 'Representative last name must be at least {{ limit }} characters long',
  74. )]
  75. private string $representativeLastName;
  76. #[Assert\Length(
  77. min: 1,
  78. minMessage: 'Representative function must be at least {{ limit }} characters long',
  79. )]
  80. private string $representativeFunction;
  81. #[Assert\NotBlank]
  82. #[Assert\Email(message: 'The email {{ value }} is not a valid email.')]
  83. private string $representativeEmail;
  84. #[Assert\Length(
  85. min: 10,
  86. minMessage: 'Phone number must be at least {{ limit }} characters long',
  87. )]
  88. private string $representativePhone;
  89. #[Assert\IsTrue(message: 'terms-must-be-accepted')]
  90. private bool $termsAccepted = false;
  91. private bool $legalRepresentative = false;
  92. private bool $newsletterSubscription = false;
  93. public function getId(): int
  94. {
  95. return $this->id;
  96. }
  97. public function setId(int $id): self
  98. {
  99. $this->id = $id;
  100. return $this;
  101. }
  102. public function getStructureName(): string
  103. {
  104. return $this->structureName;
  105. }
  106. public function setStructureName(string $structureName): self
  107. {
  108. $this->structureName = $structureName;
  109. return $this;
  110. }
  111. public function getAddress(): string
  112. {
  113. return $this->address;
  114. }
  115. public function setAddress(string $address): self
  116. {
  117. $this->address = $address;
  118. return $this;
  119. }
  120. public function getAddressComplement(): ?string
  121. {
  122. return $this->addressComplement;
  123. }
  124. public function setAddressComplement(?string $addressComplement): self
  125. {
  126. $this->addressComplement = $addressComplement;
  127. return $this;
  128. }
  129. public function getPostalCode(): string
  130. {
  131. return $this->postalCode;
  132. }
  133. public function setPostalCode(string $postalCode): self
  134. {
  135. $this->postalCode = $postalCode;
  136. return $this;
  137. }
  138. public function getCity(): string
  139. {
  140. return $this->city;
  141. }
  142. public function setCity(string $city): self
  143. {
  144. $this->city = $city;
  145. return $this;
  146. }
  147. public function getStructureEmail(): string
  148. {
  149. return $this->structureEmail;
  150. }
  151. public function setStructureEmail(string $structureEmail): self
  152. {
  153. $this->structureEmail = $structureEmail;
  154. return $this;
  155. }
  156. public function getStructureType(): PrincipalTypeEnum
  157. {
  158. return $this->structureType;
  159. }
  160. public function setStructureType(PrincipalTypeEnum $structureType): self
  161. {
  162. $this->structureType = $structureType;
  163. return $this;
  164. }
  165. public function getLegalStatus(): LegalEnum
  166. {
  167. return $this->legalStatus;
  168. }
  169. public function setLegalStatus(LegalEnum $legalStatus): self
  170. {
  171. $this->legalStatus = $legalStatus;
  172. return $this;
  173. }
  174. public function getStructureIdentifier(): string
  175. {
  176. return $this->structureIdentifier;
  177. }
  178. public function setStructureIdentifier(string $structureIdentifier): self
  179. {
  180. $this->structureIdentifier = $structureIdentifier;
  181. return $this;
  182. }
  183. public function getSiren(): string
  184. {
  185. return $this->siren;
  186. }
  187. public function setSiren(string $siren): self
  188. {
  189. $this->siren = $siren;
  190. return $this;
  191. }
  192. public function getRepresentativeFirstName(): string
  193. {
  194. return $this->representativeFirstName;
  195. }
  196. public function setRepresentativeFirstName(string $representativeFirstName): self
  197. {
  198. $this->representativeFirstName = $representativeFirstName;
  199. return $this;
  200. }
  201. public function getRepresentativeLastName(): string
  202. {
  203. return $this->representativeLastName;
  204. }
  205. public function setRepresentativeLastName(string $representativeLastName): self
  206. {
  207. $this->representativeLastName = $representativeLastName;
  208. return $this;
  209. }
  210. public function getRepresentativeFunction(): string
  211. {
  212. return $this->representativeFunction;
  213. }
  214. public function setRepresentativeFunction(string $representativeFunction): self
  215. {
  216. $this->representativeFunction = $representativeFunction;
  217. return $this;
  218. }
  219. public function getRepresentativeEmail(): string
  220. {
  221. return $this->representativeEmail;
  222. }
  223. public function setRepresentativeEmail(string $representativeEmail): self
  224. {
  225. $this->representativeEmail = $representativeEmail;
  226. return $this;
  227. }
  228. public function getRepresentativePhone(): string
  229. {
  230. return $this->representativePhone;
  231. }
  232. public function setRepresentativePhone(string $representativePhone): self
  233. {
  234. $this->representativePhone = $representativePhone;
  235. return $this;
  236. }
  237. public function getTermsAccepted(): bool
  238. {
  239. return $this->termsAccepted;
  240. }
  241. public function setTermsAccepted(bool $termsAccepted): self
  242. {
  243. $this->termsAccepted = $termsAccepted;
  244. return $this;
  245. }
  246. public function getLegalRepresentative(): bool
  247. {
  248. return $this->legalRepresentative;
  249. }
  250. public function setLegalRepresentative(bool $legalRepresentative): self
  251. {
  252. $this->legalRepresentative = $legalRepresentative;
  253. return $this;
  254. }
  255. public function getNewsletterSubscription(): bool
  256. {
  257. return $this->newsletterSubscription;
  258. }
  259. public function setNewsletterSubscription(bool $newsletterSubscription): self
  260. {
  261. $this->newsletterSubscription = $newsletterSubscription;
  262. return $this;
  263. }
  264. }