get( 'service_id' ); $apiTokenData = $data->get( 'api_token' ); $authorize = function ( $serviceId ) use ( $apiTokenData ) { $authorization = ( new AuthorizationFactory )->create(); try { $authorization->authorize( (object) Obj::pickBy( Logic::isNotEmpty(), $apiTokenData ) ); return Either::of( $serviceId ); } catch ( \Exception $e ) { $authorization->deauthorize(); return Either::left( $e->getMessage() ); } }; return Either::of( $serviceId ) ->chain( [ Select::class, 'select' ] ) ->chain( $authorize ); } }