Skip to content

Commit a00b0c0

Browse files
committed
Add method to get Pricelist
Release 0.3
1 parent 2a5d3c3 commit a00b0c0

File tree

11 files changed

+147
-39
lines changed

11 files changed

+147
-39
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
/debian/php-subreg/
55
/debian/php-subreg.debhelper.log
66
/debian/php-subreg.substvars
7-
/debian/debhelper-build-stamp
7+
/debian/debhelper-build-stamp
8+
/tests/.phpunit.result.cache
9+
/.phpunit.result.cache

Examples/GetPriceList.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Subreg - RegisterDomain Example
4+
*
5+
* @author Vítězslav Dvořák <[email protected]>
6+
* @copyright (C) 2019 Spoje.Net
7+
*/
8+
9+
namespace Subreg;
10+
11+
require_once '../vendor/autoload.php';
12+
13+
\Ease\Shared::instanced()->loadConfig('../config.json');
14+
15+
$client = new Client(\Ease\Shared::instanced()->configuration);
16+
17+
18+
19+
print_r($client->pricelist());
20+

debian/changelog

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
php-subreg (0.2-1) UNRELEASED; urgency=medium
1+
php-subreg (0.3) unstable; urgency=medium
22

3-
* debianized
3+
* new support for Pricelist command
44

5-
-- Vítězslav Dvořák <[email protected]> Mon, 04 Mar 2019 00:01:29 +0100
5+
-- Vítězslav Dvořák <[email protected]> Wed, 29 May 2019 16:21:24 +0200

debian/files

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
php-subreg_0.2-1_all.buildinfo web optional
2-
php-subreg_0.2-1_all.deb web optional
1+
php-subreg_0.3_all.buildinfo web optional
2+
php-subreg_0.3_all.deb web optional

debian/fixversion.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ VERSTR=`dpkg-parsechangelog --show-field Version`
33
COMPOSER_VERSTR=`echo ${VERSTR}|sed 's/-/./g'`
44
echo update debian/php-subreg/usr/share/php/Subreg/composer.json version to ${COMPOSER_VERSTR}
55
sed -i -e '/\"version\"/c\ \"version\": \"'${COMPOSER_VERSTR}'",' debian/php-subreg/usr/share/php/Ease/composer.json
6-
echo Update debian/php-subreg/usr/share/php/Ease/Atom.php version to ${VERSTR}
7-
sed -i -e "/static public \$libVersion/c\ static public \$frameworkVersion = '${VERSTR}';" debian/php-subreg/usr/share/php/Subreg/Client.php
6+
echo Update debian/php-subreg/usr/share/php/Subreg/Client.php version to ${VERSTR}
7+
sed -i -e "/static public \$libVersion/c\ static public \$libVersion = '${VERSTR}';" debian/php-subreg/usr/share/php/Subreg/Client.php
88
echo Update src/Ease/Atom.php version to ${VERSTR}
9-
sed -i -e "/static public \$libVersion/c\ static public \$frameworkVersion = '${VERSTR}';" src/Subreg/Client.php
9+
sed -i -e "/static public \$libVersion/c\ static public \$libVersion = '${VERSTR}';" src/Subreg/Client.php

nbproject/project.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_create_2e_tests=false
1+
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_create_2e_tests=true
22
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_enabled=true
33
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_path=tests/bootstrap.php
44
auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_enabled=true
5-
auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_path=tests/configuration.xml
5+
auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_path=phpunit.xml
66
auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_enabled=false
77
auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_path=
8-
auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_enabled=false
9-
auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_path=
8+
auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_enabled=true
9+
auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_path=vendor/bin/phpunit
1010
auxiliary.org-netbeans-modules-php-phpunit.test_2e_groups_2e_ask=false
1111
auxiliary.org-netbeans-modules-php-phpunit.test_2e_run_2e_all=false
1212
auxiliary.org-netbeans-modules-php-phpunit.test_2e_run_2e_phpunit_2e_only=false

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<phpunit colors="true" bootstrap="./testing/bootstrap.php">
33
<testsuites>
44
<testsuite name="all">
5-
<directory>./testing</directory>
5+
<directory>./tests</directory>
66
</testsuite>
77
</testsuites>
88

src/Subreg/Client.php

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Client extends \Ease\Molecule
1919
* ClientLibrary version
2020
* @var string
2121
*/
22-
static public $frameworkVersion = '0.1';
22+
static public $libVersion = '0.3';
2323

2424
/**
2525
* Object Configuration
@@ -74,6 +74,20 @@ public function __construct($config)
7474
$this->login();
7575
}
7676

77+
/**
78+
* Add Info about used user, server and libraries
79+
*
80+
* @param string $additions Additional note text
81+
*
82+
* @return boolean was logged ?
83+
*/
84+
public function logBanner($additions = null)
85+
{
86+
return $this->addStatusMessage('API '.str_replace('://',
87+
'://'.$this->config['login'].'@', $this->config['uri']).' php-subreg v'.self::$libVersion.' EasePHP Framework v'.\Ease\Atom::$frameworkVersion.' '.$additions,
88+
'debug');
89+
}
90+
7791
/**
7892
* API Call
7993
*
@@ -92,19 +106,24 @@ public function call($command, $params = [])
92106
}
93107
$responseRaw = $this->soaper->__call($command, ['data' => $params]);
94108

109+
95110
if (isset($responseRaw['status'])) {
96111
$this->lastStatus = $responseRaw['status'];
97-
if ($this->lastStatus == 'error') {
98-
$this->logError($responseRaw['error']);
112+
switch ($responseRaw['status']) {
113+
case 'ok':
114+
if (array_key_exists('data', $responseRaw)) {
115+
$this->lastResult = $responseRaw['data'];
116+
} else {
117+
$this->lastResult = $this->lastStatus;
118+
}
119+
break;
120+
case 'error':
121+
$this->logError($responseRaw['error']);
122+
$this->lastResult = ['error' => $responseRaw['error']];
123+
break;
99124
}
100125
}
101126

102-
if (array_key_exists('data', $responseRaw)) {
103-
$this->lastResult = $responseRaw['data'];
104-
} else {
105-
$this->lastResult = $this->lastStatus;
106-
}
107-
108127
return $this->lastResult;
109128
}
110129

@@ -222,4 +241,16 @@ public function domainsList()
222241
{
223242
return $this->call('Domains_List');
224243
}
244+
245+
/**
246+
* Get pricelist from your account
247+
*
248+
* @link https://subreg.cz/manual/?cmd=Pricelist Command: Pricelist
249+
*
250+
* @return array
251+
*/
252+
public function pricelist()
253+
{
254+
return $this->call('Pricelist');
255+
}
225256
}

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
define('EASE_LOGGER', 'syslog');
2525
}
2626

27-
\Ease\Shared::instanced()->loadConfig('../config.json',true);
27+
\Ease\Shared::instanced()->loadConfig('config.json',true);
2828

tests/configuration.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)