privyreza/rm-php-sdk

Resell Domains, Hosting, and VPS

3.0.0 2022-10-09 20:30 UTC

This package is auto-updated.

Last update: 2025-05-03 20:48:23 UTC


README

The Resellme PHP SDK provides an easy-to-use interface for interacting with the Resellme API. It allows resellers to manage domains, hosting, VPS, nameservers, and contacts programmatically.

Features

  • Domain Management: Search, register, transfer, and renew domains.
  • Hosting Management: Create, provision, suspend, unsuspend, update, and terminate hosting accounts.
  • VPS Management: Create and manage VPS instances.
  • Nameserver Management: List, update, add, and delete nameservers.
  • Contact Management: Create, update, and retrieve domain contacts.
  • Centralized Request Handling: All API requests are handled through a centralized RequestHandler for consistency and error handling.

Installation

Install the SDK via Composer:

composer require resellme/rm-php-sdk

Usage

Initialize the Client

require 'vendor/autoload.php';

use Resellme\Client;

$client = new Client('your-api-token');

Domain Management

Search for a Domain

$domain = $client->domain()->search('example.com');

Register a Domain

$response = $client->domain()->register([
    'domain' => 'example.com',
    'years' => 1,
    'contact_id' => 'contact-id',
]);

Transfer a Domain

$response = $client->domain()->transfer([
    'domain' => 'example.com',
    'auth_code' => 'auth-code',
    'contact_id' => 'contact-id',
]);

Renew a Domain

$response = $client->domain()->renew('domain-id', [
    'years' => 1,
]);

Hosting Management

Create a Hosting Account

$response = $client->hosting()->create([
    'domain' => 'example.com',
    'plan' => 'basic',
]);

List Hosting Accounts

$hostings = $client->hosting()->list();

Get Hosting Details

$hosting = $client->hosting()->get('hosting-id');

Update a Hosting Account

$response = $client->hosting()->update('hosting-id', [
    'plan' => 'premium',
]);

Suspend a Hosting Account

$response = $client->hosting()->suspend('hosting-id');

Unsuspend a Hosting Account

$response = $client->hosting()->unsuspend('hosting-id');

Terminate a Hosting Account

$response = $client->hosting()->terminate('hosting-id');

VPS Management

Create a VPS

$response = $client->vps()->create([
    'package_id' => 1,
    'hostname' => 'vps.example.com',
]);

Manage a VPS

$response = $client->vps()->manage('vps-id', 'reboot');

Nameserver Management

List Nameservers

$nameservers = $client->nameserver()->list('domain-id');

Update Nameservers

$response = $client->nameserver()->update('domain-id', [
    'ns1.example.com',
    'ns2.example.com',
]);

Add a Nameserver

$response = $client->nameserver()->add('domain-id', 'ns3.example.com');

Delete a Nameserver

$response = $client->nameserver()->delete('domain-id', 'ns3.example.com');

Contact Management

Create a Contact

$response = $client->contact()->create([
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => 'john.doe@example.com',
    'phone' => '+1234567890',
    'address' => '123 Main St',
    'city' => 'Example City',
    'country' => 'US',
]);

Update a Contact

$response = $client->contact()->update('contact-id', [
    'email' => 'new.email@example.com',
]);

Get Contact Details

$contact = $client->contact()->get('contact-id');

Error Handling

The SDK throws exceptions for API errors. You can catch and handle these exceptions as follows:

use Resellme\Exceptions\ApiException;
use Resellme\Exceptions\ServerException;

try {
    $domain = $client->domain()->search('example.com');
} catch (ApiException $e) {
    echo "API Error: " . $e->getMessage();
} catch (ServerException $e) {
    echo "Server Error: " . $e->getMessage();
} catch (\Exception $e) {
    echo "Unexpected Error: " . $e->getMessage();
}

Testing

Run unit tests using PHPUnit:

vendor/bin/phpunit

Contributing

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request with a detailed description of your changes.

License

This SDK is licensed under the MIT License. See the LICENSE file for details.