Skip to content

Commit

Permalink
Merge pull request #3 from tvlooy/rework
Browse files Browse the repository at this point in the history
Rework version 3.0.0
  • Loading branch information
tvlooy authored Oct 25, 2019
2 parents 1ddc958 + a1d2b2b commit ab053e3
Show file tree
Hide file tree
Showing 116 changed files with 7,312 additions and 3,232 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
.phpunit.result.cache
tests/_reports
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ language: php

php:
- 7.2
- 7.3
- 7.4snapshot

script:
- ./vendor/bin/phpunit
- composer install
- make test

20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: all test lint phpunit debug phpstan
.RECIPEPREFIX = |

all: lint phpstan phpunit
| xdg-open tests/_reports/coverage/index.html

test: lint phpstan phpunit

lint:
| find src -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | (! grep -v "No syntax errors detected" )

phpunit:
| php -dzend_extension=xdebug ./vendor/bin/phpunit

debug:
| DEBUG_DUMPS=1 php -dzend_extension=xdebug ./vendor/bin/phpunit

phpstan:
| php -dmemory_limit=-1 ./vendor/bin/phpstan analyse --level=7 src

171 changes: 45 additions & 126 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,141 +1,60 @@
# TomCan\combell-api
This is my take on the Combell shared-hosting API. The goal is to provide a set of classes that will allow you to easely interact with the API.
# tomcan\combell-api

## Current status
Since the Combell API is still in development and new functionality is added regulary, this library might not implement every call yet. I do try to keep it up-to-date as much as possible. If there are calls missing, please let me know!
This is a Combell shared-hosting API client implementation. The goal is to provide a client library that makes it
easy for you to interact with the Combell shared hosting public API.

## Usage
You can install the library through composer
```
composer install tomcan/combell-api
```
Next, you need to include the composer autoloader. Instantiate the API object with your API key and secret, create the command objects and fire away!
```php
<?php
## Current status

require dirname(__DIR__) . '/vendor/autoload.php';
Since the Combell API is still in development and new functionality is added regularly, this library might not implement
every call yet. We do try to keep it up-to-date as much as possible. If there are calls missing, please open an issue
to tell us about it or even a pull request to add the call!

$key = "YOUR-API-KEY";
$sec = "YOUR-API-SECRET";
## Usage

$adapter = new \TomCan\CombellApi\Adapter\GuzzleAdapter();
$api = new \TomCan\CombellApi\Common\Api($key, $sec, $adapter);
$cmd = new \TomCan\CombellApi\Command\Accounts\ListAccounts();
var_dump($api->ExecuteCommand($cmd));
You can install the library through composer:

?>
```bash
composer install tomcan/combell-api
```
The command will return an array containing 4 elements.

**status**
Next, you need to include the composer autoloader. Instantiate the API object with your API key and secret, create the
command objects and fire away!

This contains the HTTP status code of the response. 200 -> 204 indicate success. Other codes typically mean failure of some sort.

**headers**

This contains an array of http headers of the response in a key/value manner, where value is always an array, even if only one value is returned.

**body**

If the response contained a body, this will be the json_decoded object of that response.

**response**

As of version 2.0.0, some responses will also have a "response" element containing the processed response of the command. This is typically a set of specific classes (see Structure namespace) for the command, like a list of DNS records where each type has it's own class. More and more commands will be transformed to this structure.

As of version 3.0.0, the entire response array will be replaced by it's own object instead of array and support for the body element will be dropped.

```
array(3) {
["status"]=>
int(200)
["headers"]=>
array(10) {
["X-RateLimit-Limit"]=>
array(1) {
[0]=>
string(3) "100"
}
...
}
["body"]=>
array(25) {
[0]=>
object(stdClass)#29 (2) {
["id"]=>
int(12345)
["identifier"]=>
string(12) "domain.tld"
}
[1]=>
object(stdClass)#27 (2) {
["id"]=>
int(12346)
["identifier"]=>
string(12) "domain2.tld"
}
...
}
["response"]=>
array(25) {
[0]=>
object(TomCan\CombellApi\Structure\Accounts\Account)#37 (2) {
["id":"TomCan\CombellApi\Structure\Accounts\Account":private]=>
int(12345)
["identifier":"TomCan\CombellApi\Structure\Accounts\Account":private]=>
string(12) "domain.tld"
}
[1]=>
object(TomCan\CombellApi\Structure\Accounts\Account)#39 (2) {
["id":"TomCan\CombellApi\Structure\Accounts\Account":private]=>
int(12346)
["identifier":"TomCan\CombellApi\Structure\Accounts\Account":private]=>
string(12) "domain2.tld"
}
...
}
}
```php
require __DIR__ . '/vendor/autoload.php';

$key = 'YOUR-API-KEY';
$sec = 'YOUR-API-SECRET';

$api = new \TomCan\CombellApi\Common\Api(
new \TomCan\CombellApi\Adapter\GuzzleAdapter(),
new \TomCan\CombellApi\Common\HmacGenerator($key, $sec)
);
$cmd = new \TomCan\CombellApi\Command\Accounts\ListAccounts();

var_dump($api->executeCommand($cmd));
```

## Changelog
The command will return the data of the call, in the example above that is an array with Account objects. See the test
directory for extensive examples of all the calls.

**25-10-2019 - v2.0.8**
If you need information about the HTTP call, you can ask the api object about it:

- Implement configure FTP

**02-04-2019 - v2.0.7**

- Implement HTTP/2 setting

**24-01-2019 - v2.0.6**

- Implement username support from the API

**21-01-2019 - v2.0.5**

- Added command to get Mysql database

**21-03-2018 - v2.0.4**

- Added structured representation to LinuxHostings namespace

**20-03-2018 - v2.0.3**

- Added structured representation to MysqlDatabases and Servicepacks namespace
- Added DNS AAAA Record Type

**20-03-2018 - v2.0.2**

- Added Structured representation to Domains and ProvisioningJobs namespace

**19-03-2018 - v2.0.0**

- We now have a changelog in this file
- Reorganised the namespaces to be able to differentiate between Commands and Structures.
- The Account and DNS commands now also return a Structured representation of the objects in the "response" element of the returned array, rather than only the json_decoded body.
- The DNS portion of the API has been redone using the new methods the API provides.
- Known issue: although implemented according to the specs, the UpdateRecord command yields an Internal Server error. Since no data is available regarding the details of the error, we can only assume this is a problem on Combells side.
```php
// return the HTTP status code. 200 -> 204 indicate success, other codes typically mean failure of some sort
$api->getStatusCode();

// rate limiting headers
$api->getRateLimitUsage();
$api->getRateLimitRemaining();
$api->getRateLimitReset();
$api->getRateLimitLimit();
```

**pre 19-03-2018**
If the command is pageable, you can get info about the paging from the command object:

- No changelog has been kept prior to this point. If you really need to know, please see the Git history to get an idead of what changed.
```php
$cmd->getPagingSkipped();
$cmd->getPagingTake();
$cmd->getPagingTotalResults();
```
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "tomcan/combell-api",
"description": "Wrapper libraries for Combell public API on their shared hosting environment.",
"description": "Client libraries for the Combell shared hosting public API.",
"keywords": ["Combell","API"],
"license": "MIT",
"autoload": {
"psr-4": {"TomCan\\CombellApi\\": "src/"}
},
"require": {
"php": ">=5.5",
"php": ">=7.2",
"guzzlehttp/guzzle": "~6.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
"phpunit/phpunit": "^8.4",
"phpstan/phpstan": "^0.11.1",
"symfony/phpunit-bridge": "^4.3"
}
}
Loading

0 comments on commit ab053e3

Please sign in to comment.