-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
34 lines (26 loc) · 1.01 KB
/
test.php
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
29
30
31
32
33
34
<?php
use App\Database\Database;
use App\Models\Subscription;
use App\Models\User;
use App\Services\AdService;
use App\Services\MailService;
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/App/Config/database.php');
require_once(__DIR__ . '/App/Config/mail.php');
/** @var $connection */
/** @var $mailParams */
$db = new Database($connection);
$user = new User($db);
$subscription = new Subscription($db, $user);
$subscriptions = $subscription->getAllWithUsers();
$adService = new AdService();
$mailService = new MailService($mailParams);
foreach ($subscriptions as $key => $subscription) {
$result = $adService->getSource($subscription['url'])->getPriceAndCurrencyCode();
if ($result['price'] == $subscription['price']) {
foreach (current($subscription['email']) as $email) {
$mailService($email, $result['price'], $subscription['price'], $result['currencyCode'], $subscription['url']);
echo 'Mail to: ' . $email . ' has sent' . PHP_EOL;
}
}
}