2017 © Pedro Peláez
 

library gitter-api

Gitter async api

image

serafim/gitter-api

Gitter async api

  • Friday, March 17, 2017
  • by Serafim
  • Repository
  • 1 Watchers
  • 7 Stars
  • 194 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 36 Versions
  • 0 % Grown

The README.md

Gitter API Client 4.0

Latest Stable Version https://travis-ci.org/SerafimArts/gitter-api Scrutinizer Code Quality License Total Downloads, (*1)

Installation

composer require serafim/gitter-api, (*2)

Creating a Gitter Client

use Gitter\Client;

$client = new Client($token); 
// OR
$client = new Client($token, $logger); // $logger are instance of \Psr\Log\LoggerInterface

// ... SOME ACTIONS ...

$client->connect(); // Locks current runtime and starts an EventLoop (for streaming requests)

Resources

// $client = new \Gitter\Client('token');

$client->groups;   // Groups resource (Traversable)
$client->messages; // Messages resource
$client->rooms;    // Rooms resource (Traversable)
$client->users;    // Users resource

Example

foreach ($client->rooms as $room) {
    var_dump($room);
}

Streaming

$observer = $client->rooms->messages('roomId'); // Observer

$observer->subscribe(function ($message) {
    var_dump($message);
});

// Connect to stream!
$client->connect();

Available resources

Groups

List groups the current user is in., (*3)

  • $client->groups->all(): array

List of rooms nested under the specified group., (*4)

  • $client->groups->rooms(string $roomId): array

Messages

List of messages in a room in historical reversed order., (*5)

  • $client->messages->all(string $roomId[, string $query]): \Generator

There is also a way to retrieve a single message using its id., (*6)

  • $client->messages->find(string $roomId, string $messageId): array

Send a message to a room., (*7)

  • $client->messages->create(string $roomId, string $content): array

Update a message., (*8)

  • $client->messages->update(string $roomId, string $messageId, string $content): array

Delete a message., (*9)

  • $client->messages->delete(string $roomId, string $messageId): array

Rooms

List rooms the current user is in., (*10)

  • $client->rooms->all([string $query]): array

Join user into a room., (*11)

  • $client->rooms->joinUser(string $roomId, string $userId): array

Join current user into a room., (*12)

  • $client->rooms->join(string $roomId): array

Join current user into a room by room name (URI)., (*13)

  • $client->rooms->joinByName(string $name): array

Find room by room name (URI)., (*14)

  • $client->rooms->findByName(string $name): array

Kick user from target room., (*15)

  • $client->rooms->kick(string $roomId, string $userId): array

This can be self-inflicted to leave the the room and remove room from your left menu., (*16)

  • $client->rooms->leave(string $roomId): array

Sets up a new topic of target room., (*17)

  • $client->rooms->topic(string $roomId, string $topic): array

Sets the room is indexed by search engines., (*18)

  • $client->rooms->searchIndex(string $roomId, bool $enabled): array

Sets the tags that define the room, (*19)

  • $client->rooms->tags(string $roomId, array $tags): array

If you hate one of the rooms - you can destroy it!, (*20)

  • $client->rooms->delete(string $roomId): array

List of users currently in the room., (*21)

  • $client->rooms->users(string $roomId[, string $query]: \Generator

Use the streaming API to listen events., (*22)

  • $client->rooms->events(string $roomId): Observer

Use the streaming API to listen messages., (*23)

  • $client->rooms->messages(string $roomId): Observer

Users

Returns the current user logged in., (*24)

  • $client->users->current(): array
  • $client->users->currentUserId(): string

List of Rooms the user is part of., (*25)

  • $client->users->rooms([string $userId]): array

You can retrieve unread items and mentions using the following endpoint., (*26)

  • $client->users->unreadItems(string $roomId[, string $userId]): array

There is an additional endpoint nested under rooms that you can use to mark chat messages as read, (*27)

  • $client->users->markAsRead(string $roomId, array $messageIds[, string $userId]): array

List of the user's GitHub Organisations and their respective Room if available., (*28)

  • $client->users->orgs([string $userId]): array

List of the user's GitHub Repositories and their respective Room if available., (*29)

  • $client->users->repos([string $userId]): array

List of Gitter channels nested under the user., (*30)

  • $client->users->channels([string $userId]): array

Custom WebHook Notifications

Create a "Custom Webhook": - Open your chat - Click on "Room Settings" button - Click on "Integrations" - Select "Custom" - Remember yor Hook Id, like 2b66cf4653faa342bbe8 inside https://webhooks.gitter.im/e/ url., (*31)

$client->notify($hookId)
    // ->error($message) - Send "Error" message
    // ->info($message) - Send "Info" message
    // ->withLevel(...) - Sets up level
    ->send('Your message with markdown'); // Send message with markdown content

Custom routing

$route = Route::get('rooms/{roomId}/chatMessages')
    ->with('roomId', $roomId)
    ->toStream();

// Contains "GET https://stream.gitter.im/v1/rooms/.../chatMessages" url

$client->viaStream()->request($route)->subscribe(function($message) {
     var_dump($message);
    // Subscribe on every message in target room (Realtime subscribtion)
});

$client->connect();

Available route methods:, (*32)

  • Route::get(string $route) - GET http method
  • Route::post(string $route) - POST http method
  • Route::put(string $route) - PUT http method
  • Route::patch(string $route) - PATCH http method
  • Route::delete(string $route) - DELETE http method
  • Route::options(string $route) - OPTIONS http method
  • Route::head(string $route) - HEAD http method
  • Route::connect(string $route) - CONNECT http method
  • Route::trace(string $route) - TRACE http method

Route arguments:, (*33)

  • $route->with(string $key, string $value) - Add route or GET query parameter
  • $route->withMany(array $parameters) - Add route or GET query parameters
  • $route->withBody(string $key, string $value) - Add POST, PUT, DELETE, etc body parameter

See more info about API into Documentation, (*34)

The Versions

17/03 2017

dev-master

9999999-dev

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

17/03 2017

4.0.7

4.0.7.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

16/03 2017

4.0.6

4.0.6.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

27/01 2017

4.0.5

4.0.5.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

17/01 2017

4.0.4

4.0.4.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

30/12 2016

4.0.3

4.0.3.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

28/12 2016

4.0.2

4.0.2.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

28/12 2016

4.0.1

4.0.1.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

28/12 2016

4.0.0

4.0.0.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

26/10 2016

3.0.3

3.0.3.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

24/10 2016

3.0.2

3.0.2.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

23/10 2016

3.0.1

3.0.1.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

23/10 2016

3.0.0

3.0.0.0

Gitter async api

  Sources   Download

MIT

The Requires

 

The Development Requires

api client async react gitter

11/04 2016

2.1.1

2.1.1.0

Gitter async api

  Sources   Download

MIT

The Requires

 

api client async react ardent gitter

11/04 2016

2.1.0

2.1.0.0

Gitter async api

  Sources   Download

MIT

The Requires

 

api client async react ardent gitter

23/03 2016

2.0.1

2.0.1.0

Gitter async api

  Sources   Download

MIT

The Requires

 

api client async react ardent gitter

23/03 2016

2.0.0

2.0.0.0

Gitter async api

  Sources   Download

MIT

The Requires

 

api client async react ardent gitter

28/01 2016

1.1.2

1.1.2.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

28/01 2016

1.1.1

1.1.1.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

28/01 2016

1.1.0

1.1.0.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.16

1.0.16.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.15

1.0.15.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.14

1.0.14.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.13

1.0.13.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.12

1.0.12.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.11

1.0.11.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.10

1.0.10.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.9

1.0.9.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.8

1.0.8.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.7

1.0.7.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.6

1.0.6.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.5

1.0.5.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.4

1.0.4.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.3

1.0.3.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.1

1.0.1.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api client async react gitter

26/01 2016

1.0.0

1.0.0.0

Gitter React API

  Sources   Download

MIT

The Requires

 

api async gitter