Wiring Optical Encoder according to datasheet
The encoder works by breaking the path of light from the LED, the diode in the encoder to the photo-transistors (the things beside the caps).

A slotted or printed glass disk turns interrupting the light between them.



When lit the transistors turn on, acting sort of like switches.

There are two sensors positioned to provide quadrature.