PKx(HU'.format( text=self.uuid() ) class Message(BaseLayerResponse): """ The response returned by the API when a message is sent. """ def __init__(self, id, url, sent_at=None, sender=None, conversation=None, parts=None, recipient_status=None): super(Message, self).__init__(id, url) self.sent_at = sent_at self.sender = sender self.conversation = conversation self.parts = parts self.recipient_status = recipient_status @staticmethod def from_dict(dict_data): return Message( dict_data.get('id'), dict_data.get('url'), Message.parse_date(dict_data.get('sent_at')), Sender.from_dict(dict_data.get('sender')), Conversation.from_dict(dict_data.get('conversation')), [ MessagePart.from_dict(part) for part in dict_data.get('parts', []) ], dict_data.get('recipient_status'), ) def __repr__(self): return ''.format( uuid=self.uuid() ) class Sender: """ Used for sending messages. Id and Name may both be set, but the send_message API will prefer one over the other. """ def __init__(self, id=None, name=None): self.id = id self.name = name if not id and not name: raise ValueError("A sender must have at least one of ID or Name") @staticmethod def from_dict(dict_data): if not dict_data: return None return Sender( id=dict_data.get('user_id'), name=dict_data.get('name'), ) def __repr__(self): return ''.format( id=self.id, name=self.name, ) def as_dict(self): # If both ID and name are set, we will default to only the ID. # The layer platform explicitly prohibits sending both. if self.id: return { 'user_id': self.id, } return { 'name': self.name, } class MessagePart: """ A message chunk, as used for sending messages. Message chunks are currently limited to 2KiB by Layer. If a message is larger, it must be broken into several chunks. By default, chunks are text/plain but can be any format. Messages that are non-text (e.g. images) can be sent as base64. In this case, the encoding field must be set. """ def __init__(self, body, mime=MIME_TEXT_PLAIN, encoding=None): self.body = body self.mime_type = mime self.encoding = encoding @staticmethod def from_dict(dict_data): return MessagePart( dict_data.get('body'), dict_data.get('mime_type'), dict_data.get('encoding'), ) def __repr__(self): return ( '' .format( body=self.body, mime=' Content-Type: {0}'.format(self.mime_type), encoding=( ' Encoding: {0}'.format(self.encoding) if self.encoding else '' ) ) ) def as_dict(self): data = { 'body': self.body, 'mime_type': self.mime_type, } if self.encoding: data['encoding'] = self.encoding return data class PushNotification: """ Details for a push notification sent as part of a conversation message. Each push notification must have a body. Sound and recipients are optional. For Android, the sound parameter is simply sent to the client as a string. The recipients field is a map of user id to PushNotification object, allowing for one push notification to have custom settings for certain users. PushNotification instances used as part of the recipients field should not themselves have the recipient field set. """ def __init__(self, text, sound=None, recipients=None): self.text = text self.sound = sound self.recipients = recipients def __repr__(self): return ''.format( text=self.text ) def as_dict(self): data = { 'text': self.text, } if self.sound: data['sound'] = self.sound if not self.recipients: return data # If per-recipient push notification instances are present, convert # them to dictionaries as well. We don't simply recurse here to # ensure that we do not have child PushNotifications with their own # recipients fields. recipients_dict = {} try: recipients_iter = self.recipients.iteritems() pass except AttributeError: # Raised an atribute error must be using python3 recipients_iter = self.recipients.items() pass for recipient, notification in recipients_iter: recipients_dict[recipient] = { 'text': notification.text, 'sound': notification.sound, } data['recipients'] = recipients_dict return data class Conversation(BaseLayerResponse): """ Represents a Layer conversation. Returned by the get_ and create_ conversation methods. """ def __init__(self, id, url, messages_url=None, created_at=None, participants=None, distinct=False, metadata=None): super(Conversation, self).__init__(id, url) self.messages_url = messages_url self.created_at = created_at self.participants = participants if participants else [] self.distinct = distinct self.metadata = metadata def as_dict(self): return { 'id': self.id, 'url': self.url, 'messages_url': self.messages_url, 'created_at': self.created_at, 'participants': self.participants, 'distinct': self.distinct, 'metadata': self.metadata, } @staticmethod def from_dict(dict_data): return Conversation( dict_data.get('id'), dict_data.get('url'), dict_data.get('messages_url'), Conversation.parse_date(dict_data.get('created_at')), dict_data.get('participants'), dict_data.get('distinct'), dict_data.get('metadata'), ) def __repr__(self): return ''.format( uuid=self.uuid() ) PK}GLayerClient/__init__.pyPKWy(H^- +LayerClient-0.1.5.dist-info/DESCRIPTION.rstUNKNOWN PKWy(H}s:>>)LayerClient-0.1.5.dist-info/metadata.json{"classifiers": ["Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Topic :: Software Development :: Libraries :: Python Modules", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3"], "extensions": {"python.details": {"contacts": [{"email": "opensource@jana.com", "name": "Jana", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/Jana-Mobile/layer-python"}}}, "extras": [], "generator": "bdist_wheel (0.26.0)", "license": "Apache 2.0", "metadata_version": "2.0", "name": "LayerClient", "run_requires": [{"requires": ["python-dateutil", "requests"]}], "summary": "Client for the Layer Platform API", "version": "0.1.5"}PKWy(HV )LayerClient-0.1.5.dist-info/top_level.txtLayerClient PKWy(H''\\!LayerClient-0.1.5.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.26.0) Root-Is-Purelib: true Tag: py2-none-any PKWy(HG%$LayerClient-0.1.5.dist-info/METADATAMetadata-Version: 2.0 Name: LayerClient Version: 0.1.5 Summary: Client for the Layer Platform API Home-page: https://github.com/Jana-Mobile/layer-python Author: Jana Author-email: opensource@jana.com License: Apache 2.0 Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Requires-Dist: python-dateutil Requires-Dist: requests UNKNOWN PKWy(H[a"LayerClient-0.1.5.dist-info/RECORDLayerClient/LayerClient.py,sha256=bWE162Z3ifdkpBalcFZN_0Z3YCYntWhWjn9sMO-7WL0,16700 LayerClient/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 LayerClient-0.1.5.dist-info/DESCRIPTION.rst,sha256=OCTuuN6LcWulhHS3d5rfjdsQtW22n7HENFRh6jC6ego,10 LayerClient-0.1.5.dist-info/METADATA,sha256=hDFUmlFqG6AwRI9ZzvO07oDjfDfVfH4JZ2kpF88a_uA,676 LayerClient-0.1.5.dist-info/RECORD,, LayerClient-0.1.5.dist-info/WHEEL,sha256=JTb7YztR8fkPg6aSjc571Q4eiVHCwmUDlX8PhuuqIIE,92 LayerClient-0.1.5.dist-info/metadata.json,sha256=jc9M_ZqLB5-hxUsEeFhfkULkiWSXlNsxILA0BTa2-rM,830 LayerClient-0.1.5.dist-info/top_level.txt,sha256=Z6arfgI8xgCpceKMvw7-qkzLkScdQmq4qqLneFQBwAs,12 PKx(HU>)ALayerClient-0.1.5.dist-info/metadata.jsonPKWy(HV )ELayerClient-0.1.5.dist-info/top_level.txtPKWy(H''\\!ELayerClient-0.1.5.dist-info/WHEELPKWy(HG%$oFLayerClient-0.1.5.dist-info/METADATAPKWy(H[a"UILayerClient-0.1.5.dist-info/RECORDPK:L