assistant-deliveroo
Advanced tools
Comparing version 1.0.1 to 1.1.0
const Deliveroo = require("node-deliveroo"); | ||
const dayjs = require("dayjs"); | ||
const relativeTime = require("dayjs/plugin/relativeTime"); | ||
const deliveroo = new Deliveroo(); | ||
dayjs.extend(relativeTime); | ||
class AssistantDeliveroo { | ||
@@ -43,11 +47,7 @@ constructor({ accessToken, userId, updateInterval }) { | ||
const history = await deliveroo.getHistory(userId); | ||
const lastOrder = history.orders && history.orders.length >= 1 | ||
? history.orders[0].consumer_status | ||
: null; | ||
if (typeof lastOrder !== 'object') { | ||
if ( | ||
lastOrder.code === "COMPLETE" || | ||
lastOrder.code === "FAIL" | ||
) { | ||
const isFail = this.current_step.code === "FAIL"; | ||
const lastOrder = history.orders ? history.orders[0] : null; | ||
if (lastOrder) { | ||
const { status, estimated_delivery_at } = lastOrder; | ||
if (status === "DELIVERED" || status === "FAIL") { | ||
const isFail = status === "FAIL"; | ||
this.tryNotify( | ||
@@ -57,7 +57,8 @@ `Votre commande ${isFail ? "a échoué" : "est terminée"}.` | ||
clearInterval(interval); | ||
} | ||
else if (lastOrder.current_step !== this.current_step.current_step) { | ||
} else if (status !== this.current_step.status) { | ||
this.setCurrentStep(lastOrder); | ||
this.tryNotify( | ||
`Votre livraison en est à l'étape: ${lastOrder.title}, elle arrivera dans ${lastOrder.eta_minutes} minutes.` | ||
`Votre livraison en est à l'étape: ${status}, elle arrivera dans ${dayjs( | ||
estimated_delivery_at | ||
).fromNow(true)}.` | ||
); | ||
@@ -64,0 +65,0 @@ } |
{ | ||
"name": "assistant-deliveroo", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Un plugin Deliveroo pour assistant-plugins", | ||
@@ -10,4 +10,5 @@ "author": "Jérémie Zarca <jeremie.zarca@gmail.com>", | ||
"dependencies": { | ||
"dayjs": "^1.10.2", | ||
"node-deliveroo": "^1.1.3" | ||
} | ||
} |
@@ -18,3 +18,3 @@ # assistant-deliveroo | ||
Deux paramètres sont obligatoires : `email` et `password`, qui correspondent à vos identifiants [Deliveroo](https://deliveroo.fr/). | ||
Deux paramètres sont obligatoires : `accessToken` et `userId`, et vous pouvez également définir l'intervalle de mise à jour du traqueur `updateInterval` (en ms). | ||
@@ -21,0 +21,0 @@ ## Utilisation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5821
2
+ Addeddayjs@^1.10.2
+ Addeddayjs@1.11.13(transitive)