Exemplo n.º 1
0
def checkOrderStatus(orderId):
    order = OrderModel.get(orderId)
    if order is None:
        raise Exception('order data does not exists!')
    
    result = {
        'orderStatus': order.orderStatus,
        'transactionStatus': order.transactionStatus
    }
    return result
def handler(event, context):
    print(event)

    orderId = event['orderId']
    order = OrderModel.get(orderId)

    if order is None:
        raise Exception('order data does not exists!')

    else:
        order.update(
            actions=[OrderModel.orderStatus.set(OrderStatusEnum.FAILED)])
        return 'order cancelled'
Exemplo n.º 3
0
def handler(event, context):
    orderId = event['orderId']

    order = OrderModel.get(orderId)

    if order is None:
        raise Exception('order data does not exists!')

    else:
        order.update(actions=[
            OrderModel.orderStatus.set(OrderStatusEnum.FAILED),
            OrderModel.transactionStatus.set(TransactionStatusEnum.DONE)
        ])
        return 'order failed'
Exemplo n.º 4
0
def handler(event, context):
    print(event)

    orderId = event['orderId']
    order = OrderModel.get(orderId)

    if order is None:
        raise Exception('order data does not exists!')
    
    else:
        order.update(actions=[
            OrderModel.orderStatus.set(OrderStatusEnum.SUCCEEDED)
        ])
        return 'order successfully confirmed.'
def handler(event, context):
    orderId = event['orderId']

    order = OrderModel.get(orderId)

    if order is None:
        raise Exception('order data does not exists!')

    sqs = boto3.resource('sqs')
    queue = sqs.get_queue_by_name(QueueName='jawsdays2020_demo_order_queue')
    response = queue.send_message(MessageBody=json.dumps(order.to_dict()))

    if response.get('MessageId'):
        return 'sending order confirm event'
    else:
        raise Exception('error sending message to sqs queue.')