dispatch-node-sdk
Advanced tools
Comparing version 0.0.49 to 0.0.50
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -14,6 +16,2 @@ | ||
var _moment = require('moment'); | ||
var _moment2 = _interopRequireDefault(_moment); | ||
var _generateUUID = require('./generateUUID'); | ||
@@ -631,89 +629,128 @@ | ||
var customers = void 0; | ||
var host = void 0; | ||
var jobs = void 0; | ||
var jobOffers = void 0; | ||
var jobIds = void 0; | ||
var jobOfferIds = void 0; | ||
var totalResults = void 0; | ||
function getNextAppointmentTime(appointment) { | ||
var time = appointment.window_start_time ? appointment.window_start_time[0] : appointment.time_at; | ||
return (0, _moment2.default)(time).format('M/DD/YYYY @ h:mm a'); | ||
return appointment.window_start_time ? appointment.window_start_time[0] : appointment.time; | ||
} | ||
var filterQuery = filter ? '&models=' + filter.join(',') : ''; | ||
return this.getAuthClient().get('/v1/search?organization_id=' + organizationID + '&q=' + query + '&limit=' + maxResultsPerModel + filterQuery).then(function (response) { | ||
customers = response.customer && response.customer.hits || []; | ||
customers = customers.map(function (customer) { | ||
return _underscore2.default.pick(customer, 'id', 'first_name', 'last_name', 'full_name', 'phone_number', 'email', 'home_address'); | ||
function getMatchedWordsForFields(matches, fields) { | ||
var results = {}; | ||
fields.forEach(function (field) { | ||
results[field] = matches[field] && matches[field].matchedWords || []; | ||
}); | ||
return results; | ||
} | ||
jobIds = _underscore2.default.pluck(response.job && response.job.hits || [], 'id'); | ||
jobOfferIds = _underscore2.default.pluck(response.job_offer && response.job_offer.hits || [], 'id'); | ||
function getJobWords(result) { | ||
var matches = result._highlightResult; // eslint-disable-line no-underscore-dangle | ||
if (!matches) return {}; | ||
var totalCustomers = response.customer && response.customer.nbHits || 0; | ||
var totalJobs = response.job && response.job.nbHits || 0; | ||
var totalJobOffers = response.job_offer && response.job_offer.nbHits || 0; | ||
return getMatchedWordsForFields(matches, ['address_text', 'customer_email', 'customer_full_name', 'customer_phone_number', 'description', 'service_type', 'source', 'status', 'title']); | ||
} | ||
// Store the total result count | ||
totalResults = totalCustomers + totalJobs + totalJobOffers; | ||
function getJobOfferWords(result, primaryPhoneNumber) { | ||
var matches = result._highlightResult; // eslint-disable-line no-underscore-dangle | ||
if (!matches) return {}; | ||
if (jobIds.length === 0) return { jobs: [] }; | ||
return _this7.getAuthClient().get('/v1/jobs?filter[id_in]=' + jobIds.join(',')); | ||
}).then(function (_ref2) { | ||
var apiJobs = _ref2.jobs; | ||
// There is a possibility these could be null so we can't use destructuring with defaults. | ||
var job = matches.job || {}; | ||
var customer = matches.customer || {}; | ||
var account = matches.account || {}; | ||
jobs = apiJobs; | ||
var phoneNumberMatches = []; | ||
if (Array.isArray(customer.phone_numbers)) { | ||
var primary = customer.phone_numbers.find(function (obj) { | ||
return obj.number.value === primaryPhoneNumber; | ||
}); | ||
phoneNumberMatches = primary && primary.number.matchedWords || []; | ||
} | ||
if (jobs.length === 0) return { appointments: [] }; | ||
return _this7.getAuthClient().get('/v1/appointments?filter[job_id_in]=' + jobIds.join(',')); | ||
}).then(function (_ref3) { | ||
var appointments = _ref3.appointments; | ||
return _extends({}, getMatchedWordsForFields(job, ['address_text', 'description', 'service_type', 'title']), getMatchedWordsForFields(matches, ['status']), { | ||
var userIds = []; | ||
// These are strange and cannot use getMatchedWordsForFields | ||
customer_email: customer.email && customer.email.matchedWords || [], | ||
customer_full_name: customer.full_name && customer.full_name.matchedWords || [], | ||
customer_phone_number: phoneNumberMatches, | ||
source: account.name && account.name.matchedWords || [] | ||
}); | ||
} | ||
(appointments || []).forEach(function (appointment) { | ||
// TODO logic is supposed to select next upcoming or most recent | ||
var job = _underscore2.default.findWhere(jobs, { id: appointment.job_id }); | ||
if (job) { | ||
job.nextAppointment = getNextAppointmentTime(appointment); | ||
function getCustomerWords(result) { | ||
var matches = result._highlightResult; // eslint-disable-line no-underscore-dangle | ||
if (!matches) return {}; | ||
if (appointment.user_id) { | ||
job.user_id = appointment.user_id; | ||
userIds.push(appointment.user_id); | ||
} | ||
} else { | ||
console.error('Job not found matching appt job_id'); | ||
} | ||
return getMatchedWordsForFields(matches, ['company_name', 'email', 'full_name', 'home_address_text']); | ||
} | ||
var filterQuery = filter ? '&models=' + filter.join(',') : ''; | ||
var limitQuery = maxResultsPerModel ? '&limit=' + maxResultsPerModel : ''; | ||
var jobProps = ['address_text', 'customer_email', 'customer_full_name', 'customer_id', 'customer_phone_number', 'description', 'id', 'labels', 'organization_id', 'service_type', 'source', 'source_id', 'status', 'status_message', 'title']; | ||
return this.getAuthClient().get('/v1/search?organization_id=' + organizationID + '&q=' + query + limitQuery + filterQuery).then(function (response) { | ||
host = _this7.authClient.host.replace('https://api', 'https://files-api'); | ||
// Build customers object for returning | ||
customers = response.customer && response.customer.hits || []; | ||
customers = customers.map(function (customer) { | ||
return _extends({}, _underscore2.default.omit(customer, '_highlightResult'), { | ||
_matchedWords: getCustomerWords(customer) | ||
}); | ||
}); | ||
if (userIds.length === 0) return { users: [] }; | ||
return _this7.getAuthClient().get('/v1/users?filter[id_in]=' + userIds.join(',')); | ||
}).then(function (_ref4) { | ||
var users = _ref4.users; | ||
// Build jobOffers object for returning. | ||
// We make this match the jobs object as much as possible. | ||
jobOffers = response.job_offer && response.job_offer.hits || []; | ||
jobOffers = jobOffers.map(function (offer) { | ||
// There is a possibility these could be null so we can't use destructuring with defaults. | ||
var job = offer.job || {}; | ||
var customer = offer.customer || {}; | ||
var account = offer.account || {}; | ||
(users || []).forEach(function (user) { | ||
var job = _underscore2.default.findWhere(jobs, { user_id: user.id }); | ||
if (job) { | ||
job.technicianName = user.full_name; | ||
delete job.user_id; | ||
var appointment = offer.appointment && !_underscore2.default.isEmpty(offer.appointment) && getNextAppointmentTime(offer.appointment); | ||
var primaryPhoneNumber = void 0; | ||
if (Array.isArray(customer.phone_numbers)) { | ||
var primary = _underscore2.default.findWhere(customer.phone_numbers, { primary: true }); | ||
primaryPhoneNumber = primary && primary.number; | ||
} | ||
}); | ||
if (jobOfferIds.length === 0) return { organization_job_offers: [] }; | ||
return _this7.getAuthClient().get('/v1/organizations/' + organizationID + '/job_offers?filter[id_in]=' + jobOfferIds.join(',')); | ||
}).then(function (_ref5) { | ||
var apiJobOffers = _ref5.organization_job_offers; | ||
var words = getJobOfferWords(offer, primaryPhoneNumber); | ||
jobOffers = apiJobOffers.map(function (offer) { | ||
return { | ||
id: offer.id, | ||
title: offer.job.title, | ||
return _extends({}, _underscore2.default.pick(offer, 'id', 'organization_id', 'status'), _underscore2.default.pick(job, 'address_text', 'description', 'service_type', 'title'), { | ||
account_logo_token: account.logo_token, | ||
appointment: appointment, | ||
brand_logo: account.logo_token && host + '/v1/datafiles/' + account.logo_token, | ||
customer_email: customer.email, | ||
customer_full_name: customer.full_name, | ||
customer_phone_number: primaryPhoneNumber, | ||
source: account.name, | ||
source_id: offer.account_id, | ||
customer: offer.customer, | ||
address: offer.job.address, | ||
nextAppointment: offer.appointment ? getNextAppointmentTime(offer.appointment) : undefined | ||
}; | ||
_matchedWords: words | ||
}); | ||
}); | ||
// Build jobs object for returning. | ||
// We make this match the jobOffers object as much as possible. | ||
jobs = response.job && response.job.hits || []; | ||
jobs = jobs.map(function (job) { | ||
var words = getJobWords(job); | ||
var appointment = job.next_scheduled_appointment && !_underscore2.default.isEmpty(job.next_scheduled_appointment) && getNextAppointmentTime(job.next_scheduled_appointment); | ||
return _extends({}, _underscore2.default.pick(job, jobProps), { | ||
account_logo_token: job.logo_token, | ||
appointment: appointment, | ||
brand_logo: job.logo_token && host + '/v1/datafiles/' + job.logo_token, | ||
user_id: job.next_scheduled_appointment && job.next_scheduled_appointment.user_id, | ||
_matchedWords: words | ||
}); | ||
}); | ||
var totalCustomers = response.customer && response.customer.nbHits || 0; | ||
var totalJobs = response.job && response.job.nbHits || 0; | ||
var totalJobOffers = response.job_offer && response.job_offer.nbHits || 0; | ||
return { | ||
@@ -724,3 +761,3 @@ customers: customers, | ||
jobOffers: jobOffers, | ||
totalResults: totalResults | ||
totalResults: totalCustomers + totalJobs + totalJobOffers | ||
}; | ||
@@ -727,0 +764,0 @@ }); |
import _ from 'underscore'; | ||
import moment from 'moment'; | ||
import generateUUID from './generateUUID'; | ||
@@ -377,5 +376,8 @@ import RawClient, { AUTH_MODE_NONE, AUTH_MODE_BEARER } from './rawClient'; | ||
if (this.refreshToken) { | ||
this.exchangeToken().then(() => { | ||
return req.do(this.getAuthClient()); | ||
}).then(resolve).catch(reject); | ||
this.exchangeToken() | ||
.then(() => { | ||
return req.do(this.getAuthClient()); | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
} else { | ||
@@ -445,84 +447,173 @@ reject(err); | ||
let customers; | ||
let host; | ||
let jobs; | ||
let jobOffers; | ||
let jobIds; | ||
let jobOfferIds; | ||
let totalResults; | ||
function getNextAppointmentTime(appointment) { | ||
const time = appointment.window_start_time ? appointment.window_start_time[0] : appointment.time_at; | ||
return moment(time).format('M/DD/YYYY @ h:mm a'); | ||
return appointment.window_start_time ? appointment.window_start_time[0] : appointment.time; | ||
} | ||
const filterQuery = filter ? `&models=${filter.join(',')}` : ''; | ||
function getMatchedWordsForFields(matches, fields) { | ||
const results = {}; | ||
fields.forEach(field => { | ||
results[field] = matches[field] && matches[field].matchedWords || []; | ||
}); | ||
return results; | ||
} | ||
return this.getAuthClient().get(`/v1/search?organization_id=${organizationID}&q=${query}&limit=${maxResultsPerModel}${filterQuery}`) | ||
.then(response => { | ||
customers = response.customer && response.customer.hits || []; | ||
customers = customers.map(customer => _.pick(customer, 'id', 'first_name', 'last_name', 'full_name', 'phone_number', 'email', 'home_address')); | ||
function getJobWords(result) { | ||
const matches = result._highlightResult; // eslint-disable-line no-underscore-dangle | ||
if (!matches) return {}; | ||
jobIds = _.pluck(response.job && response.job.hits || [], 'id'); | ||
jobOfferIds = _.pluck(response.job_offer && response.job_offer.hits || [], 'id'); | ||
return getMatchedWordsForFields(matches, [ | ||
'address_text', | ||
'customer_email', | ||
'customer_full_name', | ||
'customer_phone_number', | ||
'description', | ||
'service_type', | ||
'source', | ||
'status', | ||
'title', | ||
]); | ||
} | ||
const totalCustomers = response.customer && response.customer.nbHits || 0; | ||
const totalJobs = response.job && response.job.nbHits || 0; | ||
const totalJobOffers = response.job_offer && response.job_offer.nbHits || 0; | ||
function getJobOfferWords(result, primaryPhoneNumber) { | ||
const matches = result._highlightResult; // eslint-disable-line no-underscore-dangle | ||
if (!matches) return {}; | ||
// Store the total result count | ||
totalResults = totalCustomers + totalJobs + totalJobOffers; | ||
// There is a possibility these could be null so we can't use destructuring with defaults. | ||
const job = matches.job || {}; | ||
const customer = matches.customer || {}; | ||
const account = matches.account || {}; | ||
if (jobIds.length === 0) return { jobs: [] }; | ||
return this.getAuthClient().get(`/v1/jobs?filter[id_in]=${jobIds.join(',')}`); | ||
}) | ||
.then(({ jobs: apiJobs }) => { | ||
jobs = apiJobs; | ||
let phoneNumberMatches = []; | ||
if (Array.isArray(customer.phone_numbers)) { | ||
const primary = customer.phone_numbers.find(obj => obj.number.value === primaryPhoneNumber); | ||
phoneNumberMatches = primary && primary.number.matchedWords || []; | ||
} | ||
if (jobs.length === 0) return { appointments: [] }; | ||
return this.getAuthClient().get(`/v1/appointments?filter[job_id_in]=${jobIds.join(',')}`); | ||
}) | ||
.then(({ appointments }) => { | ||
const userIds = []; | ||
return { | ||
...getMatchedWordsForFields(job, [ | ||
'address_text', | ||
'description', | ||
'service_type', | ||
'title', | ||
]), | ||
...getMatchedWordsForFields(matches, ['status']), | ||
(appointments || []).forEach(appointment => { | ||
// TODO logic is supposed to select next upcoming or most recent | ||
const job = _.findWhere(jobs, { id: appointment.job_id }); | ||
if (job) { | ||
job.nextAppointment = getNextAppointmentTime(appointment); | ||
// These are strange and cannot use getMatchedWordsForFields | ||
customer_email: customer.email && customer.email.matchedWords || [], | ||
customer_full_name: customer.full_name && customer.full_name.matchedWords || [], | ||
customer_phone_number: phoneNumberMatches, | ||
source: account.name && account.name.matchedWords || [], | ||
}; | ||
} | ||
if (appointment.user_id) { | ||
job.user_id = appointment.user_id; | ||
userIds.push(appointment.user_id); | ||
} | ||
} else { | ||
console.error('Job not found matching appt job_id'); | ||
} | ||
function getCustomerWords(result) { | ||
const matches = result._highlightResult; // eslint-disable-line no-underscore-dangle | ||
if (!matches) return {}; | ||
return getMatchedWordsForFields(matches, [ | ||
'company_name', | ||
'email', | ||
'full_name', | ||
'home_address_text', | ||
]); | ||
} | ||
const filterQuery = filter ? `&models=${filter.join(',')}` : ''; | ||
const limitQuery = maxResultsPerModel ? `&limit=${maxResultsPerModel}` : ''; | ||
const jobProps = [ | ||
'address_text', | ||
'customer_email', | ||
'customer_full_name', | ||
'customer_id', | ||
'customer_phone_number', | ||
'description', | ||
'id', | ||
'labels', | ||
'organization_id', | ||
'service_type', | ||
'source', | ||
'source_id', | ||
'status', | ||
'status_message', | ||
'title', | ||
]; | ||
return this.getAuthClient().get(`/v1/search?organization_id=${organizationID}&q=${query}${limitQuery}${filterQuery}`) | ||
.then(response => { | ||
host = this.authClient.host.replace('https://api', 'https://files-api'); | ||
// Build customers object for returning | ||
customers = response.customer && response.customer.hits || []; | ||
customers = customers.map(customer => { | ||
return { | ||
..._.omit(customer, '_highlightResult'), | ||
_matchedWords: getCustomerWords(customer), | ||
}; | ||
}); | ||
if (userIds.length === 0) return { users: [] }; | ||
return this.getAuthClient().get(`/v1/users?filter[id_in]=${userIds.join(',')}`); | ||
}) | ||
.then(({ users }) => { | ||
(users || []).forEach(user => { | ||
const job = _.findWhere(jobs, { user_id: user.id }); | ||
if (job) { | ||
job.technicianName = user.full_name; | ||
delete job.user_id; | ||
// Build jobOffers object for returning. | ||
// We make this match the jobs object as much as possible. | ||
jobOffers = response.job_offer && response.job_offer.hits || []; | ||
jobOffers = jobOffers.map(offer => { | ||
// There is a possibility these could be null so we can't use destructuring with defaults. | ||
const job = offer.job || {}; | ||
const customer = offer.customer || {}; | ||
const account = offer.account || {}; | ||
const appointment = offer.appointment && | ||
!_.isEmpty(offer.appointment) && | ||
getNextAppointmentTime(offer.appointment); | ||
let primaryPhoneNumber; | ||
if (Array.isArray(customer.phone_numbers)) { | ||
const primary = _.findWhere(customer.phone_numbers, { primary: true }); | ||
primaryPhoneNumber = primary && primary.number; | ||
} | ||
}); | ||
if (jobOfferIds.length === 0) return { organization_job_offers: [] }; | ||
return this.getAuthClient().get(`/v1/organizations/${organizationID}/job_offers?filter[id_in]=${jobOfferIds.join(',')}`); | ||
}) | ||
.then(({ organization_job_offers: apiJobOffers }) => { | ||
jobOffers = apiJobOffers.map(offer => { | ||
const words = getJobOfferWords(offer, primaryPhoneNumber); | ||
return { | ||
id: offer.id, | ||
title: offer.job.title, | ||
..._.pick(offer, 'id', 'organization_id', 'status'), | ||
..._.pick(job, 'address_text', 'description', 'service_type', 'title'), | ||
account_logo_token: account.logo_token, | ||
appointment, | ||
brand_logo: account.logo_token && `${host}/v1/datafiles/${account.logo_token}`, | ||
customer_email: customer.email, | ||
customer_full_name: customer.full_name, | ||
customer_phone_number: primaryPhoneNumber, | ||
source: account.name, | ||
source_id: offer.account_id, | ||
customer: offer.customer, | ||
address: offer.job.address, | ||
nextAppointment: offer.appointment ? getNextAppointmentTime(offer.appointment) : undefined, | ||
_matchedWords: words, | ||
}; | ||
}); | ||
// Build jobs object for returning. | ||
// We make this match the jobOffers object as much as possible. | ||
jobs = response.job && response.job.hits || []; | ||
jobs = jobs.map(job => { | ||
const words = getJobWords(job); | ||
const appointment = job.next_scheduled_appointment && | ||
!_.isEmpty(job.next_scheduled_appointment) && | ||
getNextAppointmentTime(job.next_scheduled_appointment); | ||
return { | ||
..._.pick(job, jobProps), | ||
account_logo_token: job.logo_token, | ||
appointment, | ||
brand_logo: job.logo_token && `${host}/v1/datafiles/${job.logo_token}`, | ||
user_id: job.next_scheduled_appointment && job.next_scheduled_appointment.user_id, | ||
_matchedWords: words, | ||
}; | ||
}); | ||
const totalCustomers = response.customer && response.customer.nbHits || 0; | ||
const totalJobs = response.job && response.job.nbHits || 0; | ||
const totalJobOffers = response.job_offer && response.job_offer.nbHits || 0; | ||
return { | ||
@@ -533,3 +624,3 @@ customers, | ||
jobOffers, | ||
totalResults, | ||
totalResults: totalCustomers + totalJobs + totalJobOffers, | ||
}; | ||
@@ -536,0 +627,0 @@ }); |
@@ -397,4 +397,330 @@ import nock from 'nock'; | ||
describe('search', () => { | ||
// TODO - Add search tests when the endpoint is refined and extra search queries can be removed. | ||
it('parses query from api'); | ||
it('parses query from api', done => { | ||
const client = new Dispatch(testClientID, testClientSecret); | ||
nock(dispatchUrl).get('/v1/search?organization_id=5&q=fix').times(1).reply(200, { | ||
customer: { | ||
hits: [ | ||
{ | ||
_highlightResult: { | ||
full_name: { | ||
matchLevel: 'full', | ||
matchedWords: ['fix'], | ||
}, | ||
}, | ||
company_name: 'Company', | ||
created_at: '2016-07-21T01:27:16+0000', | ||
email: 'customer-201@example.com', | ||
external_ids: [], | ||
full_name: 'Mr. Fix-It', | ||
home_address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
id: 6911, | ||
last_job_at: '2016-07-23T13:59:10+0000', | ||
notes: null, | ||
organization_id: 5, | ||
phone_numbers: ['+15555550210'], | ||
}, | ||
], | ||
nbHits: 1, | ||
}, | ||
job: { | ||
hits: [ | ||
{ | ||
_highlightResult: { | ||
address_text: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
created_at: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
customer_email: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
customer_full_name: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
customer_phone_number: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
description: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
logo_token: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
service_type: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
source: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
status: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
title: { | ||
matchLevel: 'full', | ||
matchedWords: ['fix'], | ||
}, | ||
updated_at: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
}, | ||
address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
archived_at: null, | ||
brand_id: null, | ||
created_at: '2016-07-23T13:59:10+0000', | ||
customer_email: 'customer-201@example.com', | ||
customer_full_name: 'Custom Err', | ||
customer_id: 6911, | ||
customer_phone_number: '+15555550210', | ||
description: 'in the basement', | ||
external_ids: [], | ||
id: 6340, | ||
labels: ['one', 'two'], | ||
logo_token: '0e3601b9-5a4b-4692-b82d-502f61107876', | ||
next_scheduled_appointment: { | ||
duration: 3600, | ||
technician_name: null, | ||
time: '2016-07-21T01:00:00+0000', | ||
user_id: null, | ||
}, | ||
organization_id: 5, | ||
resume_at: null, | ||
service_type: 'plumbing', | ||
source: 'abc', | ||
source_id: 8, | ||
status: 'scheduled', | ||
status_message: null, | ||
title: 'Fix the sink', | ||
updated_at: '2016-07-21T01:32:46+0000', | ||
}, | ||
], | ||
nbHits: 1, | ||
}, | ||
job_offer: { | ||
hits: [ | ||
{ | ||
_highlightResult: { | ||
account: { | ||
logo_token: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
name: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
title: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
}, | ||
appointment: { | ||
window_end_time: [{ | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}], | ||
window_start_time: [{ | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}], | ||
}, | ||
created_at: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
customer: { | ||
billing_address_text: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
email: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
full_name: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
home_address_text: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
phone_numbers: [ | ||
{ | ||
number: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
type: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
}, | ||
], | ||
}, | ||
job: { | ||
address_text: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
service_type: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
title: { | ||
matchLevel: 'full', | ||
matchedWords: ['fix'], | ||
}, | ||
}, | ||
status: { | ||
matchLevel: 'none', | ||
matchedWords: [], | ||
}, | ||
}, | ||
account: { | ||
logo_token: '0e3601b9-5a4b-4692-b82d-502f61107876', | ||
name: 'abc', | ||
title: 'ABC Warranty', | ||
}, | ||
account_id: 8, | ||
appointment: { | ||
window_end_time: ['2016-07-21T02:00:00Z'], | ||
window_start_time: ['2016-07-21T01:00:00Z'], | ||
}, | ||
created_at: '2016-07-22T21:00:33+0000', | ||
customer: { | ||
billing_address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
email: 'customer-201@example.com', | ||
full_name: 'Custom Err', | ||
home_address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
phone_number: null, | ||
phone_numbers: [ | ||
{ | ||
number: '+15555550210', | ||
primary: true, | ||
type: 'Mobile', | ||
}, | ||
], | ||
}, | ||
id: 2626, | ||
job: { | ||
address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
service_type: 'plumbing', | ||
title: 'Fix the sink', | ||
}, | ||
job_id: null, | ||
organization_id: [5], | ||
status: 'offered', | ||
}, | ||
], | ||
nbHits: 1, | ||
}, | ||
}); | ||
client.search({ | ||
organizationID: 5, | ||
query: 'fix', | ||
}).then(result => { | ||
expect(result).toEqual({ | ||
customers: [ | ||
{ | ||
_matchedWords: { | ||
company_name: [], | ||
email: [], | ||
full_name: ['fix'], | ||
home_address_text: [], | ||
}, | ||
company_name: 'Company', | ||
created_at: '2016-07-21T01:27:16+0000', | ||
email: 'customer-201@example.com', | ||
external_ids: [], | ||
full_name: 'Mr. Fix-It', | ||
home_address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
id: 6911, | ||
last_job_at: '2016-07-23T13:59:10+0000', | ||
notes: null, | ||
organization_id: 5, | ||
phone_numbers: ['+15555550210'], | ||
}, | ||
], | ||
filter: undefined, | ||
jobOffers: [ | ||
{ | ||
_matchedWords: { | ||
address_text: [], | ||
customer_email: [], | ||
customer_full_name: [], | ||
customer_phone_number: [], | ||
description: [], | ||
service_type: [], | ||
source: [], | ||
status: [], | ||
title: ['fix'], | ||
}, | ||
account_logo_token: '0e3601b9-5a4b-4692-b82d-502f61107876', | ||
address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
appointment: '2016-07-21T01:00:00Z', | ||
brand_logo: 'https://files-api.dispatch.me/v1/datafiles/0e3601b9-5a4b-4692-b82d-502f61107876', | ||
customer_email: 'customer-201@example.com', | ||
customer_full_name: 'Custom Err', | ||
customer_phone_number: '+15555550210', | ||
id: 2626, | ||
organization_id: [5], | ||
service_type: 'plumbing', | ||
source: 'abc', | ||
source_id: 8, | ||
status: 'offered', | ||
title: 'Fix the sink', | ||
}, | ||
], | ||
jobs: [ | ||
{ | ||
_matchedWords: { | ||
address_text: [], | ||
customer_email: [], | ||
customer_full_name: [], | ||
customer_phone_number: [], | ||
description: [], | ||
service_type: [], | ||
source: [], | ||
status: [], | ||
title: ['fix'], | ||
}, | ||
account_logo_token: '0e3601b9-5a4b-4692-b82d-502f61107876', | ||
address_text: '123 Summer St, apt. 1, Boston, MA 01234', | ||
appointment: '2016-07-21T01:00:00+0000', | ||
brand_logo: 'https://files-api.dispatch.me/v1/datafiles/0e3601b9-5a4b-4692-b82d-502f61107876', | ||
customer_email: 'customer-201@example.com', | ||
customer_full_name: 'Custom Err', | ||
customer_id: 6911, | ||
customer_phone_number: '+15555550210', | ||
description: 'in the basement', | ||
id: 6340, | ||
labels: ['one', 'two'], | ||
organization_id: 5, | ||
service_type: 'plumbing', | ||
source: 'abc', | ||
source_id: 8, | ||
status: 'scheduled', | ||
status_message: null, | ||
title: 'Fix the sink', | ||
user_id: null, | ||
}, | ||
], | ||
totalResults: 3, | ||
}); | ||
done(); | ||
}).catch(done); | ||
}); | ||
}); | ||
@@ -401,0 +727,0 @@ }); |
{ | ||
"name": "dispatch-node-sdk", | ||
"version": "0.0.49", | ||
"version": "0.0.50", | ||
"description": "High- and low-level libraries for interacting with the Dispatch API", | ||
@@ -23,10 +23,13 @@ "main": "dist/lib/index.js", | ||
"babel-core": "6.x.x", | ||
"babel-eslint": "6.0.4", | ||
"babel-jscs": "^2.0.5", | ||
"babel-loader": "^6.2.1", | ||
"babel-preset-es2015": "6.x.x", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"babel-register": "6.x.x", | ||
"eslint": "^2.9.0", | ||
"eslint-config-airbnb": "^8.0.0", | ||
"eslint-config-airbnb-base": "^2.0.0", | ||
"eslint-plugin-import": "^1.6.1", | ||
"babel-register": "^6.4.3", | ||
"eslint": "2.10.2", | ||
"eslint-config-airbnb": "9.0.1", | ||
"eslint-plugin-import": "1.8.0", | ||
"eslint-plugin-jsx-a11y": "^1.5.5", | ||
"eslint-plugin-react": "^5.2.2", | ||
"expect": "^1.18.0", | ||
@@ -33,0 +36,0 @@ "mocha": "^2.4.5", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
202241
5209
17