-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
- Loading branch information
Showing
8 changed files
with
180 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2025 guanguans<[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/guanguans/notify | ||
*/ | ||
|
||
namespace Guanguans\Notify\PushMe; | ||
|
||
use Guanguans\Notify\Foundation\Authenticators\OptionsAuthenticator; | ||
use GuzzleHttp\RequestOptions; | ||
|
||
class Authenticator extends OptionsAuthenticator | ||
{ | ||
public function __construct(?string $pushKey = null, ?string $tempKey = null) | ||
{ | ||
parent::__construct( | ||
[RequestOptions::JSON => ['push_key' => $pushKey, 'temp_key' => $tempKey]], | ||
true | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2025 guanguans<[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/guanguans/notify | ||
*/ | ||
|
||
namespace Guanguans\Notify\PushMe; | ||
|
||
use Guanguans\Notify\Foundation\Contracts\Authenticator; | ||
|
||
class Client extends \Guanguans\Notify\Foundation\Client | ||
{ | ||
public function __construct(Authenticator $authenticator) | ||
{ | ||
parent::__construct($authenticator); | ||
$this->baseUri('https://push.i-i.me'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2025 guanguans<[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/guanguans/notify | ||
*/ | ||
|
||
namespace Guanguans\Notify\PushMe\Messages; | ||
|
||
use Guanguans\Notify\Foundation\Concerns\AsNullUri; | ||
|
||
/** | ||
* @method self content($content) | ||
* @method self date($date) | ||
* @method self pushKey($pushKey) | ||
* @method self tempKey($tempKey) | ||
* @method self title($title) | ||
* @method self type($type) | ||
*/ | ||
class Message extends \Guanguans\Notify\Foundation\Message | ||
{ | ||
use AsNullUri; | ||
protected array $defined = [ | ||
'push_key', | ||
'temp_key', | ||
'title', | ||
'content', | ||
'type', | ||
'date', | ||
]; | ||
protected array $allowedValues = [ | ||
// 'type' => ['text', 'markdown', 'data', 'markdata'], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# PushMe | ||
|
||
## [Usage example](./../../tests/PushMe/ClientTest.php) | ||
|
||
## Related links | ||
|
||
* [https://push.i-i.me](https://push.i-i.me) | ||
* [https://push.i-i.me/docs](https://push.i-i.me/docs) | ||
* [https://github.com/yafoo/pushme](https://github.com/yafoo/pushme) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** @noinspection StaticClosureCanBeUsedInspection */ | ||
/** @noinspection PhpUnhandledExceptionInspection */ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2025 guanguans<[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/guanguans/notify | ||
*/ | ||
|
||
namespace Guanguans\NotifyTests\PushMe; | ||
|
||
use Guanguans\Notify\PushMe\Authenticator; | ||
use Guanguans\Notify\PushMe\Client; | ||
use Guanguans\Notify\PushMe\Messages\Message; | ||
|
||
it('can send message', function (): void { | ||
$authenticator = new Authenticator( | ||
'uhDXKk3UXJtdT3dE6', | ||
// 'hLzPCm6Y1y26iddAy' | ||
); | ||
$client = new Client($authenticator); | ||
$message = Message::make([ | ||
// 'push_key' => 'uhDXKk3UXJtdT3dE6', | ||
// 'temp_key' => 'hLzPCm6Y1y26iddAy', | ||
'title' => 'This is title.', | ||
'content' => '> This is content.', | ||
'date' => date('Y-m-d H:i:s'), | ||
'type' => 'markdown', | ||
]); | ||
|
||
expect($client) | ||
->mock([ | ||
response('success'), | ||
response('请检查push_key是否正确'), | ||
]) | ||
->assertCanSendMessage($message); | ||
})->group(__DIR__, __FILE__); |