-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
28 lines (24 loc) · 915 Bytes
/
index.js
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
/*!
* db-tickets
* ISC Licensed
*/
import {queryTicket as rqorderdetails} from './lib/queryTicket.js'
import findTicket from './lib/findTicket.js'
/**
* queryTicket function, returns the ticket data based on the ticket number and last name. handles both old and new ticket system
* @param string | DB ticket number (ticket number up 12 digits or 6 characters)
* @param lastName | last name of purchaser
* @return Promise | fulfills with an object that contains the ticket data
*/
const queryTicket = async (ticketNumber, lastName) => {
//create a null kwid variable
let kwid = null
if (ticketNumber.length > 5) {
const order = await findTicket(ticketNumber, lastName)
//extract the kwid from the order object
kwid = order.kwid
}
const ticketData = await rqorderdetails(ticketNumber, lastName, kwid)
return ticketData
}
export default queryTicket