Skip to content

Requests API

David Fialho edited this page Dec 6, 2016 · 8 revisions

The requests API provides a nice and simple interface to create requests and responses. The 3 base classes are "Request", "Response", and "Connection". The exact implementation of this classes is not very important. They are meant to abstract the communication details.

Creating a connectiong and making a request

with Connection(self.register_server_url) as connection:
            request = InviteRequest.signed(
                inviter=self,
                invitee_id=invitee_id.encode(),
                invitee_email=invitee_email,
            )

            logger.debug("Sending 'invite' request for user id='%s' "
                         "email='%s'" % (invitee_id, invitee_email))
            connection.request(request)