InterNetX/php-domainrobot-sdk

Serialization problem with some fields

Closed this issue · 1 comments

The json serialization seems not to work for some fields. For example the nameServers field of the Domain model.

Example :

<?php
require "vendor/autoload.php";

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

$url = "";
$user = "";
$password = "";
$context = ;
$domainRobot = new Domainrobot([
    "url" => $url,
    "auth" => new DomainrobotAuth([
        "user" => $user,
        "password" => $password,
        "context" => $context
    ])
]);

$ns1 = new NameServer(["name" => "ns1.parkingcrew.net"]);
$ns2 = new NameServer(["name" => "ns2.parkingcrew.net"]);
$servers = array($ns1, $ns2);
print_r($servers);


$domain = new Domain([
    "name" => "testdomain.at",
    "nameServers" => $servers,
    "ownerc" => new Contact(["id" => 1234]),
    "adminc" => new Contact(["id" => 1234]),
    "techc" => new Contact(["id" => 1234]),
]);

try {
    $response = $domainRobot->domain->create($domain);
} catch (DomainrobotException $e) {
    print_r($e->getError());
    exit;
}
print_r($response);

This request results in an error because the nameServers are empty models :

"nameServers": [
    {},
    {}
],

Fixed in ^0.4.1

[nameServers] => Array

        (
            [0] => Array
                (
                    [name] => ns1.parkingcrew.net
                )

            [1] => Array
                (
                    [name] => ns2.parkingcrew.net
                )

        )