<?php
// Own namespace
-namespace Wds66\Api;
+namespace Com\Wds66\Api;
// Import framework stuff
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
/**
* Creates an instance of this API class
*
- * @param $cfg Configuration array
+ * @param $configArray Configuration array
* @return $apiInstance An instance of this API class
*/
- public static final function createWernisApi (array $cfg) {
+ public static final function createWernisApi (array $configArray) {
// Create a new instance
$apiInstance = new WernisApi();
- // Fix missing
- if (!isset($cfg['api_url'])) $cfg['api_url'] = self::$apiUrl;
+ // If not an api_url is given (e.g. on local development system)
+ if (!isset($configArray['api_url'])) {
+ // ... then set the productive URL
+ $configArray['api_url'] = self::$apiUrl;
+ }
// Konfiguration uebertragen
- $apiInstance->setCoonfigArray($cfg);
+ $apiInstance->setCoonfigArray($configArray);
// Return the instance
return $apiInstance;
* @param $w_pwd Clear password of the gamer
* @return void
*/
- public function setUser ($w_id, $w_pwd) {
+ public function setUser (int $w_id, string $w_pwd) {
// Set username (id)
$this->w_id = $w_id;
* The following methods are not yet rewritten! *
************************************************/
- public function einziehen ($amount) {
+ public function einziehen (int $amount) {
// amount auf Gueltigkeit pruefen
- $amount = isset($amount) ? $amount+0 : 0;
-
if ($amount < $this->config['mineinsatz']) {
$this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
return false;
return $this->executeWithdraw($amount);
}
- public function verschicken ($amount) {
+ public function verschicken (int $amount) {
// amount auf Gueltigkeit pruefen
- $amount = isset($amount) ? $amount+0 : 0;
-
if ($amount < $this->config['mineinsatz']) {
$this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
return false;
}
// Sets a status message and code
- public function setStatusMessage ($msg, $status) {
+ public function setStatusMessage (string $msg, string $status) {
$this->statusArray['message'] = $msg;
$this->statusArray['status'] = $status;
}
}
// Sends out a request to the API and returns it's result
- private function sendRequest ($scriptName, array $requestData = array()) {
+ private function sendRequest (string $scriptName, array $requestData = []) {
// Is the requestData an array?
if (!is_array($requestData)) {
// Then abort here!
}
// Widthdraw this amount
- private function executeWithdraw ($amount) {
+ private function executeWithdraw (int $amount) {
// First all fails...
$result = false;
}
// Payout this amount
- private function executePayout ($amount) {
+ private function executePayout (int $amount) {
// First all fails...
$result = false;
}
// Send raw GET request
- private function sendRawRequest ($script) {
+ private function sendRawRequest (string $script) {
// Use the hostname from script URL as new hostname
$url = substr($script, 7);
$extract = explode('/', $url);