Skip to content

Commit

Permalink
Added response structures
Browse files Browse the repository at this point in the history
  • Loading branch information
TomCan committed Mar 21, 2018
1 parent dfc42b1 commit d9e5e97
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ array(3) {

## Changelog

**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
Expand Down
21 changes: 21 additions & 0 deletions src/Command/LinuxHostings/GetLinuxHosting.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TomCan\CombellApi\Command\LinuxHostings;

use TomCan\CombellApi\Command\AbstractCommand;
use TomCan\CombellApi\Structure\LinuxHostings\LinuxHosting;

class GetLinuxHosting extends AbstractCommand
{
Expand Down Expand Up @@ -41,4 +42,24 @@ public function setDomainname($domainname)
$this->domainname = $domainname;
}

public function processResponse($response)
{

$h = $response['body'];
$response['response'] = new LinuxHosting(
$h->domain_name,
$h->servicepack_id,
$h->max_webspace_size,
$h->max_size,
$h->webspace_usage,
$h->actual_size,
$h->ip,
$h->ip_type,
$h->ssh_host
);

return $response;

}

}
13 changes: 13 additions & 0 deletions src/Command/LinuxHostings/ListLinuxHostings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TomCan\CombellApi\Command\LinuxHostings;

use TomCan\CombellApi\Command\AbstractCommand;
use TomCan\CombellApi\Structure\LinuxHostings\LinuxHosting;

class ListLinuxHostings extends AbstractCommand
{
Expand All @@ -12,4 +13,16 @@ public function __construct()
parent::__construct("get", "/v2/linuxhostings");
}

public function processResponse($response)
{

$hostings = array();
foreach ($response['body'] as $hosting) {
$hostings[] = new LinuxHosting($hosting->domain_name, $hosting->servicepack_id);
}
$response['response'] = $hostings;

return $response;
}

}
188 changes: 188 additions & 0 deletions src/Structure/LinuxHostings/LinuxHosting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?php

namespace TomCan\CombellApi\Structure\LinuxHostings;


class LinuxHosting
{

private $domainName;
private $servicepackId;
private $maxWebspaceSize;
private $maxSize;
private $webspaceUsage;
private $actualSize;
private $ip;
private $ipType;
private $sshHost;

/**
* LinuxHosting constructor.
* @param $domain_name
* @param $servicepackId
* @param $maxWebspaceSize
* @param $maxSize
* @param $webspaceUsage
* @param $actualSize
* @param $ip
* @param $ipType
* @param $sshHost
*/
public function __construct($domainName, $servicepackId, $maxWebspaceSize = null, $maxSize = null, $webspaceUsage = null, $actualSize = null, $ip = null, $ipType = null, $sshHost = null)
{
$this->domainName = $domainName;
$this->servicepackId = $servicepackId;
$this->maxWebspaceSize = $maxWebspaceSize;
$this->maxSize = $maxSize;
$this->webspaceUsage = $webspaceUsage;
$this->actualSize = $actualSize;
$this->ip = $ip;
$this->ipType = $ipType;
$this->sshHost = $sshHost;
}

/**
* @return mixed
*/
public function getDomainName()
{
return $this->domainName;
}

/**
* @param mixed $domain_name
*/
public function setDomainName($domainName)
{
$this->domainName = $domainName;
}

/**
* @return mixed
*/
public function getServicepackId()
{
return $this->servicepackId;
}

/**
* @param mixed $servicepackId
*/
public function setServicepackId($servicepackId)
{
$this->servicepackId = $servicepackId;
}

/**
* @return null
*/
public function getMaxWebspaceSize()
{
return $this->maxWebspaceSize;
}

/**
* @param null $maxWebspaceSize
*/
public function setMaxWebspaceSize($maxWebspaceSize)
{
$this->maxWebspaceSize = $maxWebspaceSize;
}

/**
* @return null
*/
public function getMaxSize()
{
return $this->maxSize;
}

/**
* @param null $maxSize
*/
public function setMaxSize($maxSize)
{
$this->maxSize = $maxSize;
}

/**
* @return null
*/
public function getWebspaceUsage()
{
return $this->webspaceUsage;
}

/**
* @param null $webspaceUsage
*/
public function setWebspaceUsage($webspaceUsage)
{
$this->webspaceUsage = $webspaceUsage;
}

/**
* @return null
*/
public function getActualSize()
{
return $this->actualSize;
}

/**
* @param null $actualSize
*/
public function setActualSize($actualSize)
{
$this->actualSize = $actualSize;
}

/**
* @return null
*/
public function getIp()
{
return $this->ip;
}

/**
* @param null $ip
*/
public function setIp($ip)
{
$this->ip = $ip;
}

/**
* @return null
*/
public function getIpType()
{
return $this->ipType;
}

/**
* @param null $ipType
*/
public function setIpType($ipType)
{
$this->ipType = $ipType;
}

/**
* @return null
*/
public function getSshHost()
{
return $this->sshHost;
}

/**
* @param null $sshHost
*/
public function setSshHost($sshHost)
{
$this->sshHost = $sshHost;
}

}

0 comments on commit d9e5e97

Please sign in to comment.