-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring sirs kemkes with curl and update readme
- Loading branch information
virusphp
committed
Aug 2, 2024
1 parent
e24f8b1
commit cff76ef
Showing
13 changed files
with
234 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Kemkes\Bridging; | ||
|
||
class CurlFactory | ||
{ | ||
public function request($endpoint, $headers, $method = "", $payload = "") | ||
{ | ||
$headers = $this->setHeader($headers); | ||
|
||
$optf = [ | ||
CURLOPT_VERBOSE => true, | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_SSL_VERIFYPEER => false, | ||
CURLOPT_SSL_VERIFYHOST => false, | ||
CURLOPT_TIMEOUT => 5, | ||
CURLOPT_CONNECTTIMEOUT => 5, | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_HTTPHEADER => $headers | ||
]; | ||
|
||
if (!empty($method)) { | ||
$optf[CURLOPT_CUSTOMREQUEST] = $method; | ||
$optf[CURLOPT_POSTFIELDS] = $payload; | ||
$optf[CURLOPT_HTTPHEADER][] = 'Content-Type: Application/x-www-form-urlencoded'; | ||
} else { | ||
$optf[CURLOPT_HTTPHEADER][] = 'Content-Type: Application/json'; | ||
} | ||
|
||
$ch = curl_init($endpoint); | ||
curl_setopt_array($ch, $optf); | ||
$result = curl_exec($ch); | ||
$info = curl_getinfo($ch); | ||
// dd($info); | ||
curl_close($ch); | ||
|
||
return $result; | ||
} | ||
|
||
protected function setHeader($headers) | ||
{ | ||
$header = []; | ||
$header[] = 'Accept: application/json'; | ||
$header[] = 'X-rs-id:' . $headers['X-rs-id']; | ||
$header[] = 'X-timestamp:' . $headers['X-timestamp']; | ||
$header[] = 'X-pass:' . $headers['X-pass']; | ||
return $header; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Kemkes\Bridging; | ||
|
||
abstract class ManageService | ||
{ | ||
protected $urlEndpoint; | ||
|
||
protected $user; | ||
|
||
protected $pass; | ||
|
||
/** | ||
* abstract method getUrl | ||
*/ | ||
abstract public function setUrl(); | ||
|
||
/** | ||
* abstract method getConsId | ||
*/ | ||
abstract public function setUser(); | ||
|
||
/** | ||
* abstract method getSecretKey | ||
*/ | ||
abstract public function setPass(); | ||
} |
Oops, something went wrong.