Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import Is from "strong-type";
import { getTracking } from "../utils/api-json.js";
import urls from "../utils/urls.js";
import {DominosFormat} from './DominosFormat.js';
const is=new Is;
class Tracking extends DominosFormat{
constructor(){
super();
return this;
}
get dominosPhoneAPIResult(){
return this.#dominosPhoneAPIResult;
}
get dominosAPIResult(){
return this.#dominosAPIResult;
}
#dominosPhoneAPIResult={}
#dominosAPIResult={}
async byPhone(phone) {
is.string(phone);
const url=`${urls.trackRoot}${urls.track}?phonenumber=${phone}`;
//console.log(url)
this.#dominosPhoneAPIResult=await getTracking(url);
//console.dir(this.dominosPhoneAPIResult,{depth:10});
//Actions is an array should probably loop through
//for now it is available on tracking.dominosPhoneAPIResult
try{
is.object(this.#dominosPhoneAPIResult[0]);
}catch(err){
throw new DominosTrackingError('No results found;');
}
const trackingURL=`${urls.trackRoot}${this.#dominosPhoneAPIResult[0].Actions.Track}`;
this.#dominosAPIResult=await getTracking(trackingURL);
this.formatted=this.#dominosAPIResult;
//console.dir(this.dominosAPIResult,{depth:10});
return this;
}
//canada still uses the classic method
async byPhoneClassic(phone) {
//you will need to parse this
//with something like xml2js
this.#dominosPhoneAPIResult=await get(`${urls.track}Phone=${phone}`);
return this;
}
}
export {
Tracking as default,
Tracking
} |