def update_message(self, identifier, recipient_received, state): message = self.retrieve_message_by_identifier(identifier) message.recipient_received = TimestampUtility.parse(recipient_received) message.state = state updates = message.save() if updates == 1: self.logger.debug("Successfully updated message: {}".format( message.identifier)) return message else: self.logger.error("Update of message: {} returned {}".format( identifier, str(updates)))
def create(): identifier = get_jwt_identity() telemetry_parameters = request.get_json() telemetry_repository = TelemetryRepository() result = telemetry_repository.create_telemetry( Telemetry(creator=identifier, data_type=telemetry_parameters['data_type'], content=telemetry_parameters['content'], created=TimestampUtility.parse( telemetry_parameters['created']), received=TimestampUtility.now())) return Response(ResponseWrapper.wrap(identifier, 'telemetry.create', result), status=200, mimetype='application/json')
def create(): identifier = g.get('identifier', None) message_parameters = request.get_json() message_repository = MessageRepository() message = message_repository.create_message( Message(identifier=RandomUtility.random_string(32), sender=identifier, recipient=message_parameters['recipient'], content=message_parameters['content'], state=MessageState.PENDING, created=TimestampUtility.parse(message_parameters['created']), received=TimestampUtility.now(), recipient_received=None)) result = Response(ResponseWrapper.wrap(identifier, 'messages.create', message), status=200, mimetype='application/json') return result