Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ PhpWrapperProffix.phar
box.json
box.phar
manifest.json
phpunit.xml
.cache
.phpunit.cache
5 changes: 2 additions & 3 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?php
require_once("vendor\autoload.php");
require_once("src\RestAPIWrapperProffix\RestAPIWrapperProffix.php");
require_once("src\RestAPIWrapperProffix\Exception\HttpException.php");
// bootstrap.php
require_once __DIR__ . '/vendor/autoload.php';
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "pitwch/rest-api-wrapper-proffix-php",
"description": "PHP Wrapper for PROFFIX REST API",
"type": "library",
"version": "1.9.0",
"homepage": "https://www.pitw.ch",
"license": "MIT",
"authors": [
Expand All @@ -26,6 +27,9 @@
}
},
"autoload-dev": {
"psr-4": { "Pitwch\\RestAPIWrapperProffix\\Tests\\": "tests/RestAPIWrapperProffix" }
"psr-4": {
"Pitwch\\RestAPIWrapperProffix\\Tests\\": "tests/RestAPIWrapperProffix/",
"Pitwch\\RestAPIWrapperProffix\\Tests\\Integration\\": "tests/Integration/"
}
}
}
40 changes: 26 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 16 additions & 81 deletions src/RestAPIWrapperProffix/Client.php
Original file line number Diff line number Diff line change
@@ -1,121 +1,56 @@
<?php


namespace Pitwch\RestAPIWrapperProffix;

use Pitwch\RestAPIWrapperProffix\HttpClient\HttpClient;


/**
* Class Client
*
* @package Pitwch\RestAPIWrapperProffix
*/
class Client
{
protected $httpClient;

const VERSION = '1.3';


/**
* @var HttpClient
*/
protected $http;

/**
* Client constructor.
*
* @param string $url The Proffix API URL
* @param string $apiDatabase The Proffix Database
* @param string $apiUser The Proffix User
* @param string $apiPassword The Proffix Password
* @param array $apiModules The required Proffix Modules
* @param array $options Additional options
*
* @throws HttpClient\HttpClientException
*/
public function __construct($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options = [])
{
$this->http = new HttpClient($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options);
$this->httpClient = new HttpClient($url, $apiDatabase, $apiUser, $apiPassword, $apiModules, $options);
}


/**
* @param string $endpoint
* @param array $data
*
* @return mixed
*
* @throws HttpClient\HttpClientException
*/
public function post($endpoint, $data)
public function getHttpClient()
{
return $this->http->request($endpoint, 'POST', $data);
return $this->httpClient;
}

/**
* @param string $endpoint
* @param array $data
*
* @return mixed
*
* @throws HttpClient\HttpClientException
*/
public function put($endpoint, $data)
public function get($endpoint, $parameters = [])
{
return $this->http->request($endpoint, 'PUT', $data);
return $this->httpClient->request($endpoint, 'GET', [], $parameters);
}

/**
* @param string $endpoint
* @param array $parameters
*
* @return mixed
*
* @throws HttpClient\HttpClientException
*/
public function get($endpoint, $parameters = [])
public function post($endpoint, $data = [])
{
return $this->httpClient->request($endpoint, 'POST', $data);
}

return $this->http->request($endpoint, 'GET', [], $parameters);
public function put($endpoint, $data = [])
{
return $this->httpClient->request($endpoint, 'PUT', $data);
}

/**
* @param string $endpoint
* @param array $parameters
*
* @return mixed
*
* @throws HttpClient\HttpClientException
*/
public function delete($endpoint, $parameters = [])
{
return $this->http->request($endpoint, 'DELETE', [], $parameters);
return $this->httpClient->request($endpoint, 'DELETE', [], $parameters);
}

/**
* @param string $px_api_key
*
* @return mixed
*
* @throws HttpClient\HttpClientException
*/
public function info($px_api_key = '')
{
return $this->http->request('PRO/Info', 'GET', [], ['key' => $px_api_key], false);
return $this->httpClient->request('PRO/Info', 'GET', [], ['key' => $px_api_key], false);
}

/**
* @param string $px_api_key
*
* @return mixed
*
* @throws HttpClient\HttpClientException
*/
public function database($px_api_key = '')
{
return $this->http->request('PRO/Datenbank', 'GET', [], ['key' => $px_api_key], false);
return $this->httpClient->request('PRO/Datenbank', 'GET', [], ['key' => $px_api_key], false);
}


}

Loading
Loading