Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenApi-Papyros-PHP-Clients
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Σταύρος Παπαδάκης
OpenApi-Papyros-PHP-Clients
Commits
bbfa3270
Commit
bbfa3270
authored
Dec 23, 2016
by
Σταύρος Παπαδάκης
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Post protocol function
parent
5c24912d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
2 deletions
+68
-2
base-php-client/index.php
base-php-client/index.php
+44
-0
base-php-client/src/App.php
base-php-client/src/App.php
+13
-2
base-php-client/src/Client.php
base-php-client/src/Client.php
+11
-0
No files found.
base-php-client/index.php
View file @
bbfa3270
...
...
@@ -82,6 +82,50 @@ try {
exit
(
-
1
);
}
/**
* Αποστολή αρχείου για πρωτοκόλληση
*/
if
(
$send
)
{
echo
"Αποστολή εγγράφου..."
,
PHP_EOL
;
echo
"Έλεγχος για το αρχείο
{
$options
[
'send'
]
}
... "
;
if
(
is_readable
(
$options
[
'send'
]))
{
$file
=
base64_encode
(
file_get_contents
(
$options
[
'send'
]));
if
(
$file
===
false
)
{
echo
PHP_EOL
,
"ΛΑΘΟΣ: Αδυναμία κωδικοποίησης του αρχείου."
,
PHP_EOL
;
}
echo
"OK"
,
PHP_EOL
;
}
else
{
echo
PHP_EOL
,
"ΛΑΘΟΣ: Το αρχείο δεν είναι αναγνώσιμο."
,
PHP_EOL
;
exit
(
-
1
);
}
try
{
// καθορισμός παραμέτρων σε πίνακα για απλοποίηση
$submission_data
=
[
'theme'
=>
'ΔΟΚΙΜΗ: Αυτοματοποιημένο κείμενο της '
.
date
(
'c'
),
'description'
=>
'ΔΟΚΙΜΗ: Αυτοματοποιημένο κείμενο περιγραφής '
.
date
(
'Ymdhmi'
),
'docCategory'
=>
20
,
'mainDoc'
=>
[
'document'
=>
[
"base64"
=>
$file
],
'fileName'
=>
$options
[
'send'
],
'description'
=>
"ΔΟΚΙΜΗ: Αποστολή δοκιμαστικού αρχείου
{
$options
[
'send'
]
}
"
]
// το παράδειγμα δεν περιλαμβάνει συνημμένα αρχεία
// και ορισμένες επιπλέον παραμέτρους
// senderId, senderProtocol, senderProtocolDate, ada, attachedDoc[]
];
$doc_info
=
$app
->
postProtocol
(
$submission_data
,
$apikey
);
echo
"Η αποστολή ολοκληρώθηκε με ΑΡ.Π.: "
,
$doc_info
[
"protocolNumber"
],
PHP_EOL
;
echo
"Αναλυτικά: "
,
print_r
(
$doc_info
,
true
),
PHP_EOL
;
}
catch
(
\
Exception
$e
)
{
echo
'ΛΑΘΟΣ: Αδυναμία αποστολής εγγράφου. '
,
PHP_EOL
,
$e
->
getMessage
(),
PHP_EOL
;
exit
(
1
);
}
}
/**
* Λειτουργία λήψης λίστας των καταχωρημένων πρωτοκόλλων.
* Εάν έχει ζητηθεί επιστρέφονται και οι αναλυτικές πληροφορίες των εγγράφων.
...
...
base-php-client/src/App.php
View file @
bbfa3270
...
...
@@ -107,9 +107,20 @@ class App
return
$response
;
}
public
function
submit
(
$submission_data
,
$apikey
=
null
)
public
function
postProtocol
(
$submission_data
,
$apikey
=
null
)
{
$payload
=
json_encode
(
array_merge
([
'senderId'
=>
$this
->
setting
(
'sender_id'
),
],
$submission_data
)
);
if
(
$this
->
_debug
)
{
echo
"postProtocol :: payload:
{
$payload
}
"
,
PHP_EOL
;
}
$response
=
json_decode
(
$this
->
client
->
postProtocol
(
$payload
,
$apikey
===
null
?
$this
->
getApiKey
()
:
$apikey
),
true
);
return
$response
;
}
public
function
getPdf
(
$hashid
,
$apikey
=
null
)
...
...
base-php-client/src/Client.php
View file @
bbfa3270
...
...
@@ -67,6 +67,17 @@ class Client
return
$result
;
}
public
function
postProtocol
(
$payload
,
$apikey
)
{
$result
=
$this
->
post
(
"
{
$this
->
_settings
[
'base_uri'
]
}
/protocol/submit"
,
$payload
,
[
"api_key:
{
$apikey
}
"
,
"Content-Type: application/json"
,
"Accept: application/json"
,
]
);
return
$result
;
}
protected
function
setCommonCurlOptions
(
$ch
,
$uri
,
$headers
)
{
curl_setopt
(
$ch
,
CURLOPT_URL
,
$uri
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment