Skip to content

Commit

Permalink
new api methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagleft committed Oct 14, 2019
1 parent a9c75bc commit 53e6e44
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sagleft/utopialib-php",
"description": "PHP library for Utopia Network API",
"keywords": ["utopia", "lib", "php"],
"version": "1.0.2",
"version": "1.0.3",
"license" : "MIT",
"authors" : [
{
Expand Down
104 changes: 104 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -1281,5 +1281,109 @@ public function setLowTrafficMode($enabled = true): bool {
}
return $response['result'];
}

public function getWhoIsInfo($pkOrNick): array {
$params = [
'owner' => $pkOrNick
];
$response = $this->api_query("getWhoIsInfo", $params);
if(! $this->checkResultContains($response)) {
return [];
}
return $response['result'];
}

public function requestTreasuryInterestRates(): bool {
$response = $this->api_query("requestTreasuryInterestRates");
if(! $this->checkResultContains($response)) {
return false;
}
return $response['result'];
}

public function getTreasuryInterestRates(): array {
$response = $this->api_query("getTreasuryInterestRates");
if(! $this->checkResultContains($response)) {
return [];
}
return $response['result'];
}

public function requestTreasuryTransactionVolumes(): bool {
$response = $this->api_query("requestTreasuryTransactionVolumes");
if(! $this->checkResultContains($response)) {
return false;
}
return $response['result'];
}

public function getTreasuryTransactionVolumes($query_filter = null): array {
$response = $this->api_query("getTreasuryTransactionVolumes", [], $query_filter);
if(! $this->checkResultContains($response)) {
return [];
}
return $response['result'];
}

public function ucodeEncode($hex_code, $size_image = 128, $coder = "BASE64", $format = "JPG"): string {
if(!ctype_xdigit($hex_code)) {
$this->error = "hex_code must be in hexadecimal representation";
return "";
}
switch($coder) {
default:
$coder = "BASE64"; break;
case 'BASE64': break;
case 'HEX': break;
}
switch($format) {
default:
$format = "JPG"; break;
case 'JPG': break;
case 'PNG': break;
}
$params = [
'hex_code' => $hex_code,
'size_image' => $size_image,
'coder' => $coder,
'format' => $format
];
$response = $this->api_query("ucodeEncode", $params);
if(! $this->checkResultContains($response)) {
return "";
}
return $response['result'];
}

public function ucodeDecode($base64_image): array {
$params = [
'base64_image' => $base64_image
];
$response = $this->api_query("ucodeDecode", $params);
if(! $this->checkResultContains($response)) {
return "";
}
return $response['result'];
}

public function getWebSocketState(): int {
$response = $this->api_query("getWebSocketState");
if(! $this->checkResultContains($response)) {
return 0;
}
return $response['result'];
}

public function setWebSocketState($enabled = "false", $port = "226748"): int {
$params = [
'enabled' => (string) $enabled,
'port' => $port
];
$response = $this->api_query("setWebSocketState");
if(! $this->checkResultContains($response)) {
return 0;
}
return $response['result'];
}
}

0 comments on commit 53e6e44

Please sign in to comment.