Skip to content

Commit b62de4c

Browse files
committed
Fix: Add tests, Optimize Sessions
1 parent 7e663b0 commit b62de4c

11 files changed

Lines changed: 299 additions & 130 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ PhpWrapperProffix.phar
1616
box.json
1717
box.phar
1818
manifest.json
19-
phpunit.xml
19+
.cache
20+
.phpunit.cache

bootstrap.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<?php
2-
require_once("vendor\autoload.php");
3-
require_once("src\RestAPIWrapperProffix\RestAPIWrapperProffix.php");
4-
require_once("src\RestAPIWrapperProffix\Exception\HttpException.php");
2+
// bootstrap.php
3+
require_once __DIR__ . '/vendor/autoload.php';

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "pitwch/rest-api-wrapper-proffix-php",
33
"description": "PHP Wrapper for PROFFIX REST API",
44
"type": "library",
5+
"version": "1.9.0",
56
"homepage": "https://www.pitw.ch",
67
"license": "MIT",
78
"authors": [
@@ -26,6 +27,9 @@
2627
}
2728
},
2829
"autoload-dev": {
29-
"psr-4": { "Pitwch\\RestAPIWrapperProffix\\Tests\\": "tests/RestAPIWrapperProffix" }
30+
"psr-4": {
31+
"Pitwch\\RestAPIWrapperProffix\\Tests\\": "tests/RestAPIWrapperProffix/",
32+
"Pitwch\\RestAPIWrapperProffix\\Tests\\Integration\\": "tests/Integration/"
33+
}
3034
}
3135
}

composer.lock

Lines changed: 26 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,56 @@
11
<?php
22

3-
43
namespace Pitwch\RestAPIWrapperProffix;
54

65
use Pitwch\RestAPIWrapperProffix\HttpClient\HttpClient;
76

8-
97
/**
108
* Class Client
119
*
1210
* @package Pitwch\RestAPIWrapperProffix
1311
*/
1412
class Client
1513
{
14+
protected $httpClient;
1615

17-
const VERSION = '1.3';
18-
19-
20-
/**
21-
* @var HttpClient
22-
*/
23-
protected $http;
24-
25-
/**
26-
* Client constructor.
27-
*
28-
* @param string $url The Proffix API URL
29-
* @param string $apiDatabase The Proffix Database
30-
* @param string $apiUser The Proffix User
31-
* @param string $apiPassword The Proffix Password
32-
* @param array $apiModules The required Proffix Modules
33-
* @param array $options Additional options
34-
*
35-
* @throws HttpClient\HttpClientException
36-
*/
3716
public function __construct($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options = [])
3817
{
39-
$this->http = new HttpClient($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options);
18+
$this->httpClient = new HttpClient($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options);
4019
}
4120

42-
43-
/**
44-
* @param string $endpoint
45-
* @param array $data
46-
*
47-
* @return mixed
48-
*
49-
* @throws HttpClient\HttpClientException
50-
*/
51-
public function post($endpoint, $data)
21+
public function getHttpClient()
5222
{
53-
return $this->http->request($endpoint, 'POST', $data);
23+
return $this->httpClient;
5424
}
5525

56-
/**
57-
* @param string $endpoint
58-
* @param array $data
59-
*
60-
* @return mixed
61-
*
62-
* @throws HttpClient\HttpClientException
63-
*/
64-
public function put($endpoint, $data)
26+
public function get($endpoint, $parameters = [])
6527
{
66-
return $this->http->request($endpoint, 'PUT', $data);
28+
return $this->httpClient->request($endpoint, 'GET', [], $parameters);
6729
}
6830

69-
/**
70-
* @param string $endpoint
71-
* @param array $parameters
72-
*
73-
* @return mixed
74-
*
75-
* @throws HttpClient\HttpClientException
76-
*/
77-
public function get($endpoint, $parameters = [])
31+
public function post($endpoint, $data = [])
7832
{
33+
return $this->httpClient->request($endpoint, 'POST', $data);
34+
}
7935

80-
return $this->http->request($endpoint, 'GET', [], $parameters);
36+
public function put($endpoint, $data = [])
37+
{
38+
return $this->httpClient->request($endpoint, 'PUT', $data);
8139
}
8240

83-
/**
84-
* @param string $endpoint
85-
* @param array $parameters
86-
*
87-
* @return mixed
88-
*
89-
* @throws HttpClient\HttpClientException
90-
*/
9141
public function delete($endpoint, $parameters = [])
9242
{
93-
return $this->http->request($endpoint, 'DELETE', [], $parameters);
43+
return $this->httpClient->request($endpoint, 'DELETE', [], $parameters);
9444
}
9545

96-
/**
97-
* @param string $px_api_key
98-
*
99-
* @return mixed
100-
*
101-
* @throws HttpClient\HttpClientException
102-
*/
10346
public function info($px_api_key = '')
10447
{
105-
return $this->http->request('PRO/Info', 'GET', [], ['key' => $px_api_key], false);
48+
return $this->httpClient->request('PRO/Info', 'GET', [], ['key' => $px_api_key], false);
10649
}
10750

108-
/**
109-
* @param string $px_api_key
110-
*
111-
* @return mixed
112-
*
113-
* @throws HttpClient\HttpClientException
114-
*/
11551
public function database($px_api_key = '')
11652
{
117-
return $this->http->request('PRO/Datenbank', 'GET', [], ['key' => $px_api_key], false);
53+
return $this->httpClient->request('PRO/Datenbank', 'GET', [], ['key' => $px_api_key], false);
11854
}
119-
120-
12155
}
56+

0 commit comments

Comments
 (0)