Skip to content

Commit

Permalink
Merge pull request #23 from volcengine/fix/json_encode
Browse files Browse the repository at this point in the history
feat: fix jsonSerialize
  • Loading branch information
zhangpengspin authored Dec 10, 2024
2 parents 42d6551 + ffa47b5 commit 7021617
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Model/Message/Saas/Attribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function jsonSerialize()
if ($this->name != null) {
$data["name"] = $this->name;
}
if ($this->value != null) {
if ($this->value !== null) {
$data["value"] = $this->value;
}
if ($this->operation != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Sender/Saas/SaasItemMessageSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function send(Message $message)
$content = json_encode(array(
"code" => "200",
"message" => "success"
));
), JSON_PRESERVE_ZERO_FRACTION);
foreach ($events as $event) {
/** @var Event $event */
$objectEvent = $event;
Expand All @@ -32,7 +32,7 @@ public function send(Message $message)
$sendMessage = new SaasItemAppMessage($objectEvent);
$urlPath = sprintf(SaasItemMessageSender::$path, $appMessage->getAppId(), $item_name, $item_id);
$url = ($openapi->getDomain()) . $urlPath;
$body = json_encode($sendMessage);
$body = json_encode($sendMessage, JSON_PRESERVE_ZERO_FRACTION);
$method = "PUT";

$authorization = AuthUtils::sign($openapi->getAk(), $openapi->getSk(), 1800, $method, $urlPath, null, $body);
Expand Down
2 changes: 1 addition & 1 deletion src/Sender/Saas/SaasProfileMessageSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SaasProfileMessageSender implements MessageSender
public function send(Message $message): void
{
$sendMessage = new SaasProfileAppMessage($message);
$body = json_encode($sendMessage);
$body = json_encode($sendMessage, JSON_PRESERVE_ZERO_FRACTION);
$appMessage = $message->getAppMessage();
$openapi = CollectorConfig::getOpenapi();
$urlPath = sprintf(SaasProfileMessageSender::$path, $appMessage->getAppId(), $appMessage->getUserUniqueId());
Expand Down
6 changes: 3 additions & 3 deletions test/HttpSaasTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
$rc = new AppEventCollector();
# send event
$rc->sendEvent("test-uuidsdk1", getenv("APP_ID"), null, ["php_event"],
[["php_name" => "php", "php_version" => "5.6"]]);
[["php_name" => "php", "php_version" => "5.6", "event_coin1"=>0]]);

# send single event
$rc->sendEvent("test-uuidsdk1", getenv("APP_ID"), null, "php_single_event",
["php_name" => "php", "php_version" => "5.6"]);
["php_name" => "php", "php_version" => "5.6", "event_coin2"=>0]);

# profile set
$rc->profileSet("test-uuidsdk1", getenv("APP_ID"), ["profile_php_name" => "php7", "profile_php_version" => "7.4", "profile_int" => 1]);
$rc->profileSet("test-uuidsdk1", getenv("APP_ID"), ["profile_php_name" => "php7", "profile_php_version" => "7.4", "profile_int" => 1, "profile_coin" => 0]);

# set item properties
$rc->itemIdSet(getenv("APP_ID"), "book", "book3", ["author" => "吴承恩", "name" => "西游记", "price" => 59.90, "category" => 1]);
Expand Down

0 comments on commit 7021617

Please sign in to comment.