How to make a rigidbody move in the direction of finger(x,y,z)

For example, If I swipe the finger left, I want my rigidbody move in left direction. Please, help.

Something like this. i wrote it here directly, do check before writing in IDE. Instead of v3.left and v3.right, use the direction you want to move.

 public void OnEndDrag(PointerEventData eventData)
    {
        dragDirection = (eventData.position - eventData.pressPosition).normalized;

         bool isRight= dragDirection.x>0 ? true:false;

        switch (isRight)
        {
           case true : player.transform.GetComponet<RigidBody>().velocity = Vector3.right; break; 
           case false: player.transform.GetComponet<RigidBody>().velocity = Vector3.left; break;
        }
    }