krencl/wedos-api

There is no license information available for the latest version (1.0.3) of this package.

Wedos API client for PHP

1.0.3 2019-07-19 17:39 UTC

This package is auto-updated.

Last update: 2024-05-20 04:32:22 UTC


README

PHP API client for communication with Wedos API.

Installation

composer require krencl/wedos-api

Usage

Configuration

From JSON file, in root path is sample file config.json.dist:

<?php

use Krencl\WedosApi\Configuration;

$configuration = Configuration::createFromFile(__DIR__ . '/config.json');

Or hardcoded:

<?php

use Krencl\WedosApi\Configuration;

$configuration = new Configuration('user', 'password');

// optional
$configuration->setTestingMode(true);
$configuration->setUrl('https://...');

Request

Using built-in command:

<?php

use Krencl\WedosApi\Command;
use Krencl\WedosApi\Constants;

/** @var \Krencl\WedosApi\Request $command */
$command = new Command\DomainsList(Constants\DomainStatus::ACTIVE);

Or create custom request:

<?php

use Krencl\WedosApi\Request;
use Krencl\WedosApi\Constants;

$request = new Request('domains-list', [
	'status' => Constants\DomainStatus::ACTIVE,
]);

Example

<?php

use Krencl\WedosApi\Client;
use Krencl\WedosApi\Configuration;
use Krencl\WedosApi\Command;
use Krencl\WedosApi\Constants;
use Krencl\WedosApi\Exception\ResponseException;

$configuration = Configuration::createFromFile(__DIR__ . '/../config.json.dist');
$client = new Client($configuration);

$clTRID = 'myCustomId-1';
$command = new Command\DomainsList(Constants\DomainStatus::ACTIVE, $clTRID);

try {
	$response = $client->sendRequest($command);
	var_dump($response->getData());
} catch (ResponseException $e) {
	echo (string) $e;
	var_dump($e->getResponse()->getCurlResult());
}

Wedos API documentation

https://kb.wedos.com/cs/wapi.html