Skip to content

Commit cae8af5

Browse files
committed
DEV-5778
Signed-off-by: Christian Pleintinger <christian.pleintinger@internetx.com>
1 parent f442433 commit cae8af5

24 files changed

+3094
-113
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "internetx/php-domainrobot-sdk",
3-
"version": "0.9.4",
3+
"version": "0.9.5",
44
"description": "A php package for easy integration of the domainrobot API powered by InterNetX GmbH.",
55
"type": "library",
66
"license": "MIT",
@@ -25,4 +25,3 @@
2525
}
2626
}
2727
}
28-

example/domain/DomainBuy.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace Example;
4+
5+
use Domainrobot\Domainrobot;
6+
use Domainrobot\Lib\DomainrobotAuth;
7+
use Domainrobot\Lib\DomainrobotException;
8+
use Domainrobot\Model\Domain;
9+
use Domainrobot\Model\DomainExtensions;
10+
use Domainrobot\Model\DomainBuyExtensions;
11+
use Domainrobot\Model\NameServer;
12+
use Domainrobot\Model\ObjectJob;
13+
14+
class SDKController
15+
{
16+
/**
17+
* Buy a domain of the Sedo premium market.
18+
*
19+
* IMPORTANT: As of now this task does not work in an sandbox enviroment,
20+
* because of the necessity to query the price of an domain
21+
* from Sedo (which only works live).
22+
*
23+
* @return ObjectJob
24+
*/
25+
public function domainCreatePremium()
26+
{
27+
// Create an domainrobot instance
28+
$domainrobot = new Domainrobot([
29+
"url" => "https://api.autodns.com/v1",
30+
"auth" => new DomainrobotAuth([
31+
"user" => "username",
32+
"password" => "password",
33+
"context" => 4
34+
])
35+
]);
36+
37+
try {
38+
39+
// Domainrobot\Model\Domain
40+
$domain = new Domain();
41+
42+
// Set the name of domain wanted to buy
43+
$domain->setName("sedo-example.com");
44+
45+
// Set the price and currency of the domain wanted to buy
46+
$domain->setExtensions(new DomainExtensions([
47+
'domainBuyExtensions' => new DomainBuyExtensions([
48+
'amount' => 76,
49+
'currency' => "EUR"
50+
]),
51+
]));
52+
53+
// Set the name servers of the domain
54+
$domain->setNameServers([
55+
new NameServer([
56+
"name" => "ns1.example.com"
57+
]),
58+
new NameServer([
59+
"name" => "ns2.example.com"
60+
]),
61+
new NameServer([
62+
"name" => "ns3.example.com"
63+
])
64+
]);
65+
66+
// Load an existing domain contact
67+
// Domainrobot\Model\Contact
68+
$contact = $domainrobot->contact->info(23372787);
69+
70+
// Set the necessary contact info with the loaded contact
71+
$domain->setAdminc($contact);
72+
$domain->setOwnerc($contact);
73+
$domain->setTechc($contact);
74+
$domain->setZonec($contact);
75+
76+
// Domainrobot\Model\ObjectJob
77+
$objectJob = $domainrobot->domain->buy($domain);
78+
79+
} catch (DomainrobotException $exception) {
80+
return $exception;
81+
}
82+
83+
return $objectJob;
84+
}
85+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
namespace Example;
4+
5+
use Domainrobot\Domainrobot;
6+
use Domainrobot\Lib\DomainrobotAuth;
7+
use Domainrobot\Lib\DomainrobotException;
8+
use Domainrobot\Model\Domain;
9+
use Domainrobot\Model\NameServer;
10+
use Domainrobot\Model\ObjectJob;
11+
12+
class SDKController
13+
{
14+
/**
15+
* Create a premium domain
16+
*
17+
* For this task there are two prerequisites.
18+
*
19+
* First and most important is that the user is allowed to order premium domains (Reseller).
20+
*
21+
* Secondly you must know a premium domain with its price class.
22+
* You can achieve that for example by searching with the domainstudio task.
23+
*
24+
*
25+
* POST /domainstudio
26+
* {
27+
* "searchToken": "example.com",
28+
* "currency": "EUR"
29+
* }
30+
*
31+
*
32+
* In the /domainstudio Response look after the attribute "source": "PREMIUM".
33+
*
34+
* With an premium domain you selected you must now inquire its price class.
35+
*
36+
*
37+
* GET /domainpremium/examples.shop
38+
*
39+
*
40+
* In the /domainpremium Response look after the attribute "priceClass".
41+
*
42+
* @return ObjectJob
43+
*/
44+
public function domainCreatePremium()
45+
{
46+
// Create an domainrobot instance
47+
$domainrobot = new Domainrobot([
48+
"url" => "https://api.autodns.com/v1",
49+
"auth" => new DomainrobotAuth([
50+
"user" => "username",
51+
"password" => "password",
52+
"context" => 4
53+
])
54+
]);
55+
56+
try {
57+
58+
// Domainrobot\Model\Domain
59+
$domain = new Domain();
60+
61+
// Set the name of the premium domain
62+
$domain->setName("examples.shop");
63+
64+
// Set the inquired price class of the premium domain
65+
$domain->setPriceClass("SHOP-TIER9");
66+
67+
// Set the name servers of the premium domain
68+
$domain->setNameServers([
69+
new NameServer([
70+
"name" => "ns1.example.shop"
71+
]),
72+
new NameServer([
73+
"name" => "ns2.example.shop"
74+
]),
75+
new NameServer([
76+
"name" => "ns3.example.shop"
77+
])
78+
]);
79+
80+
// Load an existing domain contact
81+
// Domainrobot\Model\Contact
82+
$contact = $domainrobot->contact->info(23372784);
83+
84+
// Set the necessary contact info with the loaded contact
85+
$domain->setAdminc($contact);
86+
$domain->setOwnerc($contact);
87+
$domain->setTechc($contact);
88+
$domain->setZonec($contact);
89+
90+
// Domainrobot\Model\ObjectJob
91+
$objectJob = $domainrobot->domain->create($domain);
92+
93+
} catch (DomainrobotException $exception) {
94+
return $exception;
95+
}
96+
97+
return $objectJob;
98+
}
99+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Example;
4+
5+
use Domainrobot\Domainrobot;
6+
use Domainrobot\Lib\DomainrobotAuth;
7+
use Domainrobot\Lib\DomainrobotException;
8+
use Domainrobot\Model\Domain;
9+
use Domainrobot\Model\NameServer;
10+
use Domainrobot\Model\ObjectJob;
11+
12+
class SDKController
13+
{
14+
/**
15+
* Change the OwnerC of an existing domain.
16+
*
17+
* With the /domain/{name}/_ownerChange task it is possible to switch from
18+
* one domain contact to another domain contact of the same user.
19+
*
20+
* @return ObjectJob
21+
*/
22+
public function domainOwnerChange()
23+
{
24+
// Create an domainrobot instance
25+
$domainrobot = new Domainrobot([
26+
"url" => "https://api.autodns.com/v1",
27+
"auth" => new DomainrobotAuth([
28+
"user" => "username",
29+
"password" => "password",
30+
"context" => 4
31+
])
32+
]);
33+
34+
try {
35+
36+
// Domainrobot\Model\Domain
37+
$domain = new Domain();
38+
39+
// Set the name of the domain
40+
$domain->setName("example.com");
41+
42+
// Confirm the consent of the owner
43+
$domain->setConfirmOwnerConsent(true);
44+
45+
// Domainrobot\Model\Contact
46+
$contact = $domainrobot->contact->info(23372784);
47+
48+
// Set the new OwnerC
49+
$domain->setOwnerc($contact);
50+
51+
// Domainrobot\Model\ObjectJob
52+
$objectJob = $domainrobot->domain->ownerChange($domain);
53+
54+
} catch (DomainrobotException $exception) {
55+
return $exception;
56+
}
57+
58+
return $objectJob;
59+
}
60+
}

example/domain/DomainTrade.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
namespace Example;
4+
5+
use Domainrobot\Domainrobot;
6+
use Domainrobot\Lib\DomainrobotAuth;
7+
use Domainrobot\Lib\DomainrobotException;
8+
use Domainrobot\Model\Domain;
9+
use Domainrobot\Model\ObjectJob;
10+
11+
class SDKController
12+
{
13+
/**
14+
* Change the OwnerC of an existing domain.
15+
*
16+
* With the /domain/_trade task it is possible to switch from the domain
17+
* contact of one user to the domain contact of another user (Transfer).
18+
*
19+
* For this task there are two prerequisites.
20+
*
21+
* First and most important is that the registry must support the trade task.
22+
*
23+
* Secondly you must have an valid authinfo code.
24+
* The authinfo must be generated with the /domain/{name}/_authinfo1 task.
25+
*
26+
*
27+
* GET /domain/example.be/_authinfo1
28+
*
29+
*
30+
* In the /domain/{name}/_authinfo1 Response look after the attribute "authinfo".
31+
*
32+
* @return ObjectJob
33+
*/
34+
public function domainTrade()
35+
{
36+
// Create an domainrobot instance
37+
$domainrobot = new Domainrobot([
38+
"url" => "https://api.autodns.com/v1",
39+
"auth" => new DomainrobotAuth([
40+
"user" => "username",
41+
"password" => "password",
42+
"context" => 4
43+
])
44+
]);
45+
46+
try {
47+
48+
// Domainrobot\Model\Domain
49+
$domain = new Domain();
50+
51+
// Set the name of the domain which should be transfered to the new OwnerC
52+
$domain->setName("example.be");
53+
54+
// Set the authinfo code
55+
$domain->setAuthinfo("-qm-WJbL3DqyABCb");
56+
57+
// Confirm the consent of the owner
58+
$domain->setConfirmOwnerConsent(true);
59+
60+
// Domainrobot\Model\Contact
61+
$contact = $domainrobot->contact->info(23372784);
62+
63+
// Set the new OwnerC
64+
$domain->setOwnerc($contact);
65+
66+
// Domainrobot\Model\ObjectJob
67+
$objectJob = $domainrobot->domain->trade($domain);
68+
69+
} catch (DomainrobotException $exception) {
70+
return $exception;
71+
}
72+
73+
return $objectJob;
74+
}
75+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Example;
4+
5+
use Domainrobot\Domainrobot;
6+
use Domainrobot\Lib\DomainrobotAuth;
7+
use Domainrobot\Lib\DomainrobotException;
8+
use Domainrobot\Model\Redirect;
9+
10+
class SDKController
11+
{
12+
/**
13+
* Create an domain redirect
14+
*
15+
* @return Redirect
16+
*/
17+
public function redirectCreateDomain()
18+
{
19+
// Create an domainrobot instance
20+
$domainrobot = new Domainrobot([
21+
"url" => "https://api.autodns.com/v1",
22+
"auth" => new DomainrobotAuth([
23+
"user" => "username",
24+
"password" => "password",
25+
"context" => 4
26+
])
27+
]);
28+
29+
try {
30+
31+
// Domainrobot\Model\Redirect
32+
$redirect = new Redirect();
33+
34+
// Set the source domain
35+
$redirect->setSource("example-1.com");
36+
37+
// Set the target path
38+
$redirect->setTarget("example-2.com/test");
39+
40+
// Set type DOMAIN
41+
$redirect->setType("DOMAIN");
42+
43+
// Set mode HTTP
44+
$redirect->setMode("HTTP");
45+
46+
// Domainrobot\Model\Redirect
47+
$object = $domainrobot->redirect->create($redirect);
48+
49+
} catch (DomainrobotException $exception) {
50+
return $exception;
51+
}
52+
53+
return $object;
54+
}
55+
}

0 commit comments

Comments
 (0)