Skip to content

Commit

Permalink
DEV-5778
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Pleintinger <[email protected]>
  • Loading branch information
ChripIX committed Mar 16, 2022
1 parent f442433 commit cae8af5
Show file tree
Hide file tree
Showing 24 changed files with 3,094 additions and 113 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "internetx/php-domainrobot-sdk",
"version": "0.9.4",
"version": "0.9.5",
"description": "A php package for easy integration of the domainrobot API powered by InterNetX GmbH.",
"type": "library",
"license": "MIT",
Expand All @@ -25,4 +25,3 @@
}
}
}

85 changes: 85 additions & 0 deletions example/domain/DomainBuy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace Example;

use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Domain;
use Domainrobot\Model\DomainExtensions;
use Domainrobot\Model\DomainBuyExtensions;
use Domainrobot\Model\NameServer;
use Domainrobot\Model\ObjectJob;

class SDKController
{
/**
* Buy a domain of the Sedo premium market.
*
* IMPORTANT: As of now this task does not work in an sandbox enviroment,
* because of the necessity to query the price of an domain
* from Sedo (which only works live).
*
* @return ObjectJob
*/
public function domainCreatePremium()
{
// Create an domainrobot instance
$domainrobot = new Domainrobot([
"url" => "https://api.autodns.com/v1",
"auth" => new DomainrobotAuth([
"user" => "username",
"password" => "password",
"context" => 4
])
]);

try {

// Domainrobot\Model\Domain
$domain = new Domain();

// Set the name of domain wanted to buy
$domain->setName("sedo-example.com");

// Set the price and currency of the domain wanted to buy
$domain->setExtensions(new DomainExtensions([
'domainBuyExtensions' => new DomainBuyExtensions([
'amount' => 76,
'currency' => "EUR"
]),
]));

// Set the name servers of the domain
$domain->setNameServers([
new NameServer([
"name" => "ns1.example.com"
]),
new NameServer([
"name" => "ns2.example.com"
]),
new NameServer([
"name" => "ns3.example.com"
])
]);

// Load an existing domain contact
// Domainrobot\Model\Contact
$contact = $domainrobot->contact->info(23372787);

// Set the necessary contact info with the loaded contact
$domain->setAdminc($contact);
$domain->setOwnerc($contact);
$domain->setTechc($contact);
$domain->setZonec($contact);

// Domainrobot\Model\ObjectJob
$objectJob = $domainrobot->domain->buy($domain);

} catch (DomainrobotException $exception) {
return $exception;
}

return $objectJob;
}
}
99 changes: 99 additions & 0 deletions example/domain/DomainCreatePremium.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

namespace Example;

use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Domain;
use Domainrobot\Model\NameServer;
use Domainrobot\Model\ObjectJob;

class SDKController
{
/**
* Create a premium domain
*
* For this task there are two prerequisites.
*
* First and most important is that the user is allowed to order premium domains (Reseller).
*
* Secondly you must know a premium domain with its price class.
* You can achieve that for example by searching with the domainstudio task.
*
*
* POST /domainstudio
* {
* "searchToken": "example.com",
* "currency": "EUR"
* }
*
*
* In the /domainstudio Response look after the attribute "source": "PREMIUM".
*
* With an premium domain you selected you must now inquire its price class.
*
*
* GET /domainpremium/examples.shop
*
*
* In the /domainpremium Response look after the attribute "priceClass".
*
* @return ObjectJob
*/
public function domainCreatePremium()
{
// Create an domainrobot instance
$domainrobot = new Domainrobot([
"url" => "https://api.autodns.com/v1",
"auth" => new DomainrobotAuth([
"user" => "username",
"password" => "password",
"context" => 4
])
]);

try {

// Domainrobot\Model\Domain
$domain = new Domain();

// Set the name of the premium domain
$domain->setName("examples.shop");

// Set the inquired price class of the premium domain
$domain->setPriceClass("SHOP-TIER9");

// Set the name servers of the premium domain
$domain->setNameServers([
new NameServer([
"name" => "ns1.example.shop"
]),
new NameServer([
"name" => "ns2.example.shop"
]),
new NameServer([
"name" => "ns3.example.shop"
])
]);

// Load an existing domain contact
// Domainrobot\Model\Contact
$contact = $domainrobot->contact->info(23372784);

// Set the necessary contact info with the loaded contact
$domain->setAdminc($contact);
$domain->setOwnerc($contact);
$domain->setTechc($contact);
$domain->setZonec($contact);

// Domainrobot\Model\ObjectJob
$objectJob = $domainrobot->domain->create($domain);

} catch (DomainrobotException $exception) {
return $exception;
}

return $objectJob;
}
}
60 changes: 60 additions & 0 deletions example/domain/DomainOwnerChange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Example;

use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Domain;
use Domainrobot\Model\NameServer;
use Domainrobot\Model\ObjectJob;

class SDKController
{
/**
* Change the OwnerC of an existing domain.
*
* With the /domain/{name}/_ownerChange task it is possible to switch from
* one domain contact to another domain contact of the same user.
*
* @return ObjectJob
*/
public function domainOwnerChange()
{
// Create an domainrobot instance
$domainrobot = new Domainrobot([
"url" => "https://api.autodns.com/v1",
"auth" => new DomainrobotAuth([
"user" => "username",
"password" => "password",
"context" => 4
])
]);

try {

// Domainrobot\Model\Domain
$domain = new Domain();

// Set the name of the domain
$domain->setName("example.com");

// Confirm the consent of the owner
$domain->setConfirmOwnerConsent(true);

// Domainrobot\Model\Contact
$contact = $domainrobot->contact->info(23372784);

// Set the new OwnerC
$domain->setOwnerc($contact);

// Domainrobot\Model\ObjectJob
$objectJob = $domainrobot->domain->ownerChange($domain);

} catch (DomainrobotException $exception) {
return $exception;
}

return $objectJob;
}
}
75 changes: 75 additions & 0 deletions example/domain/DomainTrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Example;

use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Domain;
use Domainrobot\Model\ObjectJob;

class SDKController
{
/**
* Change the OwnerC of an existing domain.
*
* With the /domain/_trade task it is possible to switch from the domain
* contact of one user to the domain contact of another user (Transfer).
*
* For this task there are two prerequisites.
*
* First and most important is that the registry must support the trade task.
*
* Secondly you must have an valid authinfo code.
* The authinfo must be generated with the /domain/{name}/_authinfo1 task.
*
*
* GET /domain/example.be/_authinfo1
*
*
* In the /domain/{name}/_authinfo1 Response look after the attribute "authinfo".
*
* @return ObjectJob
*/
public function domainTrade()
{
// Create an domainrobot instance
$domainrobot = new Domainrobot([
"url" => "https://api.autodns.com/v1",
"auth" => new DomainrobotAuth([
"user" => "username",
"password" => "password",
"context" => 4
])
]);

try {

// Domainrobot\Model\Domain
$domain = new Domain();

// Set the name of the domain which should be transfered to the new OwnerC
$domain->setName("example.be");

// Set the authinfo code
$domain->setAuthinfo("-qm-WJbL3DqyABCb");

// Confirm the consent of the owner
$domain->setConfirmOwnerConsent(true);

// Domainrobot\Model\Contact
$contact = $domainrobot->contact->info(23372784);

// Set the new OwnerC
$domain->setOwnerc($contact);

// Domainrobot\Model\ObjectJob
$objectJob = $domainrobot->domain->trade($domain);

} catch (DomainrobotException $exception) {
return $exception;
}

return $objectJob;
}
}
55 changes: 55 additions & 0 deletions example/redirect/RedirectCreateDomain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Example;

use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Redirect;

class SDKController
{
/**
* Create an domain redirect
*
* @return Redirect
*/
public function redirectCreateDomain()
{
// Create an domainrobot instance
$domainrobot = new Domainrobot([
"url" => "https://api.autodns.com/v1",
"auth" => new DomainrobotAuth([
"user" => "username",
"password" => "password",
"context" => 4
])
]);

try {

// Domainrobot\Model\Redirect
$redirect = new Redirect();

// Set the source domain
$redirect->setSource("example-1.com");

// Set the target path
$redirect->setTarget("example-2.com/test");

// Set type DOMAIN
$redirect->setType("DOMAIN");

// Set mode HTTP
$redirect->setMode("HTTP");

// Domainrobot\Model\Redirect
$object = $domainrobot->redirect->create($redirect);

} catch (DomainrobotException $exception) {
return $exception;
}

return $object;
}
}
Loading

0 comments on commit cae8af5

Please sign in to comment.