<?php

namespace App\Listeners\V1;

use App\Events\V1\EventABFLWebhook;
use App\Events\V1\EventJobs;
use App\Lib\Common\RabbitMQ;
use App\OneFinService;
use App\QueueLog;
use App\Slack;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use PhpAmqpLib\Exchange\AMQPExchangeType;

class TransactionInitiated
{

    public function handle(Model $model){
//        $OneFinService = new OneFinService(new Request(['id' => $model->application_id, 'transaction_id' => $model->id]));
//        $success = $OneFinService->postLoanRepayment();
//        (new Slack(new Request(['title' => 'OneFin Auto Transaction Initiated', 'fields' => ['message' => '', 'id' => $model->application_id, 'transaction_id' => $model->id, 'success' => json_encode($success)], 'group' => Slack::$STAGE_TESTING])))->send();
//        if (!$success){
//            (new Slack(new Request(['title' => 'OneFin Auto Transaction Failed', 'fields' => ['message' => '', 'id' => $model->application_id, 'transaction_id' => $model->id], 'group' => Slack::$STAGE_TESTING])))->send();
//        }
    }
}
