Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Changes to some property names
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRow committed Jul 4, 2020
1 parent 155cb9a commit cdf4eef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
12 changes: 7 additions & 5 deletions src/NanoIPC.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class NanoIPC
private $context;
private $nanoPreamble;
private $nanoEncoding;
private $nanoAPIKey;
private $nanoApiKey;
private $id = 0;


Expand Down Expand Up @@ -151,13 +151,13 @@ public function setNanoEncoding(int $nano_encoding)
// ## Set Nano API key
// #

public function setNanoAPIKey(string $nano_api_key = null)
public function setNanoApiKey(string $nano_api_key = null)
{
if (empty($nano_api_key)){
throw new NanoIPCException("Invalid Nano API key: $nano_api_key");
}

$this->nanoAPIKey = $nano_api_key;
$this->nanoApiKey = $nano_api_key;
}


Expand Down Expand Up @@ -258,6 +258,7 @@ public function __call($method, array $params)
) {
$request = $arguments;
$request['action'] = $method;

// 4
} elseif ($this->nanoEncoding == 4) {
$request = [
Expand All @@ -267,8 +268,8 @@ public function __call($method, array $params)
];

// Nano API key
if ($this->nanoAPIKey != null) {
$request['credentials'] = $this->nanoAPIKey;
if ($this->nanoApiKey != null) {
$request['credentials'] = $this->nanoApiKey;
}
} else {
//
Expand Down Expand Up @@ -329,6 +330,7 @@ public function __call($method, array $params)
if (isset($this->response['error'])) {
$this->error = $this->response['error'];
}

// 4
} elseif ($this->nanoEncoding == 4) {
$this->responseType = $this->response['message_type'];
Expand Down
30 changes: 16 additions & 14 deletions src/NanoRPC.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class NanoRPC
private $port;
private $url;
private $options;
private $nanoAPI;
private $nanoAPIKey;
private $nanoApi;
private $nanoApiKey;
private $id = 0;


Expand Down Expand Up @@ -68,7 +68,7 @@ public function __construct(
$this->hostname = $hostname;
$this->port = $port;
$this->url = $url;
$this->nanoAPI = 1;
$this->nanoApi = 1;

$this->options =
[
Expand All @@ -91,29 +91,29 @@ public function __construct(
// ## Set Nano API
// #

public function setNanoAPI(int $nano_api)
public function setNanoApi(int $nano_api)
{
if ($nano_api != 1 &&
$nano_api != 2
) {
throw new NanoRPCException("Invalid Nano API: $nano_api");
}

$this->nanoAPI = $nano_api;
$this->nanoApi = $nano_api;
}


// #
// ## Set Nano API key
// #

public function setNanoAPIKey(string $nano_api_key = null)
public function setNanoApiKey(string $nano_api_key = null)
{
if (empty($nano_api_key)){
throw new NanoRPCException("Invalid Nano API key: $nano_api_key");
}

$this->nanoAPIKey = $nano_api_key;
$this->nanoApiKey = $nano_api_key;
}


Expand Down Expand Up @@ -147,20 +147,21 @@ public function __call($method, array $params)
// # API switch

// v1
if ($this->nanoAPI == 1) {
if ($this->nanoApi == 1) {
$request = $arguments;
$request['action'] = $method;
$request['action'] = $method;

// v2
} elseif ($this->nanoAPI == 2) {
} elseif ($this->nanoApi == 2) {
$request = [
'correlation_id' => (string) $this->id,
'message_type' => $method,
'message' => $arguments
];

// Nano API key
if ($this->nanoAPIKey != null) {
$request['credentials'] = $this->nanoAPIKey;
if ($this->nanoApiKey != null) {
$request['credentials'] = $this->nanoApiKey;
}
} else {
//
Expand Down Expand Up @@ -195,12 +196,13 @@ public function __call($method, array $params)
// # API switch

// v1
if ($this->nanoAPI == 1) {
if ($this->nanoApi == 1) {
if (isset($this->response['error'])) {
$this->error = $this->response['error'];
}

// v2
} elseif ($this->nanoAPI == 2) {
} elseif ($this->nanoApi == 2) {
$this->responseType = $this->response['message_type'];

$this->responseTime = (int) $this->response['time'];
Expand Down
2 changes: 1 addition & 1 deletion test/NanoRPC.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

$nanorpc = new php4nano\NanoRPC('http', 'localhost', 7076, 'api/v2');

$nanorpc->setAPI(2);
$nanorpc->setNanoApi(2);

$account = 'nano_3dyo9e7wkf8kuykghbjdt78njux3yudhdrhtwaymc8fsmxhxpt1h48zffbse';

Expand Down

0 comments on commit cdf4eef

Please sign in to comment.