diff --git a/base-php-client/index.php b/base-php-client/index.php index 0e589df5915804ae31ecaf98e7daf7ba147361b4..d7364b2778e7e7303c07ca015d61b10e48656388 100644 --- a/base-php-client/index.php +++ b/base-php-client/index.php @@ -130,5 +130,18 @@ if ($show) { } } +/** + * ΞΡιΟΞΏΟ ΟΞ³Ξ―Ξ± Ξ»Ξ�ΟΞ·Ο Ξ±ΟΟΞ΅Ξ―ΞΏΟ ΞΌΞ΅ δΡδομΞΞ½ΞΏ hash id $options['save'] Ξ� $options['get'] + */ +if ($get) { + if ($save) { + $doc_details = $app->savePdf($options['save'], $apikey); + echo "ΞΞ΅ΟΟΞΏΞΌΞΟΞ΅ΞΉΞ΅Ο Ξ±ΟΞΏΞΈΞ�ΞΊΞ΅Ο ΟΞ·Ο Ξ΅Ξ³Ξ³ΟΞ¬ΟΞΏΟ : ", PHP_EOL, print_r($doc_details, true), PHP_EOL; + } else { + $doc_details = $app->getPdf($options['get'], $apikey); + echo "ΞΞ΅ΟΟΞΏΞΌΞΟΞ΅ΞΉΞ΅Ο Ξ΅Ξ³Ξ³ΟΞ¬ΟΞΏΟ : ", PHP_EOL, print_r($doc_details, true), PHP_EOL; + } +} + echo "Done.", PHP_EOL; exit(0); diff --git a/base-php-client/src/App.php b/base-php-client/src/App.php index e4198bfa6dd809cee23a773081417d57b7f68691..d94edc2a876a371adf210cd48f6c2b83be061071 100644 --- a/base-php-client/src/App.php +++ b/base-php-client/src/App.php @@ -114,12 +114,27 @@ class App public function getPdf($hashid, $apikey = null) { - + if ($this->_debug) { + echo "getPdf:: hash id: {$hashid}", PHP_EOL; + } + + $response = json_decode($this->client->getPdf($hashid, $apikey === null ? $this->getApiKey() : $apikey), true); + return $response; } public function savePdf($hashid, $apikey = null) { - + if ($this->_debug) { + echo "savePdf:: hash id: {$hashid}", PHP_EOL; + } + + $result = $this->getPdf($hashid, $apikey = null); + $save = file_put_contents($result["fileName"], base64_decode($result["document"]["base64"])); + return [ + 'file_name' => $result["fileName"], + 'description' => $result["description"], + 'save' => ($save ? 'ΞΟΞΏΞΈΞ·ΞΊΞ΅ΟΟΞ·ΞΊΞ΅' : 'ΞΞΞ Ξ±ΟΞΏΞΈΞ·ΞΊΞ΅ΟΞΈΞ·ΞΊΞ΅') + ]; } /** diff --git a/base-php-client/src/Client.php b/base-php-client/src/Client.php index 6a0e8b1a33079e1e5577e9c1f546a3dbb53d8e7d..b436fe645b07b443a0298da3b32debba033a37e9 100644 --- a/base-php-client/src/Client.php +++ b/base-php-client/src/Client.php @@ -56,6 +56,17 @@ class Client return $result; } + public function getPdf($hashid, $apikey) + { + $result = $this->get("{$this->_settings['base_uri']}/document/pdf/{$hashid}", [], [ + "api_key: {$apikey}", + "Content-Type: text/plain", + "Accept: application/json", + ] + ); + return $result; + } + protected function setCommonCurlOptions($ch, $uri, $headers) { curl_setopt($ch, CURLOPT_URL, $uri);