Skip to content

Commit 53ece71

Browse files
GroupMessageResponse 내 여러 타입 추가 및 MMS 기능 추가
1 parent 81376f2 commit 53ece71

10 files changed

Lines changed: 290 additions & 11 deletions

File tree

src/Exceptions/MessageNotReceivedException.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33
namespace Nurigo\Solapi\Exceptions;
44

55
use Exception;
6+
use Nurigo\Solapi\Models\Response\FailedMessage;
67

78
class MessageNotReceivedException extends Exception
89
{
910
/**
10-
* @var array
11+
* @var FailedMessage[]
1112
*/
1213
public $failedMessageList;
1314

1415
/**
15-
* @param array $failedMessageList
16+
* @param FailedMessage[] $failedMessageList
1617
*/
17-
public function __construct(array $failedMessageList)
18+
public function __construct($failedMessageList)
1819
{
1920
$this->failedMessageList = $failedMessageList;
2021
parent::__construct("메시지 접수에 실패했습니다.");
2122
}
2223

2324
/**
24-
* @return array
25+
* @return FailedMessage[]
2526
*/
2627
public function getFailedMessageList(): array
2728
{

src/Libraries/Authenticator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44

55
class Authenticator
66
{
7+
/**
8+
* @param string $apiKey
9+
* @param string $apiSecretKey
10+
* @return string
11+
*/
712
public static function getAuthorizationHeaderInfo(string $apiKey, string $apiSecretKey): string
813
{
914
// TODO: Timezone 문제가 생길 수 있어 추후 수정 필요
1015
date_default_timezone_set("Asia/Seoul");
1116
$date = date("Y-m-d\TH:i:s.Z\Z", time());
1217
$salt = uniqid();
1318
$signature = hash_hmac("sha256", $date . $salt, $apiSecretKey);
19+
1420
return "Authorization: HMAC-SHA256 apiKey={$apiKey}, date={$date}, salt={$salt}, signature={$signature}";
1521
}
1622
}

src/Libraries/Fetcher.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,31 @@
1010
*/
1111
class Fetcher
1212
{
13+
/**
14+
* @var Fetcher
15+
*/
1316
private static $singleton;
1417

1518
protected $apiKey = '';
1619
protected $apiSecretKey = '';
1720

1821
const API_URL = "https://api.solapi.com";
1922

20-
public static function getInstance(string $apiKey, string $apiSecretKey)
23+
/**
24+
* @param string $apiKey
25+
* @param string $apiSecretKey
26+
* @return Fetcher
27+
*/
28+
public static function getInstance(string $apiKey, string $apiSecretKey): Fetcher
2129
{
2230
if (!isset(Fetcher::$singleton)) Fetcher::$singleton = new Fetcher($apiKey, $apiSecretKey);
2331
return Fetcher::$singleton;
2432
}
2533

34+
/**
35+
* @param string $apiKey
36+
* @param string $apiSecretKey
37+
*/
2638
public function __construct(string $apiKey, string $apiSecretKey)
2739
{
2840
$this->apiKey = $apiKey;

src/Models/Message.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Nurigo\Solapi\Models\Kakao\KakaoOption;
66

7-
// TODO: Property 설명 정의해야 함
87
class Message
98
{
109
/**
@@ -26,9 +25,20 @@ class Message
2625
* @var string 스토리지 내 이미지 ID
2726
*/
2827
public $imageId;
28+
29+
/**
30+
* @var string 문자 제목(LMS, MMS 전용 옵션)
31+
*/
2932
public $subject;
33+
34+
/**
35+
* @var string 국가번호
36+
*/
3037
public $country = "82";
3138

39+
/**
40+
* @var KakaoOption
41+
*/
3242
public $kakaoOptions;
3343

3444
/**

src/Models/Request/SendRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SendRequest
3232
* @param DateTime|null $scheduledDate
3333
* @param bool $allowDuplicates
3434
*/
35-
public function __construct(array $messages, DateTime $scheduledDate = null, bool $allowDuplicates = false)
35+
public function __construct($messages, $scheduledDate = null, $allowDuplicates = false)
3636
{
3737
$this->messages = $messages;
3838
if ($scheduledDate != null) {
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
namespace Nurigo\Solapi\Models\Request;
4+
5+
class UploadFileRequest
6+
{
7+
/**
8+
* @var string base64 encode된 문자
9+
*/
10+
public $file;
11+
12+
/**
13+
* @var string file 유형(MMS, KAKAO 등)
14+
*/
15+
public $type;
16+
17+
/**
18+
* @var string|null 파일 이름
19+
*/
20+
public $name;
21+
22+
/**
23+
* @var string|null 첨부파일 링크(친구톡 이미지 전용)
24+
*/
25+
public $link;
26+
27+
/**
28+
* @return string
29+
*/
30+
public function getFile(): string
31+
{
32+
return $this->file;
33+
}
34+
35+
/**
36+
* @param string $file
37+
* @return UploadFileRequest
38+
*/
39+
public function setFile(string $file): UploadFileRequest
40+
{
41+
$this->file = $file;
42+
return $this;
43+
}
44+
45+
/**
46+
* @return string
47+
*/
48+
public function getType(): string
49+
{
50+
return $this->type;
51+
}
52+
53+
/**
54+
* @param string $type
55+
* @return UploadFileRequest
56+
*/
57+
public function setType(string $type): UploadFileRequest
58+
{
59+
$this->type = $type;
60+
return $this;
61+
}
62+
63+
/**
64+
* @return string|null
65+
*/
66+
public function getName(): string
67+
{
68+
return $this->name;
69+
}
70+
71+
/**
72+
* @param string|null $name
73+
* @return UploadFileRequest
74+
*/
75+
public function setName(string $name): UploadFileRequest
76+
{
77+
$this->name = $name;
78+
return $this;
79+
}
80+
81+
/**
82+
* @return string|null
83+
*/
84+
public function getLink(): string
85+
{
86+
return $this->link;
87+
}
88+
89+
/**
90+
* @param string|null $link
91+
* @return UploadFileRequest
92+
*/
93+
public function setLink(string $link): UploadFileRequest
94+
{
95+
$this->link = $link;
96+
return $this;
97+
}
98+
99+
public function __construct()
100+
{
101+
unset($this->name);
102+
unset($this->link);
103+
}
104+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Nurigo\Solapi\Models\Response;
4+
5+
class FailedMessage
6+
{
7+
/**
8+
* @var string
9+
*/
10+
public $to;
11+
12+
/**
13+
* @var string
14+
*/
15+
public $from;
16+
17+
/**
18+
* @var string
19+
*/
20+
public $type;
21+
22+
/**
23+
* @var string
24+
*/
25+
public $statusMessage;
26+
27+
/**
28+
* @var string
29+
*/
30+
public $country;
31+
32+
/**
33+
* @var string
34+
*/
35+
public $messageId;
36+
37+
/**
38+
* @var string
39+
*/
40+
public $statusCode;
41+
42+
/**
43+
* @var string
44+
*/
45+
public $accountId;
46+
}

src/Models/Response/SendResponse.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SendResponse implements JsonSerializable
1212
public $groupInfo;
1313

1414
/**
15-
* @var array
15+
* @var FailedMessage[]
1616
*/
1717
public $failedMessageList;
1818

@@ -25,6 +25,9 @@ public function __construct($value)
2525
$this->failedMessageList = $value->failedMessageList;
2626
}
2727

28+
/**
29+
* @return array
30+
*/
2831
public function jsonSerialize(): array
2932
{
3033
return [
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Nurigo\Solapi\Models\Response;
4+
5+
class UploadFileResponse
6+
{
7+
/**
8+
* @var string
9+
*/
10+
public $type;
11+
12+
/**
13+
* @var string
14+
*/
15+
public $originalName;
16+
17+
/**
18+
* @var string
19+
*/
20+
public $link;
21+
22+
/**
23+
* @var string
24+
*/
25+
public $fileId;
26+
27+
/**
28+
* @var string
29+
*/
30+
public $name;
31+
32+
/**
33+
* @var string
34+
*/
35+
public $url;
36+
37+
/**
38+
* @var string
39+
*/
40+
public $accountId;
41+
42+
/**
43+
* @var string
44+
*/
45+
public $dateCreated;
46+
47+
/**
48+
* @var string
49+
*/
50+
public $dateUpdated;
51+
52+
/**
53+
* @param mixed $value
54+
*/
55+
public function __construct($value)
56+
{
57+
$this->type = $value->type;
58+
$this->originalName = $value->originalName;
59+
$this->link = $value->link;
60+
$this->fileId = $value->fileId;
61+
$this->name = $value->name;
62+
$this->url = $value->url;
63+
$this->accountId = $value->accountId;
64+
$this->dateCreated = $value->dateCreated;
65+
$this->dateUpdated = $value->dateUpdated;
66+
}
67+
}

0 commit comments

Comments
 (0)