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