Hello,
I've been trying to work with the Blesta PHP API library for a bit and I stumbled on an issue while trying to interface with it. I am currently using the following code:
<?php
require_once "blesta_api.php";
require_once "blesta_response.php";
$user = "...";
$key = "...";
$url = "https://(snipped)/api";
$api = new BlestaApi($url, $user, $key);
$code = bin2hex(openssl_random_pseudo_bytes(5));
$coupon_data = array(
"code" => $code,
"company_id" => 1,
"used_qty" => 0,
"max_qty" => 1,
"start_date" => date("c"),
"end_date" => "2025-12-30 11:59:59 UTC",
"status" => "active",
"recurring" => 0,
"limit_recurring" => 0,
"packages" => array(1, 2),
"amounts" => array(
"currency" => "USD",
"amount" => 50,
"type" => "percent"
)
);
$response = $api->post("coupons", "add", $coupon_data);
echo var_dump($response);
?>
There doesn't seem to be an issue as when I execute this, I receive no errors back. However, the response is empty, and the coupon API suggests that it will respond with an integer. Am I doing something wrong?