Git Product home page Git Product logo

realtimeregister-php's People

Contributors

a1rpun avatar adrianmejias avatar arnobot avatar arnowest avatar avoeffelen avatar deluze avatar enablinglogic avatar frontendcoffee avatar frsandervs avatar gcumbaya avatar glenn1001 avatar jeroenvermeulen avatar koenhendriks avatar marcvdm avatar markdingemanse avatar stefan-at-sandwave avatar stephanvdhorn avatar thijswiersema avatar thomasredpanda avatar websmurf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

realtimeregister-php's Issues

Implement missing endpoints in Domains API

Zone JSON is assumed to have 'template' key but that is not always the case

This code:

public static function fromArray(array $data): Zone
{
return new Zone(
$data['template'],
$data['link'] ?? null
);
}

barfs on this data from RTR Live:

{
  "domainName": "somedomain.nl",
  "registrant": "some_registrant",
  "status": [
    "OK"
  ],
  "authcode": "___secret___",
  "createdDate": "2018-08-03T09:49:40Z",
  "updatedDate": "2023-04-19T11:46:06Z",
  "expiryDate": "2023-11-03T09:49:40Z",
  "ns": [
    "ns1.yoursrs.com",
    "ns2.yoursrs.com"
  ],
  "autoRenew": true,
  "autoRenewPeriod": 12,
  "zone": {
    "id": 1334243663,
    "service": "BASIC",
    "dnssec": false
  },
  "premium": false,
  "gateway": false,
  "privacyProtect": false,
  "contacts": [
    {
      "role": "ADMIN",
      "handle": "some_registrant"
    },
    {
      "role": "TECH",
      "handle": "some_registrant"
    },
    {
      "role": "BILLING",
      "handle": "some_registrant"
    }
  ],
  "customer": "savvii",
  "registry": "Sidn"
}

Error:

PHP Warning:  Undefined array key "template" in vendor/sandwave-io/realtimeregister-php/src/Domain/Zone.php on line 20

Implement DNS Templates

Documentation: https://dm.realtimeregister.com/docs/api/templates

Module:

  • Add a TemplatesApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get
  • List
  • Create
  • Update
  • Delete

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

Mutual exclusivity in request input

PR #66 exposed some issues with mutual exclusivity across request input. For example domains/create has a zone input that can't be used together with ns and keyData.

Do other calls have this kind of mutual exclusivity too? Can we proactively prevent bad requests like these?

Request Logging

I would like to see a feature when i am in a debugging state i have the option to see what payload was send to the remote api. You should be able to provide the client constructor with an optional PSR-Log service that can log this payload when a remote call is being executed.

Implement Brands API

Documentation: https://dm.realtimeregister.com/docs/api/brands

Module:

  • Add a BrandsApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get
  • List
  • Create
  • Update
  • Delete
  • Get template
  • List templates
  • Update template
  • Preview template

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

Implement SSL API

Documentation: https://dm.realtimeregister.com/docs/api/ssl

Module:

  • Add a SslApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get certificate
  • List certificates
  • Download certificate
  • List DCV e-mail addresses
  • Resend DCV
  • Get product
  • List products
  • Request certificate
  • Renew certificate
  • Reissue certificate
  • Revoke certificate
  • Send subscriber agreement
  • Add note
  • Schedule validation call

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

Implement Financial API

Documentation: https://dm.realtimeregister.com/docs/api/financial

Module:

  • Add a FinancialApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get transaction
  • List transactions
  • Get exchange rates

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

LanguageCodes do not get instantiated properly inside the DomainSyntax

DomainSyntax assumes there is only a single language code but in reality its a collection of language codes.

public static function fromArray(array $json): DomainSyntax
{
    return new DomainSyntax(
        $json['minLength'],
        $json['maxLength'],
        $json['idnSupport'],
        $json['allowedCharacters'] ?? null,
        isset($json['languageCodes']) ? LanguageCodes::fromArray($json['languageCodes']) : null
    );
}

The above code assumes the Language code is only a single item. But in reality when this element is available this is a collection of codes.

public static function fromArray(array $json): LanguageCodes
{
    return new LanguageCodes(
        $json['name'],
        $json['allowedCharacters'] ?? null
    );
}

Implement Notifications API

Documentation: https://dm.realtimeregister.com/docs/api/notifications

Module:

  • Add a NotificationsApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get
  • List
  • Poll
  • Ack

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

IsProxy telnet driver

As described within the IsProxy page of the documentation, the API for IsProxy functions based on a telnet connection.

In this page of the documentation, a code sample is given as a possible way of implementing the API.

  • Add a IsProxy class to the main namespace of the repository, this class should make using the IsProxy package really easy.
  • Add developer documentation to the readme with an example of using the IsProxy driver.
<?php

/**
 * Realtime Register is proxy
 *
 * <code>
 * require_once 'IsProxy.php';
 *
 * $ip = new IsProxy("apikey");
 * $ip->check('domainname', 'com');
 *
 * $result = $ip->result();
 * echo $result['domain'].' '.$result['result'];
 *
 * $ip->close();
 * </code>
 */

class IsProxy {
    /**
     * Connection
     *
     * @var     object
     */
    var $_fp;

    /**
     * Construct
     *
     * @param   string  The api key
     * @param   string  The IsProxy host, defaults to "is.yoursrs.com"
     * @param   int     The IsProxy port, defaults to 2001
     * @return  void
     */
    function IsProxy($apikey, $host = "is.yoursrs.com", $port = 2001) {
        $this->apikey = $apikey;
        $this->host = $host;
        $this->port = $port;
    }

    /**
     * Close
     *
     * @return  void
     */
    function close() {
        $this->write('CLOSE');

        @fclose($this->_fp);
    }

    /**
     * Connect
     *
     * @return  bool    Connection established?
     */
    function connect() {
        $this->_fp = @fsockopen($this->host, $this->port, $errno, $errstr, 10);
        if(!is_resource($this->_fp)) {
            return false;
        }

        /**
         * Login
         */
        return $this->login();
    }

    /**
     * Check
     *
     * @param   string  Domainname
     * @param   mixed   TLD(s)
     * @return  void
     */
    function check($domainname, $tlds) {
        if(!is_array($tlds)) {
            $tlds = (array) $tlds;
        }

        foreach($tlds as $tld) {
            $this->write('IS '.$domainname.'.'.$tld);
        }
    }

    /**
     * Result
     *
     * @return  array   [ domain, result ]
     */
    function result() {
        $response = $this->read();
        if(preg_match('#^([\-\w.]+)\s(available|not\savailable|invalid\sdomain|error)#', $response, $match)) {
            return array('domain' => $match[1], 'result' => $match[2]);
        }

        return array('domain' => '-', 'result' => 'error');
    }

    /**
     * Is connected?
     *
     * @return  bool    Connection?
     */
    function is_connected() {
        return is_resource($this->_fp);
    }

    /**
     * Login
     *
     * @return  bool    Login successfull?
     */
    function login() {
        if(!$this->write('LOGIN '.$this->apikey)) {
            return false;
        }

        $response = $this->read();
        if(preg_match('#^400\sLogin\sfailed#', $response)) {
            return false;
        }

        return preg_match('#^100\sLogin\sok#', $response);
    }

    /**
     * Read
     *
     * @return  string  Response
     */
    function read() {
        if(!$this->is_connected()) {
            $this->connect();
        }

        if(!$response = fgets($this->_fp, 1024)) {
            return false;
        }

        return trim($response);
    }

    /**
     * Write
     *
     * @param   string  Message
     * @return  bool    Writing successfull?
     */
    function write($message) {
        if(!$this->is_connected()) {
            $this->connect();
        }

        return @fputs($this->_fp, $message."\r\n");
    }
}

?>

Some usage example code:

<?php

/**
 * Realtime Register is proxy example usage
 */

/**
 * Realtime Register is proxy api key
 */
$apikey = 'apikey';

/**
 * TLDs
 */
$tlds = array('com', 'net', 'org', 'info');

/**
 * Text
 */
$text = array(
    'error'             => 'Error',
    'available'         => 'Available',
    'not available'     => 'Not available',
    'invalid domain'    => 'Invalid domain',
);

$domainname = isset($_REQUEST['domainname']) ? $_REQUEST['domainname'] : null;
$tld = isset($_REQUEST['tld']) ? $_REQUEST['tld'] : null;

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '  <table>';
echo '    <tr>';
echo '      <td><input type="text" name="domainname" value="'.$domainname.'" /></td>';
echo '      <td>.</td>';
echo '      <td><select name="tld"><option value="all" '.($tld == 'all' ? 'selected="selected"' : null).'>(all)</option>';

foreach($tlds as $opt) {
    echo '        <option value="'.$opt.'"'.($tld == $opt ? 'selected="selected"' : null).'>'.$opt.'</option>';
}

echo '      </select></td>';
echo '      <td><input type="submit" value="Check" /></td>';
echo '    </tr>';
echo '  </table>';
echo '</form>';

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    if(is_null($domainname) || is_null($tld)) {
        echo '<p>Ongeldige domeinnaam</p>';
    }
    else {
        /**
         * Initiate Realtime Register whois proxy
         */
        require_once 'IsProxy.php';

        $ip = new IsProxy($apikey);

        $tld_check = $tld == 'all' ? $tlds : (array) $tld;

        $tld_count = sizeof($tld_check);
        $a = 0;

        echo '<table>';

        $ip->check($domainname, $tld_check);
        while($result = $ip->result()) {
            $a++;

            echo '<tr><td>'.$result['domain'].'</td><td>'.$text[$result['result']].'</td></tr>';
            flush();

            if($a == $tld_count) {
                $ip->close();

                break;
            }
        }

        echo '</table>';
    }
}

?>

Implement Processes API

Documentation: https://dm.realtimeregister.com/docs/api/processes

Module:

  • Add a ProcessesApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get
  • List
  • #46
  • Resend
  • Cancel

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

Implement Hosts API

Documentation: https://dm.realtimeregister.com/docs/api/hosts

Module:

  • Add a HostsApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get
  • List
  • Create
  • Update
  • Delete

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

Implement Providers API

Documentation: https://dm.realtimeregister.com/docs/api/providers

Module:

  • Add a ProvidersApi module in the Api namespace
  • Add this module to the RealtimeRegister class.

Endpoints:

  • Get
  • List
  • Get downtime
  • List downtime

When implementing the endpoints, make sure to include links to the documentation using the @see annotation in docblocks.

Tests:

  • Add tests for all the added domain objects
  • Add tests for all the added endpoints

Urlencode parameters

As mentioned in the following thread we are missing url encoding on the provided parameters in most of the API clients:
#69 (comment)

For consistency, let's update all methods with parameters that accept strings to urlencode these values before sending it to the RTR API.

Search on listings does nothing.

Currently, on all list endpoints, an optional ?string $search = null is available.

The docs say that this functionality exists, the query parameter q has to be given, this will search across all fields. However the current implementation assigns this value to search instead, this of course, does nothing.

All list endpoints should be updated so the search value is set on the q query parameter instead of search.

The function parameter can stay the same and still be named $search, as this is nice and clear for the user.

Based on the docs, this functionality is available on all list endpoints:

Screenshot 2020-10-03 at 14 46 47

Thanks @tanorojas for spotting this!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.