Skip to content

Commit b5f53a4

Browse files
author
Vítězslav Dvořák
committed
Get_DNS_Zone ans Make_Order added
Added Client::env2conf for easy use of .env based configuration
1 parent 10be4d0 commit b5f53a4

File tree

5 files changed

+110
-2
lines changed

5 files changed

+110
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/.phpunit.result.cache
1010
/.phpunit.cache/
1111
/nbproject/
12+
/.env

Examples/GetDnsZone.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* Subreg - Usage Example
5+
*
6+
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
7+
* @copyright (C) 2024 Spoje.Net
8+
*/
9+
10+
namespace Subreg;
11+
12+
require_once '../vendor/autoload.php';
13+
14+
\Ease\Shared::init([
15+
'SUBREG_LOCATION',
16+
'SUBREG_URI',
17+
'SUBREG_LOGIN',
18+
'SUBREG_PASSWORD'
19+
], '../.env');
20+
21+
$client = new Client(Client::env2conf(\Ease\Shared::instanced()->configuration));
22+
$client->login();
23+
24+
$response = $client->getDnsZone('vitexsoftware.com');
25+
26+
var_dump($response);

debian/changelog

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
php-spojenet-subreg (1.1.0) UNRELEASED; urgency=medium
1+
php-spojenet-subreg (1.1.0) unstable; urgency=medium
22

3+
[ vitex ]
34
* creditCorrection and infoUser functions added
45

5-
-- vitex <info@vitexsoftware.cz> Thu, 25 Jan 2024 20:24:48 +0100
6+
-- <vitezslav.dvorak@spojenet.cz> Mon, 22 Apr 2024 17:17:07 +0200
67

78
php-spojenet-subreg (1.0) unstable; urgency=medium
89

nbproject/configs/Register.properties

Whitespace-only changes.

src/Subreg/Client.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,31 @@ public function __construct($config)
7878
$this->setObjectName();
7979
}
8080

81+
/**
82+
* Convert ENV keys to configuration
83+
*
84+
* @param array $env
85+
*
86+
* @return array
87+
*/
88+
public static function env2conf(array $env)
89+
{
90+
$conf = [];
91+
if (array_key_exists('SUBREG_LOCATION', $env)) {
92+
$conf['location'] = $env['SUBREG_LOCATION'];
93+
}
94+
if (array_key_exists('SUBREG_URI', $env)) {
95+
$conf['uri'] = $env['SUBREG_URI'];
96+
}
97+
if (array_key_exists('SUBREG_LOGIN', $env)) {
98+
$conf['login'] = $env['SUBREG_LOGIN'];
99+
}
100+
if (array_key_exists('SUBREG_PASSWORD', $env)) {
101+
$conf['password'] = $env['SUBREG_PASSWORD'];
102+
}
103+
return $conf;
104+
}
105+
81106
/**
82107
* Add Info about used user, server and libraries
83108
*
@@ -330,4 +355,59 @@ public function infoUser(int $id)
330355
{
331356
return $this->call('Info_User', ['id' => $id]);
332357
}
358+
359+
/**
360+
* List of DNS records for specified domain.
361+
*
362+
* @see https://subreg.cz/manual/?cmd=Get_DNS_Zone
363+
*
364+
* @param string $zoneName Registered domain
365+
*
366+
* @return array
367+
*/
368+
public function getDnsZone(string $zoneName)
369+
{
370+
return $this->call('Get_DNS_Zone', ['domain' => $zoneName]);
371+
}
372+
373+
/**
374+
* Create a new order (CreateDomain, ModifyDomain, RenewDomain, ... )
375+
*
376+
* @see https://subreg.cz/manual/?cmd=Make_Order
377+
*
378+
* Create_Domain
379+
* PremiumCreate_Domain
380+
* Transfer_Domain
381+
* PremiumTransfer_Domain
382+
* AccountTransfer_Domain
383+
* TransferApprove_Domain
384+
* TransferDeny_Domain
385+
* TransferCancel_Domain
386+
* SKChangeOwner_Domain
387+
* Modify_Domain
388+
* ModifyNS_Domain
389+
* Delete_Domain
390+
* Restore_Domain
391+
* PremiumRestore_Domain
392+
* Renew_Domain
393+
* PremiumRenew_Domain
394+
* Backorder_Domain
395+
* Preregister_Domain
396+
* Create_Object
397+
* Transfer_Object
398+
* Update_Object
399+
* TransferRU_Request
400+
*
401+
* Certificate_Request
402+
*
403+
* @param string $domain
404+
* @param string $type
405+
* @param array $data
406+
*
407+
* @return array
408+
*/
409+
public function makeOrder(string $domain, string $type, array $data = [])
410+
{
411+
return $this->call('Make_Order', ['domain' => $zoneName, 'type' => $type, 'params' => $data]);
412+
}
333413
}

0 commit comments

Comments
 (0)