Skip to content

Commit

Permalink
Merge branch 'HuisingaWS-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
speedster-kiev committed Jun 30, 2014
2 parents 9c4db03 + 62b7668 commit bdc3f72
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Namecheap/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Exception extends \Exception {}
include_once 'Command/Domains/Check.php';
include_once 'Command/Domains/Create.php';
include_once 'Command/Domains/GetTldList.php';
include_once 'Command/Domains/Renew.php';
include_once 'Command/Domains/Dns/SetDefault.php';
include_once 'Command/Domains/Dns/SetCustom.php';
include_once 'Command/Domains/Dns/GetList.php';
Expand All @@ -26,6 +27,7 @@ class Exception extends \Exception {}
include_once 'Command/Domains/Ns/GetInfo.php';
include_once 'Command/Domains/Ns/Update.php';
include_once 'Command/Users/GetBalances.php';
include_once 'Command/Users/GetPricing.php';
include_once 'Command/Users/Address/GetList.php';

class Api
Expand All @@ -39,6 +41,7 @@ class Api
'domains.getContacts' => 'Namecheap\Command\Domains\GetContacts',
'domains.create' => 'Namecheap\Command\Domains\Create',
'domains.check' => 'Namecheap\Command\Domains\Check',
'domains.renew' => 'Namecheap\Command\Domains\Renew',
'domains.getTldList' => 'Namecheap\Command\Domains\GetTldList',
'domains.dns.setDefault' => 'Namecheap\Command\Domains\Dns\SetDefault',
'domains.dns.setCustom' => 'Namecheap\Command\Domains\Dns\SetCustom',
Expand All @@ -50,6 +53,7 @@ class Api
'domains.ns.getInfo' => 'Namecheap\Command\Domains\Ns\GetInfo',
'domains.ns.update' => 'Namecheap\Command\Domains\Ns\Update',
'users.getBalances' => 'Namecheap\Command\Users\GetBalances',
'users.getPricing' => 'Namecheap\Command\Users\GetPricing',
'users.address.getList' => 'Namecheap\Command\Users\Address\GetList',
'users.address.getInfo' => 'Namecheap\Command\Users\Address\GetInfo',
);
Expand Down
2 changes: 1 addition & 1 deletion src/Namecheap/Command/Domains/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function domainName($value = null)
$this->setParam('DomainName', (string) substr($value, 0, 70));
return $this;
}
$this->getParam('DomainName');
return $this->getParam('DomainName');
}
}
}
53 changes: 53 additions & 0 deletions src/Namecheap/Command/Domains/Renew.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Namecheap\Command\Domains\Renew
{
class Exception extends \Exception {}
}

namespace Namecheap\Command\Domains
{
class Renew extends \Namecheap\Command\ACommand
{
public $domain = array();

public function command()
{
return 'namecheap.domains.renew';
}

public function params()
{
return array(
'DomainName' => null,
'Years' => 1,
);
}

/**
* Process domains array
*/
protected function _postDispatch()
{
foreach ($this->_response->DomainRenewResult->attributes() as $key => $value)
{
$this->domain[$key] = (string) $value;
}
}

/**
* Get/set method for domain list, limited to 70 characters
* @param string $value
* @return mixed
*/
public function domainName($value = null)
{
if (null !== $value)
{
$this->setParam('DomainName', (string) substr($value, 0, 70));
return $this;
}
return $this->getParam('DomainName');
}
}
}
53 changes: 53 additions & 0 deletions src/Namecheap/Command/Users/GetPricing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Namecheap\Command\Users\GetPricing
{
class Exception extends \Exception {}
}

namespace Namecheap\Command\Users
{
class GetPricing extends \Namecheap\Command\ACommand
{
public $data = array();

public function command()
{
return 'namecheap.users.getPricing';
}

public function params()
{
return array(
'ProductType' => 'DOMAIN',
'ProductCategory' => null,
);
}

/**
* Process domains array
*/
protected function _postDispatch()
{
foreach ($this->_response->UserGetPricingResult->attributes() as $key => $value)
{
$this->data[$key] = (string) $value;
}
}

/**
* Get/set method for domain list, limited to 1024 characters
* @param string|array $value
* @return mixed
*/
public function domainName($value = null)
{
if (null !== $value)
{
$this->setParam('DomainName', (string) substr($value, 0, 70));
return $this;
}
$this->getParam('DomainName');
}
}
}
34 changes: 34 additions & 0 deletions src/Namecheap/examples/domains.renew.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);

include_once '../Api.php';

try
{
$config = new \Namecheap\Config();
$config->apiUser('api-username')
->apiKey('api-key')
->clientIp('your-ip')
->sandbox(true);

$command = Namecheap\Api::factory($config, 'domains.renew');
$command->setParams(array(
'DomainName' => 'example1.com',
'Years' => 1
))->dispatch();
} catch (\Exception $e) {
die($e->getMessage());
}

if ($command->status() == 'error') { die($command->errorMessage); }
d($command);

function d($value = array())
{
echo '<pre>' . "\n";
print_r($value);
die('</pre>' . "\n");
}
33 changes: 33 additions & 0 deletions src/Namecheap/examples/users.getPricing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);

include_once '../Api.php';

try
{
$config = new \Namecheap\Config();
$config->apiUser('api-username')
->apiKey('api-key')
->clientIp('your-ip')
->sandbox(true);

$command = Namecheap\Api::factory($config, 'users.getPricing');
$command->setParams(array(
'ProductType' => 'DOMAIN',
'ProductCategory' => 'REGISTER'
))->dispatch();
} catch (\Exception $e) {
die($e->getMessage());
}

d($command);

function d($value = array())
{
echo '<pre>' . "\n";
print_r($value);
die('</pre>' . "\n");
}

0 comments on commit bdc3f72

Please sign in to comment.