def __init__(self, message_status, msgid, system_id, source_addr, destination_addr, sub_date, source_addr_ton, source_addr_npi, dest_addr_ton, dest_addr_npi): # ESME_* statuses are returned from SubmitSmResp # Others are returned from DeliverSm, values must be the same as Table B-2 if message_status[:5] != 'ESME_' and message_status not in [ 'DELIVRD', 'EXPIRED', 'DELETED', 'UNDELIV', 'ACCEPTD', 'UNKNOWN', 'REJECTD' ]: raise InvalidParameterError("Invalid message_status: %s" % message_status) properties = { 'message-id': msgid, 'headers': { 'try-count': 0, 'message_status': message_status, 'system_id': system_id, 'source_addr': source_addr, 'destination_addr': destination_addr, 'sub_date': str(sub_date), 'source_addr_ton': source_addr_ton, 'source_addr_npi': source_addr_npi, 'dest_addr_ton': dest_addr_ton, 'dest_addr_npi': dest_addr_npi } } Content.__init__(self, msgid, properties=properties)
def __init__(self, message_status, msgid, dlr_url, dlr_level, id_smsc='', sub='', dlvrd='', subdate='', donedate='', err='', text='', method='POST', trycount=0): # ESME_* statuses are returned from SubmitSmResp # Others are returned from DeliverSm, values must be the same as Table B-2 if message_status[:5] != 'ESME_' and message_status not in ['DELIVRD', 'EXPIRED', 'DELETED', 'UNDELIV', 'ACCEPTD', 'UNKNOWN', 'REJECTD']: raise InvalidParameterError("Invalid message_status: %s" % message_status) if dlr_level not in [1, 2, 3]: raise InvalidParameterError("Invalid dlr_level: %s" % dlr_level) if method not in ['POST', 'GET']: raise InvalidParameterError('Invalid method: %s' % method) properties = {'message-id': msgid, 'headers': {'try-count': 0, 'url': dlr_url, 'method': method, 'message_status': message_status, 'level': dlr_level, 'id_smsc': id_smsc, 'sub': sub, 'dlvrd': dlvrd, 'subdate': subdate, 'donedate': donedate, 'err': err, 'text': text}} Content.__init__(self, msgid, properties=properties)
def __init__(self, message_status, msgid, dlr_url, dlr_level, id_smsc='', sub='', dlvrd='', subdate='', donedate='', err='', text='', method='POST', trycount=0): # ESME_* statuses are returned from SubmitSmResp # Others are returned from DeliverSm, values must be the same as Table B-2 if message_status[:5] != 'ESME_' and message_status not in [ 'DELIVRD', 'EXPIRED', 'DELETED', 'UNDELIV', 'ACCEPTD', 'UNKNOWN', 'REJECTD']: raise InvalidParameterError("Invalid message_status: %s" % message_status) if dlr_level not in [1, 2, 3]: raise InvalidParameterError("Invalid dlr_level: %s" % dlr_level) if method not in ['POST', 'GET']: raise InvalidParameterError('Invalid method: %s' % method) properties = {'message-id': msgid, 'headers': {'try-count': 0, 'url': dlr_url, 'method': method, 'message_status': message_status, 'level': dlr_level, 'id_smsc': id_smsc, 'sub': sub, 'dlvrd': dlvrd, 'subdate': subdate, 'donedate': donedate, 'err': err, 'text': text}} Content.__init__(self, msgid, properties=properties)
def __init__(self, body = "", children = None, properties = None, pickleProtocol = 2, prePickle = False): self.pickleProtocol = pickleProtocol if prePickle == True: body = pickle.dumps(body, self.pickleProtocol) Content.__init__(self, body, children, properties)
def __init__(self, bid, uid, amount): if not isinstance(amount, float) and not isinstance(amount, int): raise InvalidParameterError('Amount is not float or int: %s' % amount) if amount < 0: raise InvalidParameterError('Amount cannot be a negative value: %s' % amount) properties = {'message-id': bid, 'headers': {'user-id': uid, 'amount': str(amount)}} Content.__init__(self, bid, properties=properties)
def __init__(self, body="", children=None, properties=None, pickleProtocol=2): self.pickleProtocol = pickleProtocol body = self.pickle(body) Content.__init__(self, body, children, properties)
def __init__(self, body="", children=None, properties=None, pickleProtocol=_pickle.HIGHEST_PROTOCOL): self.pickleProtocol = pickleProtocol body = self.pickle(body) Content.__init__(self, body, children, properties)
def __init__(self, body="", children=None, properties=None, pickleProtocol=2, prePickle=False): self.pickleProtocol = pickleProtocol if prePickle == True: body = pickle.dumps(body, self.pickleProtocol) Content.__init__(self, body, children, properties)
def __init__(self, body="", children=None, properties=None, pickleProtocol=2, prePickle=False): self.pickleProtocol = pickleProtocol if prePickle is True: body = pickle.dumps(body, self.pickleProtocol) # Add creation date in header if 'headers' not in properties: properties['headers'] = {} properties['headers']['created_at'] = str(datetime.datetime.now()) Content.__init__(self, body, children, properties)
def __init__(self, bid, uid, amount): if type(amount) != float and type(amount) != int: raise InvalidParameterError('Amount is not float or int: %s' % amount) if amount < 0: raise InvalidParameterError('Amount cannot be a negative value: %s' % amount) properties = {} properties['message-id'] = bid properties['headers'] = {'user-id': uid, 'amount': str(amount)} Content.__init__(self, bid, properties = properties)
def __init__(self, bid, uid, amount): if type(amount) != float and type(amount) != int: raise InvalidParameterError('Amount is not float or int: %s' % amount) if amount < 0: raise InvalidParameterError( 'Amount cannot be a negative value: %s' % amount) properties = {} properties['message-id'] = bid properties['headers'] = {'user-id': uid, 'amount': str(amount)} Content.__init__(self, bid, properties=properties)
def __init__(self, message_status, msgid, system_id, source_addr, destination_addr): properties = {} # ESME_* statuses are returned from SubmitSmResp # Others are returned from DeliverSm, values must be the same as Table B-2 if message_status[:5] != 'ESME_' and message_status not in ['DELIVRD', 'EXPIRED', 'DELETED', 'UNDELIV', 'ACCEPTD', 'UNKNOWN', 'REJECTD']: raise InvalidParameterError("Invalid message_status: %s", message_status) properties['message-id'] = msgid properties['headers'] = {'try-count': 0, 'message_status': message_status, 'system_id': system_id, 'source_addr': source_addr, 'destination_addr': destination_addr} Content.__init__(self, msgid, properties = properties)
def __init__(self, pdu_type, msgid, status, smpp_msgid=None, cid=None, dlr_details=None): if pdu_type not in (CommandId.deliver_sm, CommandId.data_sm, CommandId.submit_sm_resp): raise InvalidParameterError('Invalid pdu_type: %s' % pdu_type.name) if pdu_type == CommandId.submit_sm_resp and status == CommandStatus.ESME_ROK and smpp_msgid is None: raise InvalidParameterError( 'submit_sm_resp with ESME_ROK dlr must have smpp_msgid arg defined' ) elif pdu_type in (CommandId.deliver_sm, CommandId.data_sm) and (cid is None or dlr_details is None): raise InvalidParameterError( 'deliver_sm dlr must have cid and dlr_details args defined') properties = { 'message-id': str(msgid), 'headers': { 'type': pdu_type.name } } if pdu_type == CommandId.submit_sm_resp and smpp_msgid is not None: # smpp_msgid is used to define mapping between msgid and smpp_msgid (when receiving submit_sm_resp ESME_ROK) properties['headers']['smpp_msgid'] = smpp_msgid.decode().upper( ).lstrip('0') elif pdu_type in (CommandId.deliver_sm, CommandId.data_sm): properties['headers']['cid'] = cid for k, v in dlr_details.items(): if isinstance(v, bytes): properties['headers']['dlr_%s' % k] = v.decode() else: properties['headers']['dlr_%s' % k] = v if isinstance(status, Enum): status = status.name Content.__init__(self, status, properties=properties)
def __init__(self, pdu_type, msgid, status, smpp_msgid=None, cid=None, dlr_details=None): pdu_type_s = '%s' % pdu_type status_s = '%s' % status if pdu_type_s not in ['deliver_sm', 'data_sm', 'submit_sm_resp']: raise InvalidParameterError('Invalid pdu_type: %s' % pdu_type_s) if pdu_type_s == 'submit_sm_resp' and status_s == 'ESME_ROK' and smpp_msgid is None: raise InvalidParameterError( 'submit_sm_resp with ESME_ROK dlr must have smpp_msgid arg defined' ) elif pdu_type_s in ['deliver_sm', 'data_sm' ] and (cid is None or dlr_details is None): raise InvalidParameterError( 'deliver_sm dlr must have cid and dlr_details args defined') properties = { 'message-id': str(msgid), 'headers': { 'type': pdu_type_s } } properties['delivery-mode'] = 2 if pdu_type_s == 'submit_sm_resp' and smpp_msgid is not None: # smpp_msgid is used to define mapping between msgid and smpp_msgid (when receiving submit_sm_resp ESME_ROK) properties['headers']['smpp_msgid'] = str( smpp_msgid).upper().lstrip('0') elif pdu_type_s in ['deliver_sm', 'data_sm']: properties['headers']['cid'] = cid for k, v in dlr_details.iteritems(): properties['headers']['dlr_%s' % k] = v Content.__init__(self, status_s, properties=properties)
def __init__(self, pdu_type, msgid, status, smpp_msgid=None, cid=None, dlr_details=None): pdu_type_s = '%s' % pdu_type status_s = '%s' % status if pdu_type_s not in ['deliver_sm', 'data_sm', 'submit_sm_resp']: raise InvalidParameterError('Invalid pdu_type: %s' % pdu_type_s) if pdu_type_s == 'submit_sm_resp' and status_s == 'ESME_ROK' and smpp_msgid is None: raise InvalidParameterError('submit_sm_resp with ESME_ROK dlr must have smpp_msgid arg defined') elif pdu_type_s in ['deliver_sm', 'data_sm'] and (cid is None or dlr_details is None): raise InvalidParameterError('deliver_sm dlr must have cid and dlr_details args defined') properties = {'message-id': str(msgid), 'headers': {'type': pdu_type_s}} if pdu_type_s == 'submit_sm_resp' and smpp_msgid is not None: # smpp_msgid is used to define mapping between msgid and smpp_msgid (when receiving submit_sm_resp ESME_ROK) properties['headers']['smpp_msgid'] = str(smpp_msgid).upper().lstrip('0') elif pdu_type_s in ['deliver_sm', 'data_sm']: properties['headers']['cid'] = cid for k, v in dlr_details.iteritems(): properties['headers']['dlr_%s' % k] = v Content.__init__(self, status_s, properties=properties)