Skip to content

Commit

Permalink
wip Gitter
Browse files Browse the repository at this point in the history
  • Loading branch information
guanguans committed Jan 23, 2024
1 parent 565a700 commit 4a8c063
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Gitter/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

/**
* This file is part of the guanguans/notify.
*
* (c) guanguans <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Guanguans\Notify\Gitter;

class Client extends \Guanguans\Notify\Foundation\Client
{
/**
* @param Credential|string $credential
*/
public function __construct($credential, \GuzzleHttp\Client $httpClient = null)
{
if (! $credential instanceof Credential) {
$this->credential = new Credential($credential);
}

parent::__construct($credential, $httpClient);
}
}
19 changes: 19 additions & 0 deletions src/Gitter/Credential.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

/**
* This file is part of the guanguans/notify.
*
* (c) guanguans <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Guanguans\Notify\Gitter;

use Guanguans\Notify\Foundation\AuthorizationTokenCredential;

class Credential extends AuthorizationTokenCredential
{
}
39 changes: 39 additions & 0 deletions src/Gitter/Messages/Message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

/**
* This file is part of the guanguans/notify.
*
* (c) guanguans <[email protected]>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Guanguans\Notify\Gitter\Messages;

use Guanguans\Notify\Foundation\Concerns\AsJson;
use Guanguans\Notify\Foundation\Concerns\AsPost;

class Message extends \Guanguans\Notify\Foundation\Message
{
use AsPost;
use AsJson;

protected array $defined = [
'text',
];

private string $roomsId;

public function __construct(string $roomsId, string $text)
{
parent::__construct(['text' => $text]);
$this->roomsId = $roomsId;
}

public function httpUri(): string
{
return "https://api.gitter.im/v1/rooms/$this->roomsId/chatMessages";
}
}

0 comments on commit 4a8c063

Please sign in to comment.