__init__.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2014 OpenMarket Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. def threePidAssocFromDict(d):
  16. assoc = ThreepidAssociation(d['medium'], d['address'], d['mxid'], d['ts'], d['not_before'], d['not_after'])
  17. return assoc
  18. class ThreepidAssociation:
  19. def __init__(self, medium, address, mxid, ts, not_before, not_after):
  20. """
  21. :param medium: The medium of the 3pid (eg. email).
  22. :type medium: str
  23. :param address: The identifier (eg. email address).
  24. :type address: str
  25. :param mxid: The matrix ID the 3pid is associated with.
  26. :type mxid: str
  27. :param ts: The creation timestamp of this association, ms.
  28. :type ts: int
  29. :param not_before: The timestamp, in ms, at which this association
  30. becomes valid.
  31. :type not_before: int
  32. :param not_after: The timestamp, in ms, at which this association
  33. ceases to be valid.
  34. :type not_after: int
  35. """
  36. self.medium = medium
  37. self.address = address
  38. self.mxid = mxid
  39. self.ts = ts
  40. self.not_before = not_before
  41. self.not_after = not_after
  42. self.extra_fields = {}