It just does the same things the official client does. The fact that it's a REST API makes inspecting the traffic relatively easy, although that trades off efficiency compared to the custom protocols that a lot of early IM clients used.
Note that the resemblance to Skype (and even references to Skype in the source code) are not coincidences; Teams is AFAIK largely based on the same backend as MS-Skype.
Early teams was fully compatible with skype for business, they were 2 front ends for the same API. The API has changed a lot since then but the very basic things are still skype-themed
Note that the resemblance to Skype (and even references to Skype in the source code) are not coincidences; Teams is AFAIK largely based on the same backend as MS-Skype.