'POST', 'callback' => array( $this, 'handle' ), 'permission_callback' => array( $this->verifier, 'verify' ), ) ); } /** * Store the update. * * @param WP_REST_Request $request Signed request from the cloud. * @return WP_REST_Response|WP_Error */ public function handle( WP_REST_Request $request ) { $data = json_decode( $request->get_body(), true ); try { $update = ConnectionUpdate::from_array( is_array( $data ) ? $data : array() ); } catch ( \Throwable $e ) { return new WP_Error( 'storebridge_invalid_body', 'The connection update is invalid.', array( 'status' => 400 ) ); } $this->settings->save_connection( array( 'status' => $update->status->value, 'tiktok' => $update->tiktok?->to_array(), 'reason' => $update->reason?->to_array(), ), $update->occurred_at ); return new WP_REST_Response( null, 204 ); } }