Skip to content

Commit 0c14d8b

Browse files
committed
feat(PushMe): adds PushMe package
- Adds `Authenticator` class to handle PushMe authentication - Adds `Client` class for PushMe API communication - Adds `Message` class for creating PushMe messages - Includes documentation and related links
1 parent ae2085d commit 0c14d8b

File tree

8 files changed

+181
-2
lines changed

8 files changed

+181
-2
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# notify
22

33
> [!NOTE]
4-
> Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、Zulip).
4+
> Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、Zulip).
55
66
[![tests](https://github.com/guanguans/notify/actions/workflows/tests.yml/badge.svg)](https://github.com/guanguans/notify/actions/workflows/tests.yml)
77
[![check & fix styling](https://github.com/guanguans/notify/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/notify/actions/workflows/php-cs-fixer.yml)
@@ -35,6 +35,7 @@
3535
* [Pushback](./src/Pushback/README.md)
3636
* [PushBullet](./src/PushBullet/README.md)
3737
* [PushDeer](./src/PushDeer/README.md)
38+
* [PushMe](./src/PushMe/README.md)
3839
* [Pushover](./src/Pushover/README.md)
3940
* [PushPlus](./src/PushPlus/README.md)
4041
* [QQ](./src/QQ/README.md)

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "guanguans/notify",
3-
"description": "Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、Zulip).",
3+
"description": "Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、Zulip).",
44
"license": "MIT",
55
"type": "library",
66
"keywords": [
@@ -38,6 +38,7 @@
3838
"Pushback",
3939
"PushBullet",
4040
"PushDeer",
41+
"PushMe",
4142
"Pushover",
4243
"PushPlus",
4344
"QQ",

ide.json

+30
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,36 @@
995995
]
996996
}
997997
},
998+
{
999+
"complete": "staticStrings",
1000+
"condition": [
1001+
{
1002+
"classFqn": [
1003+
"\\Guanguans\\Notify\\PushMe\\Messages\\Message"
1004+
],
1005+
"newClassFqn": [
1006+
"\\Guanguans\\Notify\\PushMe\\Messages\\Message"
1007+
],
1008+
"methodNames": [
1009+
"make"
1010+
],
1011+
"parameters": [
1012+
1
1013+
],
1014+
"place": "arrayKey"
1015+
}
1016+
],
1017+
"options": {
1018+
"strings": [
1019+
"content",
1020+
"date",
1021+
"push_key",
1022+
"temp_key",
1023+
"title",
1024+
"type"
1025+
]
1026+
}
1027+
},
9981028
{
9991029
"complete": "staticStrings",
10001030
"condition": [

src/PushMe/Authenticator.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) 2021-2025 guanguans<[email protected]>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*
11+
* @see https://github.com/guanguans/notify
12+
*/
13+
14+
namespace Guanguans\Notify\PushMe;
15+
16+
use Guanguans\Notify\Foundation\Authenticators\OptionsAuthenticator;
17+
use GuzzleHttp\RequestOptions;
18+
19+
class Authenticator extends OptionsAuthenticator
20+
{
21+
public function __construct(?string $pushKey = null, ?string $tempKey = null)
22+
{
23+
parent::__construct(
24+
[RequestOptions::JSON => ['push_key' => $pushKey, 'temp_key' => $tempKey]],
25+
true
26+
);
27+
}
28+
}

src/PushMe/Client.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) 2021-2025 guanguans<[email protected]>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*
11+
* @see https://github.com/guanguans/notify
12+
*/
13+
14+
namespace Guanguans\Notify\PushMe;
15+
16+
use Guanguans\Notify\Foundation\Contracts\Authenticator;
17+
18+
class Client extends \Guanguans\Notify\Foundation\Client
19+
{
20+
public function __construct(Authenticator $authenticator)
21+
{
22+
parent::__construct($authenticator);
23+
$this->baseUri('https://push.i-i.me');
24+
}
25+
}

src/PushMe/Messages/Message.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Copyright (c) 2021-2025 guanguans<[email protected]>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*
11+
* @see https://github.com/guanguans/notify
12+
*/
13+
14+
namespace Guanguans\Notify\PushMe\Messages;
15+
16+
use Guanguans\Notify\Foundation\Concerns\AsNullUri;
17+
18+
/**
19+
* @method self content($content)
20+
* @method self date($date)
21+
* @method self pushKey($pushKey)
22+
* @method self tempKey($tempKey)
23+
* @method self title($title)
24+
* @method self type($type)
25+
*/
26+
class Message extends \Guanguans\Notify\Foundation\Message
27+
{
28+
use AsNullUri;
29+
protected array $defined = [
30+
'push_key',
31+
'temp_key',
32+
'title',
33+
'content',
34+
'type',
35+
'date',
36+
];
37+
protected array $allowedValues = [
38+
// 'type' => ['text', 'markdown', 'data', 'markdata', 'chart'],
39+
];
40+
}

src/PushMe/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# PushMe
2+
3+
## [Usage example](./../../tests/PushMe/ClientTest.php)
4+
5+
## Related links
6+
7+
* [https://push.i-i.me](https://push.i-i.me)
8+
* [https://push.i-i.me/docs](https://push.i-i.me/docs)
9+
* [https://github.com/yafoo/pushme](https://github.com/yafoo/pushme)
10+
* [https://github.com/yafoo/pushme-server](https://github.com/yafoo/pushme-server)

tests/PushMe/ClientTest.php

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/** @noinspection StaticClosureCanBeUsedInspection */
4+
/** @noinspection PhpUnhandledExceptionInspection */
5+
6+
declare(strict_types=1);
7+
8+
/**
9+
* Copyright (c) 2021-2025 guanguans<[email protected]>
10+
*
11+
* For the full copyright and license information, please view
12+
* the LICENSE file that was distributed with this source code.
13+
*
14+
* @see https://github.com/guanguans/notify
15+
*/
16+
17+
namespace Guanguans\NotifyTests\PushMe;
18+
19+
use Guanguans\Notify\PushMe\Authenticator;
20+
use Guanguans\Notify\PushMe\Client;
21+
use Guanguans\Notify\PushMe\Messages\Message;
22+
23+
it('can send message', function (): void {
24+
$authenticator = new Authenticator(
25+
'uhDXKk3UXJtdT3dE6',
26+
// 'hLzPCm6Y1y26iddAy'
27+
);
28+
$client = new Client($authenticator);
29+
$message = Message::make([
30+
// 'push_key' => 'uhDXKk3UXJtdT3dE6',
31+
// 'temp_key' => 'hLzPCm6Y1y26iddAy',
32+
'title' => 'This is title.',
33+
'content' => '> This is content.',
34+
'date' => date('Y-m-d H:i:s'),
35+
'type' => 'markdown',
36+
]);
37+
38+
expect($client)
39+
->mock([
40+
response('success'),
41+
response('请检查push_key是否正确'),
42+
])
43+
->assertCanSendMessage($message);
44+
})->group(__DIR__, __FILE__);

0 commit comments

Comments
 (0)