47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Integrations\Whmcs\Writers;
|
|
|
|
use App\Integrations\Whmcs\DTOs\CustomerDomainData;
|
|
use App\Integrations\Whmcs\Support\DnsDomainLinker;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CustomerDomainWriter
|
|
{
|
|
public function __construct(private DnsDomainLinker $dnsLinker)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Skips domains whose WHMCS client couldn't be resolved to a local customer.
|
|
*/
|
|
public function write(CustomerDomainData $data): bool
|
|
{
|
|
if ($data->customerId === null) {
|
|
return false;
|
|
}
|
|
|
|
DB::table('module_domain')->updateOrInsert(
|
|
['legacy_id' => $data->legacyId],
|
|
[
|
|
'name' => $data->name,
|
|
'order_id' => $data->orderId,
|
|
'first_payment' => $data->firstPayment,
|
|
'module_dns_id' => 0,
|
|
'next_payment' => $data->nextPayment,
|
|
'next_due_date' => $data->nextDueDate,
|
|
'next_invoice_date' => $data->nextInvoiceDate,
|
|
'customer_id' => $data->customerId,
|
|
'domain_type_id' => 0,
|
|
'registrar_id' => $data->registrarId,
|
|
'note' => $data->note,
|
|
'status' => $data->status,
|
|
]
|
|
);
|
|
|
|
$this->dnsLinker->link($data->name, $data->customerId, $data->registrarId);
|
|
|
|
return true;
|
|
}
|
|
}
|