Skip to content

Commit

Permalink
RT-15535: Extra description for additionalfields.php
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterjan.eilers committed Nov 27, 2024
1 parent d1fc9ea commit 3407017
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 46 deletions.
12 changes: 12 additions & 0 deletions modules/registrars/realtimeregister/additionalfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use RealtimeRegisterDomains\Services\LogService;
use RealtimeRegisterDomains\Services\MetadataService;

// Use this variable to skip getting the metadata for any tld's, add custom fields at the bottom of the file
$skip = ['nl'];
$tlds = [];
$languageCodes = [];
Expand Down Expand Up @@ -105,4 +106,15 @@ function ($field) {
}
}

/* Add custom fields here, example
$additionaldomainfields[".nl"][] = [
"Name" => "Name1",
"LangVar" => "langvar_1",
"Type" => "dropdown",
"Options" => "option1|Option 1,option2|Option2,
"Default" => "option1",
];
...
*/

MetadataService::removeDefaultFields($additionaldomainfields);
Original file line number Diff line number Diff line change
Expand Up @@ -20,63 +20,62 @@ public function __invoke(Request $request)
{
$results = new ResultsList();

if (App::registrarConfig()->customerHandle() !== '') {
// Then, get the pricing
$prices = $this->getPrices(App::client()->customers->priceList(App::registrarConfig()->customerHandle()));
if (App::registrarConfig()->customerHandle() === '') {
throw new \Exception("No Customer set in config");
}
// Then, get the pricing
$prices = $this->getPrices(App::client()->customers->priceList(App::registrarConfig()->customerHandle()));

foreach ($prices as $tld => $priceInfo) {
$item = new ImportItem();
try {
$metadata = (new MetadataService($tld))->getMetadata();
} catch (\Exception $e) {
continue;
}
foreach ($prices as $tld => $priceInfo) {
$item = new ImportItem();
try {
$metadata = (new MetadataService($tld))->getMetadata();
} catch (\Exception $e) {
continue;
}

$item->setExtension(idn_to_utf8($tld));
$item->setEppRequired($metadata->transferSupportsAuthcode);
if ($priceInfo['CREATE']) {
$item->setRegisterPrice(number_format($priceInfo['CREATE']['price'] / 100, 2, '.', ''));
$item->setCurrency($priceInfo['CREATE']['currency']);
}
$item->setExtension(idn_to_utf8($tld));
$item->setEppRequired($metadata->transferSupportsAuthcode);
if ($priceInfo['CREATE']) {
$item->setRegisterPrice(number_format($priceInfo['CREATE']['price'] / 100, 2, '.', ''));
$item->setCurrency($priceInfo['CREATE']['currency']);
}

if ($priceInfo['RENEW']) {
$item->setRenewPrice(number_format($priceInfo['RENEW']['price'] / 100, 2, '.', ''));
}
if ($priceInfo['RENEW']) {
$item->setRenewPrice(number_format($priceInfo['RENEW']['price'] / 100, 2, '.', ''));
}

if ($priceInfo['TRANSFER']) {
$item->setTransferPrice(number_format($priceInfo['TRANSFER']['price'] / 100, 2, '.', ''));
}
if ($priceInfo['TRANSFER']) {
$item->setTransferPrice(number_format($priceInfo['TRANSFER']['price'] / 100, 2, '.', ''));
}

if ($priceInfo['RESTORE']) {
if ($metadata->redemptionPeriod) {
$item->setRedemptionFeePrice(number_format($priceInfo['RESTORE']['price'] / 100, 2, '.', ''));
$item->setRedemptionFeeDays($metadata->redemptionPeriod);
}
if ($metadata->autoRenewGracePeriod) {
$item->setGraceFeePrice(number_format($priceInfo['RENEW']['price'] / 100, 2, '.', ''));
$item->setGraceFeeDays($metadata->autoRenewGracePeriod);
}
if ($priceInfo['RESTORE']) {
if ($metadata->redemptionPeriod) {
$item->setRedemptionFeePrice(number_format($priceInfo['RESTORE']['price'] / 100, 2, '.', ''));
$item->setRedemptionFeeDays($metadata->redemptionPeriod);
}
if ($metadata->autoRenewGracePeriod) {
$item->setGraceFeePrice(number_format($priceInfo['RENEW']['price'] / 100, 2, '.', ''));
$item->setGraceFeeDays($metadata->autoRenewGracePeriod);
}
}

if ($metadata->createDomainPeriods) {
$minYears = -1;
$maxYears = -1;
foreach ($metadata->createDomainPeriods as $period) {
if ($period % 12 == 0) {
if ($minYears === -1) {
$minYears = $period / 12;
}
$maxYears = $period / 12;
if ($metadata->createDomainPeriods) {
$minYears = -1;
$maxYears = -1;
foreach ($metadata->createDomainPeriods as $period) {
if ($period % 12 == 0) {
if ($minYears === -1) {
$minYears = $period / 12;
}
$maxYears = $period / 12;
}
$item->setMinYears($minYears);
$item->setMaxYears($maxYears);
}
$results[] = $item;
$item->setMinYears($minYears);
$item->setMaxYears($maxYears);
}
return $results;
} else {
throw new \Exception("No Customer set in config");
$results[] = $item;
}
return $results;
}
}

0 comments on commit 3407017

Please sign in to comment.