The correct view is that it does not invalidate the fast unless there is oil or something similar on this endoscope that reaches the stomach by means of it; in that case, it invalidates the fast. It may not be used during an obligatory fast except out of necessity.
If a person has an opening in his abdomen and inserts something into his stomach through that opening, then according to the established school of law, this invalidates his fast, just as treating a penetrating abdominal wound does. The correct view, however, is that this does not invalidate the fast unless this opening has been made a substitute for the mouth, such that food and drink are introduced through it because the esophagus is blocked, ulcerated, or the like. In that case, whatever is introduced through it invalidates the fast, just as if it had been introduced through the mouth. This was the view preferred by Shaykh al-Islam Ibn Taymiyyah.
“Other than through his urethra; or if he induces vomiting, masturbates, engages in intimate contact and ejaculates, emits pre-ejaculatory fluid, or repeatedly looks and then ejaculates, ...”
His statement, “Other than through his urethra,” means the channel of the penis. Thus, if he inserts through the penis a thread bearing the taste of medicine, this does not invalidate his fast, because whatever enters by way of the penis does not reach the body cavity. Urine only comes out by seepage. This is how the jurists, may Allah have mercy on them, explained it. What they meant is that urine collects in the bladder by seepage, since it has only one outlet.
Praise be to Allah, we have no need for such explanations in the first place if we adopt the preponderant view: namely, that what invalidates the fast is eating and drinking. Whatever is introduced through the urethra is not called eating or drinking. If an enema—something introduced through the anus—does not invalidate the fast according to the preponderant view, then what enters through the urethra is even less likely to do so.
His statement, “Or if he induces vomiting,” means that he deliberately brings about vomiting. However, vomiting must actually occur. If he attempts to induce vomiting but does not vomit, then his fast is not invalidated; rather, it does not