Skip to content

Commit

Permalink
v2.1.1
Browse files Browse the repository at this point in the history
* Minor bugfixes
  • Loading branch information
arianoangelo committed Apr 22, 2024
1 parent 4e5e1f1 commit cd5cd8b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
26 changes: 14 additions & 12 deletions BlockBee/BlockBee.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ class BlockBee
private $parameters = [];
private $api_key = null;

/**
* @throws Exception
*/
public function __construct($coin, $own_address, $callback_url, $parameters = [], $bb_params = [], $api_key = '')
{
if (empty($coin)) {
throw new Exception('Please provide a valid coin/ticker.');
}

if (empty($callback_url)) {
throw new Exception('Please provide a valid callback url.');
}

$this->valid_coins = BlockBee::get_supported_coins($api_key);

if (!in_array($coin, $this->valid_coins)) {
Expand All @@ -33,6 +44,9 @@ public function __construct($coin, $own_address, $callback_url, $parameters = []
$this->api_key = $api_key;
}

/**
* @throws ApiException
*/
public static function get_supported_coins($api_key = '')
{
$info = BlockBee::get_info(null, true);
Expand Down Expand Up @@ -62,10 +76,6 @@ public static function get_supported_coins($api_key = '')
*/
public function get_address()
{
if (empty($this->coin) || empty($this->callback_url)) {
return null;
}

$callback_url = $this->callback_url;

if (!empty($this->parameters)) {
Expand All @@ -92,10 +102,6 @@ public function get_address()

public function check_logs()
{
if (empty($this->coin) || empty($this->callback_url)) {
return null;
}

$callback_url = $this->callback_url;
if (!empty($this->parameters)) {
$req_parameters = http_build_query($this->parameters);
Expand All @@ -121,10 +127,6 @@ public function check_logs()
*/
public function get_qrcode($value = false, $size = false)
{
if (empty($this->coin)) {
return null;
}

$address = $this->payment_address;

if (empty($address)) {
Expand Down
4 changes: 2 additions & 2 deletions BlockBee/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function _request_get($coin, $endpoint, $params = [], $assoc = fal
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response_object = json_decode($response, $assoc);

if (isset($response_object->status) && $response_object->status === 'error') {
if ((is_object($response_object) && isset($response_object->status) && $response_object->status === 'error') || (is_array($response_object) && isset($response_object['status']) && $response_object['status'] === 'error')) {
$statusCode = $http_code;
$apiError = $response_object->error ?? null;

Expand Down Expand Up @@ -85,7 +85,7 @@ public static function _request_post($coin, $endpoint, $api_key, $body = [], $is
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response_object = json_decode($response, $assoc);

if (isset($response_object->status) && $response_object->status === 'error') {
if ((is_object($response_object) && isset($response_object->status) && $response_object->status === 'error') || (is_array($response_object) && isset($response_object['status']) && $response_object['status'] === 'error')) {
$statusCode = $http_code;
$apiError = $response_object->error ?? null;

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ Contact us @ https://blockbee.io/contacts/
* Minor bugfixes
* Improve error handling

#### 2.1.1
* Minor bugfixes

### Breaking Changes

#### 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"BlockBee\\": "BlockBee/"
}
},
"version": "2.1.0"
"version": "2.1.1"
}

0 comments on commit cd5cd8b

Please sign in to comment.