Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from fiskaly/feature/v1.2.100
Browse files Browse the repository at this point in the history
Upgrade Client to v1.2.100
  • Loading branch information
Benjamin Müllner authored Aug 19, 2020
2 parents d3b1192 + 2235954 commit f2598d3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "library",
"homepage": "https://github.com/fiskaly/fiskaly-sdk-php",
"license": "MIT",
"version": "1.2.000",
"version": "1.2.100",
"require": {
"php": ">=7.1",
"datto/json-rpc-http": "*",
Expand Down
12 changes: 5 additions & 7 deletions examples/src/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
*/
try {
$config_params = [
'debug_level' => 4,
'debug_file' => __DIR__ . '/../fiskaly.log',
'debug_level' => 3,
'debug_file' => '-',
'client_timeout' => 5000,
'smaers_timeout' => 2000,
];
Expand All @@ -73,11 +73,9 @@
*/
try {
$response = $client->request(
'PUT',
'/tss/ecb75169-680f-48d1-93b2-52cc10abb9f/tx/9cbe6566-e24c-42ac-97fe-6a0112fb3c6',
["last_revision" => "0"],
["Content-Type" => "application/json"],
'eyJzdGF0ZSI6ICJBQ1RJVkUiLCJjbGllbnRfaWQiOiAiYTYyNzgwYjAtMTFiYi00MThhLTk3MzYtZjQ3Y2E5NzVlNTE1In0='
'GET',
'/tss',
["states" => ["DISABLED", "UNINITIALIZED"]]
);
echo "Request response: ", $response, "\n\n";
} catch (Exception $e) {
Expand Down
35 changes: 24 additions & 11 deletions src/FiskalyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class FiskalyClient
{
/** @var string */
const SDK_VERSION = '1.1.600';
const SDK_VERSION = '1.2.100';

/** @var string */
private $context = '';
Expand Down Expand Up @@ -63,33 +63,42 @@ private function doRequest($method, $params)

/**
* FiskalyClient Credentials Constructor - Construct an instance of the fiskaly API client Class
* @param string $fiskaly_service
* @param $api_key
* @param $api_secret
* @param string $base_url
* @param string $fiskaly_service
* @param string email
* @param string password
* @param string organization_id
* @param string environment
* @return FiskalyClient
* @throws Exception
*/
public static function createUsingCredentials($fiskaly_service, $api_key, $api_secret, $base_url)
public static function createUsingCredentials($fiskaly_service, $api_key = '', $api_secret = '', $base_url, $email = '', $password = '', $organization_id = '', $environment = '')
{
if (empty($fiskaly_service)) {
throw new Exception("fiskaly_service must be provided");
}

if (empty($api_key)) {
throw new Exception("api_key must be provided");
}
if (empty($email)) {
if (empty($api_key)) {
throw new Exception("api_key must be provided");
}

if (empty($api_secret)) {
throw new Exception("api_secret must be provided");
if (empty($api_secret)) {
throw new Exception("api_secret must be provided");
}
} else if (empty($password)) {
throw new Exception("password must be provided in combination with email");
}


if (empty($base_url)) {
throw new Exception("base_url must be provided");
}

$instance = new self($fiskaly_service);
$instance->createContext(trim($api_key), trim($api_secret), trim($base_url));
$instance->createContext(trim($api_key), trim($api_secret), trim($base_url), trim($email), trim($password), trim($organization_id), trim($environment));
return $instance;
}

Expand Down Expand Up @@ -123,12 +132,16 @@ public static function createUsingContext($fiskaly_service, $context)
* @param $base_url
* @throws Exception
*/
private function createContext($api_key, $api_secret, $base_url)
private function createContext($api_key, $api_secret, $base_url, $email, $password, $organization_id, $environment)
{
$contextParams = [
'base_url' => $base_url,
'api_key' => $api_key,
'api_secret' => $api_secret,
'email' => $email,
'password' => $password,
'organization_id' => $organization_id,
'environment' => $environment,
'sdk_version' => self::SDK_VERSION
];

Expand Down Expand Up @@ -261,8 +274,8 @@ public function configure($config_params)

/**
* Execute the request
* @param string $path
* @param string $method
* @param string $path
* @param null $query
* @param null $headers
* @param string $body - Base64 encoded JSON.
Expand Down

0 comments on commit f2598d3

Please sign in to comment.