// tslint:disable:no-console // import * as redis from 'redis'; import * as mongoose from 'mongoose'; import { chevre } from '../../../lib/index'; const project = { id: String(process.env.PROJECT_ID) }; const coaAuthClient = new chevre.COA.auth.RefreshToken({ endpoint: chevre.credentials.coa.endpoint, refreshToken: chevre.credentials.coa.refreshToken }); async function main() { await mongoose.connect(process.env.MONGOLAB_URI); const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection); const offerRepo = new chevre.repository.Offer(mongoose.connection); const masterService = new chevre.COA.service.Master( { endpoint: chevre.credentials.coa.endpoint, auth: coaAuthClient }, { timeout: chevre.credentials.coa.timeout } ); await chevre.service.offer.event.importFromCOA({ project, theaterCode: '120' })({ categoryCode: categoryCodeRepo, offer: offerRepo, masterService }); console.log('imported'); } main() .then(console.log) .catch(console.error);