пожалуйста, прости меня, я совершенно новый в Lambda и Node.
Я пытаюсь повторить этот мерзавец, чтобы заказать пиццу с помощью кнопки AWS IoT.
Мой текущий код:
var pizzapi = require('dominos');
var myStore = new pizzapi.Store(
{
ID: 'Example'
}
);
var myAddress = new pizzapi.Address(
{
Street: 'Example',
City: 'Example',
Region: 'Example',
PostalCode: 'Example'
}
);
var myCustomer = new pizzapi.Customer(
{
firstName: 'Example',
lastName: 'Example',
address: myAddress,
phone: 'Example',
email: '[email protected]'
}
);
var order = new pizzapi.Order(
{
customer: myCustomer,
storeID: myStore.ID
}
);
var cardNumber='Example';
var cardInfo = new order.PaymentObject();
cardInfo.Amount = order.Amounts.Customer;
cardInfo.Number = cardNumber;
cardInfo.CardType = order.validateCC(cardNumber);
cardInfo.Expiration = 'Example';
cardInfo.SecurityCode = 'Example';
cardInfo.PostalCode = 'Example';
order.Payments.push(cardInfo);
function orderDominos(event, context) {
var clickType = event.clickType;
switch(clickType.toLowerCase()) {
case "single": {
order.addItem(
new pizzapi.Item(
{
code: 'P_14SCREEN',
options: {},
quantity: 1
}
)
);
break;
}
case "double": {
order.addItem(
new pizzapi.Item(
{
code: 'P_14SCREEN',
options: {},
quantity: 1
}
)
);
break;
}
case "long": {
order.addItem(
new pizzapi.Item(
{
code: 'P_14SCREEN',
options: {},
quantity: 1
}
)
);
break;
}
}
order.validate(
function(result) {
console.log("Order is Validated");
}
);
order.price(
function(result) {
console.log("Order is Priced");
}
);
order.place(
function(result) {
console.log("Price is", result.result.Order.Amounts, "\nEstimated Wait Time",result.result.Order.EstimatedWaitMinutes, "minutes");
console.log("Order placed!");
context.succeed(event);
}
);
}
exports.handler = orderDominos;