CustomerProfile.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace Webkul\BagistoApi\Models;
  3. use ApiPlatform\Metadata\ApiProperty;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use ApiPlatform\Metadata\GraphQl\Query;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Webkul\BagistoApi\Resolver\CustomerQueryResolver;
  9. use ApiPlatform\OpenApi\Model\Operation;
  10. /**
  11. * Authenticated customer profile read operation
  12. */
  13. #[ApiResource(
  14. routePrefix: '/api/shop',
  15. uriTemplate: '/customer-profiles',
  16. shortName: 'CustomerProfile',
  17. paginationEnabled: false,
  18. operations: [
  19. new GetCollection(
  20. uriTemplate: '/customer-profile',
  21. provider: \Webkul\BagistoApi\State\CustomerProfileCollectionProvider::class,
  22. paginationEnabled: false,
  23. normalizationContext: [
  24. 'skip_null_values' => false,
  25. ],
  26. openapi: new Operation(
  27. tags: ['Customer'],
  28. summary: 'Get authenticated customer profile',
  29. description: 'Returns the profile of the currently authenticated customer. Requires Bearer token via the Authorize button.',
  30. responses: [
  31. '200' => new \ApiPlatform\OpenApi\Model\Response(
  32. description: 'Authenticated customer profile',
  33. content: new \ArrayObject([
  34. 'application/json' => [
  35. 'example' => [
  36. [
  37. 'id' => '1529',
  38. 'firstName' => 'Api',
  39. 'lastName' => 'Doc',
  40. 'email' => 'john@example.com',
  41. 'phone' => null,
  42. 'gender' => null,
  43. 'dateOfBirth' => null,
  44. 'status' => '1',
  45. 'subscribedToNewsLetter' => false,
  46. 'isVerified' => '0',
  47. 'isSuspended' => '0',
  48. 'image' => null,
  49. 'password' => null,
  50. 'confirmPassword' => null,
  51. 'success' => null,
  52. 'message' => null,
  53. ],
  54. ],
  55. ],
  56. ]),
  57. ),
  58. ],
  59. ),
  60. ),
  61. ],
  62. graphQlOperations: [
  63. new Query(
  64. name: 'read',
  65. resolver: CustomerQueryResolver::class,
  66. args: [],
  67. normalizationContext: [
  68. 'groups' => ['query'],
  69. ],
  70. description: 'Read authenticated customer profile using Bearer token in Authorization header. Returns the authenticated customer\'s profile data.',
  71. ),
  72. ]
  73. )]
  74. class CustomerProfile
  75. {
  76. #[ApiProperty(readable: true, writable: false, identifier: true)]
  77. #[Groups(['query'])]
  78. public ?string $id = null;
  79. #[ApiProperty(readable: true, writable: false)]
  80. #[Groups(['query', 'mutation'])]
  81. public ?string $first_name = null;
  82. #[ApiProperty(readable: true, writable: false)]
  83. #[Groups(['query', 'mutation'])]
  84. public ?string $last_name = null;
  85. #[ApiProperty(readable: true, writable: false)]
  86. #[Groups(['query', 'mutation'])]
  87. public ?string $email = null;
  88. #[ApiProperty(readable: true, writable: false)]
  89. #[Groups(['query', 'mutation'])]
  90. public ?string $phone = null;
  91. #[ApiProperty(readable: true, writable: false)]
  92. #[Groups(['query', 'mutation'])]
  93. public ?string $gender = null;
  94. #[ApiProperty(readable: true, writable: false)]
  95. #[Groups(['query', 'mutation'])]
  96. public ?string $date_of_birth = null;
  97. #[ApiProperty(readable: true, writable: false)]
  98. #[Groups(['query', 'mutation'])]
  99. public ?string $status = null;
  100. #[ApiProperty(readable: true, writable: false)]
  101. #[Groups(['query', 'mutation'])]
  102. public ?bool $subscribed_to_news_letter = null;
  103. #[ApiProperty(readable: true, writable: false)]
  104. #[Groups(['query', 'mutation'])]
  105. public ?string $is_verified = null;
  106. #[ApiProperty(readable: true, writable: false)]
  107. #[Groups(['query', 'mutation'])]
  108. public ?string $is_suspended = null;
  109. #[ApiProperty(readable: true, writable: false)]
  110. #[Groups(['query', 'mutation'])]
  111. public ?string $image = null;
  112. #[ApiProperty(readable: true, writable: false)]
  113. #[Groups(['mutation'])]
  114. public ?string $password = null;
  115. #[ApiProperty(readable: true, writable: false)]
  116. #[Groups(['mutation'])]
  117. public ?string $confirmPassword = null;
  118. #[ApiProperty(readable: true, writable: false)]
  119. #[Groups(['query', 'mutation'])]
  120. public ?bool $success = null;
  121. #[ApiProperty(readable: true, writable: false)]
  122. #[Groups(['query', 'mutation'])]
  123. public ?string $message = null;
  124. }