Skip to content

Commit

Permalink
remove zone
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Mak <[email protected]>
  • Loading branch information
makandre committed Jul 11, 2020
1 parent 25471d9 commit 602eef8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
25 changes: 25 additions & 0 deletions lambda/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,28 @@ module.exports.getZone = async (userId) => {
});
});
};

module.exports.removeZone = async (userId) => {

const db = await getDB();

const params = {
Key: {
userId: {
S: userId
}
},
TableName: TABLE
};

return new Promise((resolve, reject) => {

db.deleteItem(params, (err, data) => {

if (err)
return reject(err)

resolve();
});
});
};
5 changes: 1 addition & 4 deletions lambda/impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,5 @@ module.exports.checkPickup = async (requestEnvelope) => {
};

module.exports.deZone = (requestEnvelope) => {

const userId = requestEnvelope.context.System.user.userId;

// TODO
return db.removeZone(requestEnvelope.context.System.user.userId);
};
4 changes: 2 additions & 2 deletions lambda/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ const SkillDisabledEventHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'AlexaSkillEvent.SkillDisabled';
},
handle(handlerInput) {
impl.deZone(handlerInput.requestEnvelope)
async handle(handlerInput) {
await impl.deZone(handlerInput.requestEnvelope)
},
};

Expand Down

0 comments on commit 602eef8

Please sign in to comment.