Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added getRegistrationDate method #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions opensrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,36 @@ public function renewDomain($domain, $module_row_id = null, array $vars = [])
return $response->status() == 'OK';
}

/**
* Gets the domain registration date
*
* @param stdClass $service The service belonging to the domain to lookup
* @param string $format The format to return the registration date in
* @return string The domain registration date in UTC time in the given format
* @see Services::get()
*/
public function getRegistrationDate($service, $format = 'Y-m-d H:i:s')
{
Loader::loadHelpers($this, ['Date']);

$domain = $this->getServiceDomain($service);
$module_row_id = $service->module_row_id ?? null;

$row = $this->getModuleRow($module_row_id);
$api = $this->getApi($row->meta->user, $row->meta->key, $row->meta->sandbox == 'true');

$domains = new OpensrsDomains($api);
$result = $domains->get(['domain' => $domain, 'type' => 'all_info']);
$this->processResponse($api, $result);

if ($result->status() != 'OK') {
return false;
}
$response = $result->response();

return $this->Date->format($format, $response->attributes['registry_createdate'] ?? date('c'));
}

/**
* Gets the domain expiration date
*
Expand Down