// tslint:disable:no-console
import * as mongoose from 'mongoose';

import { chevre } from '../../../lib/index';

const project = { id: String(process.env.PROJECT_ID) };

async function main() {
    await mongoose.connect(<string>process.env.MONGOLAB_URI);

    const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
    const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);

    const action = await (await chevre.service.payment.any.createService()).findCheckAction({
        project: {
            id: project.id
        },
        sameAs: {
            id: '666627d5e7fdb1e29d985675'
        },
        purpose: {
            id: '666627c6e7fdb1e29d985646'
        }
    })({
        action: actionRepo,
        task: taskRepo
    });
    // tslint:disable-next-line:no-null-keyword
    console.dir(action.result?.purchaseNumberAuthResult, { depth: null });
}

main()
    .then()
    .catch(console.error);
