AvatarRoute.php
3 years ago
LocationRoute.php
4 years ago
PasswordRoute.php
2 years ago
ProfileRoute.php
4 years ago
Tab.php
2 years ago
LocationRoute.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonorDashboards\Tabs\EditProfileTab; |
| 4 | |
| 5 | use Give\DonorDashboards\Helpers\LocationList; |
| 6 | use Give\DonorDashboards\Tabs\Contracts\Route as RouteAbstract; |
| 7 | use WP_REST_Request; |
| 8 | |
| 9 | /** |
| 10 | * @since 2.10.0 |
| 11 | */ |
| 12 | class LocationRoute extends RouteAbstract |
| 13 | { |
| 14 | |
| 15 | /** @var string */ |
| 16 | public function endpoint() |
| 17 | { |
| 18 | return 'location'; |
| 19 | } |
| 20 | |
| 21 | public function args() |
| 22 | { |
| 23 | return [ |
| 24 | 'countryCode' => [ |
| 25 | 'type' => 'string', |
| 26 | 'required' => true, |
| 27 | 'sanitize_callback' => 'sanitize_text_field', |
| 28 | ], |
| 29 | ]; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @since 2.10.0 |
| 34 | * |
| 35 | * @param WP_REST_Request $request |
| 36 | * |
| 37 | * @return array |
| 38 | * |
| 39 | */ |
| 40 | public function handleRequest(WP_REST_Request $request) |
| 41 | { |
| 42 | return [ |
| 43 | 'states' => LocationList::getStates( |
| 44 | $request->get_param('countryCode') |
| 45 | ), |
| 46 | ]; |
| 47 | } |
| 48 | } |
| 49 |