Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hampel/synergy-wholesale
Synergy Wholesale API wrapper using SoapClient
https://github.com/hampel/synergy-wholesale
api-client dns domains soapclient synergywholesale
Last synced: about 1 month ago
JSON representation
Synergy Wholesale API wrapper using SoapClient
- Host: GitHub
- URL: https://github.com/hampel/synergy-wholesale
- Owner: hampel
- License: mit
- Created: 2023-06-10T02:23:59.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-12T06:22:25.000Z (about 1 year ago)
- Last Synced: 2024-06-22T19:04:27.212Z (6 months ago)
- Topics: api-client, dns, domains, soapclient, synergywholesale
- Language: PHP
- Homepage:
- Size: 224 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
Synergy Wholesale API Wrapper
=============================[![Latest Version on Packagist](https://img.shields.io/packagist/v/hampel/synergy-wholesale.svg?style=flat-square)](https://packagist.org/packages/hampel/synergy-wholesale)
[![Total Downloads](https://img.shields.io/packagist/dt/hampel/synergy-wholesale.svg?style=flat-square)](https://packagist.org/packages/hampel/synergy-wholesale)
[![Open Issues](https://img.shields.io/github/issues-raw/hampel/synergy-wholesale.svg?style=flat-square)](https://github.com/hampel/synergy-wholesale/issues)
[![License](https://img.shields.io/packagist/l/hampel/synergy-wholesale.svg?style=flat-square)](https://packagist.org/packages/hampel/synergy-wholesale)A Synergy Wholesale API wrapper using SoapClient
By [Simon Hampel](mailto:[email protected])
Installation
------------To install using composer, run the following command:
`composer require hampel/synergy-wholesale`
Note that if you intend to use this package with Laravel, we recommend installing the
[hampel/synergy-wholesale-laravel](https://packagist.org/packages/hampel/synergy-wholesale-laravel) package instead,
which provides a simple Laravel service provider and Facade for working with this API wrapper. The Laravel version
automatically links into the Laravel logging system as well, making it easy to keep track of issues with the API.Usage
-----You will need to turn on API access in your Synergy Wholesale control panel, which will tell you your Reseller ID. You
also need to add the IP address of your web server to the IP whitelist to enable an API key.Specify the Reseller ID and API Key as parameters to the SynergyWholesle constructor.
You can optionally specify a logging implementation which uses the psr/log interface
(eg [Monolog](https://github.com/Seldaek/monolog)), which will enable the API calls and responses to be logged for
debugging and error tracking purposes.This API wrapper provides a rich object-oriented interface to the API calls, using value objects to construct inputs
which provide granular validation of input data.Raw responses from the API are stdClass objects containing public properties with the response values. This wrapper
processes and validates these responses and provides a richer interface for accessing the returned data.Exceptions are thrown on errors.
__Long-hand Initialisation Example__
```php
// start by creating a SoapClient with the location of the WSDL file supplied by Synergy Wholesale
$client = new SoapClient(null, array('location' => SynergyWholesale::WSDL_URL, 'uri' => ''));// create a Response generator (the engine which maps command objects to response objects)
$responseGenerator = new \SynergyWholesale\BasicResponseGenerator();// now we can build our command execution engine, pass "null" for the logger if we don't have one
$sw = new \SynergyWholesale\SynergyWholesale($client, $responseGenerator, null, "reseller_id", "api_key");
```__Alternative Static Factory Example__
```php
// does all the heavy lifting for you if you don't need a logger
$sw = \SynergyWholesale\SynergyWholesale::make("reseller_id", "api_key");
```__Balance Query Command Example__
```php
// create a command object for the SynergyWholesale service to execute
$command = new BalanceQueryCommand(); // no parameters required for this call!// execute the command
try {
$response = $sw->execute($command);
}
catch (Exception $e) {
// different exceptions are thrown on different types of errors
// you can be as coarse or as granular as you like with error handling
exit("Error executing command: " . $e->getMessage());
}echo "Account balance: " . $response->getBalance();
```__Domain Information Command Example__
```php
// need to create a Domain object first
try {
$domain = new \SynergyWholesale\Types\Domain('example.com');
}
catch (\SynergyWholesale\Exception\InvalidArgumentException $e) {
exit("Error building domain object: " . $e->getMessage());
}// pass this as a parameter to the command
$command = new DomainInfoCommand($domain);// execute the command
try {
$response = $sw->execute($command);
}
catch (Exception $e) {
exit("Error executing command: " . $e->getMessage());
}echo "
// check availability of a domain for registration
$command = new CheckDomainCommand('example.com');
$response = $sw->execute($command);var_dump($response);
```
Notes
-----
Only the Domain Name and SMS API calls have been implementedTODO:
* Implement all the other calls to the SynergyWholesale API