Skip to content
This repository was archived by the owner on Jul 29, 2020. It is now read-only.

Commit 1f4dca4

Browse files
committed
Fixed url parameters overriding
1 parent ba5f526 commit 1f4dca4

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

src/FlexiPeeHP/FlexiBeeRO.php

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class FlexiBeeRO extends \Ease\Sand
366366
* @var boolean
367367
*/
368368
public $offline = false;
369-
369+
370370
/**
371371
* Override cURL timeout
372372
* @var int seconds
@@ -470,7 +470,7 @@ public function getConnectionOptions()
470470
if (!empty($company)) {
471471
$conOpts['company'] = $company;
472472
}
473-
if(!is_null($this->timeout)){
473+
if (!is_null($this->timeout)) {
474474
$conOpts['timeout'] = $this->timeout;
475475
}
476476
return $conOpts;
@@ -495,7 +495,7 @@ public function curlInit()
495495
curl_setopt($this->curl, CURLOPT_USERPWD,
496496
$this->user.':'.$this->password); // set username and password
497497
}
498-
if(!is_null($this->timeout)){
498+
if (!is_null($this->timeout)) {
499499
curl_setopt($this->curl, CURLOPT_TIMEOUT, $this->timeout);
500500
}
501501
}
@@ -614,6 +614,7 @@ public function setPrefix($prefix)
614614
* One of html|xml|json|csv|dbf|xls|isdoc|isdocx|edi|pdf|pdf|vcf|ical
615615
*
616616
* @param string $format
617+
*
617618
* @return boolen format is availble
618619
*/
619620
public function setFormat($format)
@@ -637,6 +638,7 @@ public function setFormat($format)
637638
* Set evidence for communication
638639
*
639640
* @param string $evidence evidence pathName to use
641+
*
640642
* @return boolean evidence switching status
641643
*/
642644
public function setEvidence($evidence)
@@ -827,12 +829,12 @@ public function updateApiURL()
827829
* Add params to url
828830
*
829831
* @param string $url originall url
830-
* @param array $params value to add
832+
* @param array $addParams value to add
831833
* @param boolean $override replace already existing values ?
832834
*
833835
* @return string url with parameters added
834836
*/
835-
public function addUrlParams($url, $params, $override = false)
837+
public function addUrlParams($url, $addParams, $override = false)
836838
{
837839
$urlParts = parse_url($url);
838840
$urlFinal = '';
@@ -847,10 +849,10 @@ public function addUrlParams($url, $params, $override = false)
847849
}
848850
if (array_key_exists('query', $urlParts)) {
849851
parse_str($urlParts['query'], $queryUrlParams);
850-
$urlParams = $override ? array_merge($params, $queryUrlParams) : array_merge($queryUrlParams,
851-
$params);
852+
$urlParams = $override ? array_merge($queryUrlParams, $addParams) : array_merge($addParams,
853+
$queryUrlParams);
852854
} else {
853-
$urlParams = $params;
855+
$urlParams = $addParams;
854856
}
855857

856858
if (!empty($urlParams)) {
@@ -882,6 +884,7 @@ public function addDefaultUrlParams($urlRaw)
882884
* @param string $urlSuffix část URL za identifikátorem firmy.
883885
* @param string $method HTTP/REST metoda
884886
* @param string $format Requested format
887+
*
885888
* @return array|boolean Výsledek operace
886889
*/
887890
public function performRequest($urlSuffix = null, $method = 'GET',
@@ -1023,6 +1026,7 @@ public function parseResponse($responseDecoded, $responseCode)
10231026
* Parse error message response
10241027
*
10251028
* @param array $responseDecoded
1029+
*
10261030
* @return int number of errors processed
10271031
*/
10281032
public function parseError(array $responseDecoded)
@@ -1044,6 +1048,7 @@ public function parseError(array $responseDecoded)
10441048
* @param string $url URL požadavku
10451049
* @param string $method HTTP Method GET|POST|PUT|OPTIONS|DELETE
10461050
* @param string $format požadovaný formát komunikace
1051+
*
10471052
* @return int HTTP Response CODE
10481053
*/
10491054
public function doCurlRequest($url, $method, $format = null)
@@ -1103,6 +1108,7 @@ public function doCurlRequest($url, $method, $format = null)
11031108
*
11041109
* @link https://demo.flexibee.eu/devdoc/actions Provádění akcí
11051110
* @param string $action
1111+
*
11061112
* @return boolean
11071113
*/
11081114
public function setAction($action)
@@ -1437,6 +1443,7 @@ public function idExists($identifer = null)
14371443
* Test if given record exists in FlexiBee.
14381444
*
14391445
* @param array|string|int $data ext:id:23|code:ITEM|['id'=>23]|23
1446+
*
14401447
* @return boolean Record presence status
14411448
*/
14421449
public function recordExists($data = [])
@@ -1600,6 +1607,7 @@ public function getKod($data = null, $unique = true)
16001607
*
16011608
* @param array $resultData
16021609
* @param string $url URL
1610+
*
16031611
* @return boolean Log save success
16041612
*/
16051613
public function logResult($resultData = null, $url = null)
@@ -1775,6 +1783,7 @@ public function getRecordIdent()
17751783
* Vrací identifikátor objektu code: nebo id:
17761784
*
17771785
* @link https://demo.flexibee.eu/devdoc/identifiers Identifikátory záznamů
1786+
*
17781787
* @return string indentifikátor záznamu reprezentovaného objektem
17791788
*/
17801789
public function __toString()
@@ -1786,6 +1795,7 @@ public function __toString()
17861795
* Gives you FlexiPeeHP class name for Given Evidence
17871796
*
17881797
* @param string $evidence
1798+
*
17891799
* @return string Class name
17901800
*/
17911801
public static function evidenceToClassName($evidence)
@@ -1814,6 +1824,7 @@ public function getFirstRecordID()
18141824
* Vrací hodnotu daného externího ID
18151825
*
18161826
* @param string $want Which ? If empty,you obtain the first one.
1827+
*
18171828
* @return string
18181829
*/
18191830
public function getExternalID($want = null)
@@ -1841,6 +1852,7 @@ public function getExternalID($want = null)
18411852
* Vrací aktuální globální verzi změn
18421853
*
18431854
* @link https://www.flexibee.eu/api/dokumentace/ref/changes-api#globalVersion Globální Verze
1855+
*
18441856
* @return type
18451857
*/
18461858
public function getGlobalVersion()
@@ -1882,6 +1894,7 @@ public function getResponseFormat()
18821894
* Return the same response format for one and multiplete results
18831895
*
18841896
* @param array $responseBody
1897+
*
18851898
* @return array
18861899
*/
18871900
public function unifyResponseFormat($responseBody)
@@ -1918,6 +1931,7 @@ public function unifyResponseFormat($responseBody)
19181931
* Obtain structure for current (or given) evidence
19191932
*
19201933
* @param string $evidence
1934+
*
19211935
* @return array Evidence structure
19221936
*/
19231937
public function getColumnsInfo($evidence = null)
@@ -1950,6 +1964,7 @@ public function getColumnInfo($column, $evidence = null)
19501964
* Obtain actions for current (or given) evidence
19511965
*
19521966
* @param string $evidence
1967+
*
19531968
* @return array Evidence structure
19541969
*/
19551970
public function getActionsInfo($evidence = null)
@@ -1969,6 +1984,7 @@ public function getActionsInfo($evidence = null)
19691984
* Obtain relations for current (or given) evidence
19701985
*
19711986
* @param string $evidence
1987+
*
19721988
* @return array Evidence structure
19731989
*/
19741990
public function getRelationsInfo($evidence = null)
@@ -1988,6 +2004,7 @@ public function getRelationsInfo($evidence = null)
19882004
* Obtain info for current (or given) evidence
19892005
*
19902006
* @param string $evidence
2007+
*
19912008
* @return array Evidence info
19922009
*/
19932010
public function getEvidenceInfo($evidence = null)
@@ -2006,6 +2023,7 @@ public function getEvidenceInfo($evidence = null)
20062023
* Obtain name for current (or given) evidence path
20072024
*
20082025
* @param string $evidence Evidence Path
2026+
*
20092027
* @return array Evidence info
20102028
*/
20112029
public function getEvidenceName($evidence = null)
@@ -2077,6 +2095,7 @@ public function getFlexiBeeURL()
20772095
* Set Record Key
20782096
*
20792097
* @param int|string $myKeyValue
2098+
*
20802099
* @return boolean
20812100
*/
20822101
public function setMyKey($myKeyValue)
@@ -2132,9 +2151,10 @@ public function sendByMail($to, $subject, $body, $cc = null)
21322151
}
21332152

21342153
/**
2135-
* Send all unsent Invoices by mail
2154+
* Send all unsent Documents by eMail
21362155
*
21372156
* @url https://www.flexibee.eu/api/dokumentace/ref/odesilani-mailem/
2157+
*
21382158
* @return int http response code
21392159
*/
21402160
public function sendUnsent()

testing/src/FlexiPeeHP/FlexiBeeROTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ public function testSetUp()
159159
*/
160160
public function testGetConnectionOptions()
161161
{
162-
$options = $this->object->getConnectionOptions();
162+
$options = $this->object->getConnectionOptions();
163163
$this->assertArrayHasKey('url', $options);
164-
$this->object->timeout = 120;
164+
$this->object->timeout = 120;
165165
$this->object->authSessionId = 'sessid';
166166
$this->object->setCompany('test');
167167
$this->object->getConnectionOptions();
@@ -997,7 +997,7 @@ public function testJoin()
997997
*/
998998
public function testAddUrlParams()
999999
{
1000-
$this->assertEquals('http://vitexsoftware.cz/path?id=1&a=b',
1000+
$this->assertEquals('http://vitexsoftware.cz/path?a=b&id=1',
10011001
$this->object->addUrlParams('http://vitexsoftware.cz/path?a=b',
10021002
['id' => 1], TRUE));
10031003
}
@@ -1011,7 +1011,7 @@ public function testAddDefaultUrlParams()
10111011
$this->assertEquals('http://vitexsoftware.cz?a=b',
10121012
$this->object->addDefaultUrlParams('http://vitexsoftware.cz?a=b'));
10131013
$this->object->defaultUrlParams['id'] = 1;
1014-
$this->assertEquals('http://vitexsoftware.cz/path?a=b&id=1',
1014+
$this->assertEquals('http://vitexsoftware.cz/path?id=1&a=b',
10151015
$this->object->addDefaultUrlParams('http://vitexsoftware.cz/path?a=b'));
10161016
}
10171017

@@ -1035,6 +1035,9 @@ public function testSetDataValue()
10351035
if (!empty($this->object->getColumnsInfo())) {
10361036
$this->object->setDataValue('datVyst', new \DateTime());
10371037
}
1038+
$this->object->setDataValue('test', 'test');
1039+
$this->object->setDataValue('kod', 'code:testKOD');
1040+
$this->assertEquals('testKOD', $this->object->getDataValue('kod'));
10381041
}
10391042

10401043
/**

0 commit comments

Comments
 (0)