Skip to content

Commit 3224a05

Browse files
Merge pull request #17 from Palbahngmiyine/master
Release PHP SDK 5.0.3
2 parents 81bda25 + d4ab140 commit 3224a05

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solapi/sdk",
33
"description": "SOLAPI SDK for PHP",
4-
"version": "5.0.2",
4+
"version": "5.0.3",
55
"type": "library",
66
"license": "MIT",
77
"autoload": {

src/Libraries/Fetcher.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ public function request(string $method, string $uri, $data = false)
6767
case "POST":
6868
case "PUT":
6969
case "DELETE":
70-
if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
70+
if ($data) {
71+
$data = NullEliminator::array_null_eliminate((array)$data);
72+
$data = json_encode($data);
73+
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
74+
}
7175
break;
7276
case "GET":
73-
default:
7477
if ($data) $url = sprintf("%s?%s", $url, http_build_query($data));
7578
break;
7679
}

src/Libraries/NullEliminator.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Nurigo\Solapi\Libraries;
4+
5+
class NullEliminator
6+
{
7+
static function array_null_eliminate(array $data): array
8+
{
9+
$result = array();
10+
foreach ($data as $key => $value) {
11+
$tempValue = null;
12+
if (is_array($value) || is_object($value)) {
13+
$tempValue = self::array_null_eliminate((array)$value);
14+
} else if (!is_null($value)) {
15+
$tempValue = $value;
16+
}
17+
if (!is_null($tempValue)) {
18+
$result[$key] = $tempValue;
19+
}
20+
}
21+
return $result;
22+
}
23+
}

src/Models/Kakao/KakaoOption.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,5 @@ public function setButtons(array $buttons): KakaoOption
148148
public function __construct()
149149
{
150150
$this->variables = new stdClass();
151-
unset($this->buttons);
152151
}
153152
}

src/Models/Message.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,4 @@ public function setKakaoOptions(KakaoOption $kakaoOptions): Message
258258
$this->kakaoOptions = $kakaoOptions;
259259
return $this;
260260
}
261-
262-
public function __construct()
263-
{
264-
unset($this->text);
265-
unset($this->kakaoOptions);
266-
unset($this->subject);
267-
unset($this->imageId);
268-
unset($this->autoTypeDetect);
269-
unset($this->groupId);
270-
unset($this->messageId);
271-
unset($this->type);
272-
}
273261
}

src/Models/Request/DefaultAgent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DefaultAgent
1616

1717
public function __construct()
1818
{
19-
$this->sdkVersion = 'php/5.0.2';
19+
$this->sdkVersion = 'php/5.0.3';
2020
$this->osPlatform = PHP_OS . " | " . phpversion();
2121
}
2222
}

0 commit comments

Comments
 (0)