Files for connecting to the REST API of Skype for Business
- Instantiate the class with the user ID (SIP address) and password of a valid account. User Agent and Endpoint ID are both arbitrary identifiers.
Then call the
StartApplication
method
myapp = UCWAApp.UCWAApplication(userID, pwd, userAgent, endpointID)
myapp.StartApplication()
- To get the status of the user that created the application, call the UpdateTasks method on your app with the 'presence' qualifier:
Mystatus = myapp.UpdateTasks('presence')
This returns a JSON object and current status is found in the ['availability'] resource.
- To set the user status, call the UpdateTasks method with the 'presence' qualifier and pass an option that is available from the MS SFB list.
myapp.UpdateTasks('presence', 'Busy')
- To get the status of a contact, pass the SIP address of the contact to the GetPresence method:
status = myapp.GetPresence('somename@mydomain.com')
This returns a JSON object and status can be found under the ['availability'] key
- To send a message you must first open the messaging channel with the StartMessaging method:
message = myapp.StartMessaging(UserDict.get(person)['sip'])
-
If successful, this will return a list of possible options which are: conversation, self, sendMessage, setIsTyping, stopMessaging, typingParticipants. It is possible for the recipient to cancel the request, which will return an NoneType object.
-
Sending a string object to the sendMessage resource will send the message to the open conversation:
myapp.Messaging(status, 'sendMessage', message='this is a new message.')
Note: It is advisable to wrap this in some logic that handles a NoneType response
- Upon finishing communications, it is important to stop the messaging channel with
myapp.Messaging(status, 'stopMessaging')