The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WebService::Gitter - An interface to Gitter REST API via Perl 5.

VERSION

version 0.3.0

SYNOPSIS

use WebService::Gitter;

my $client = WebService::Gitter->new(token_pass => 'my_api_or_token_key');

$client->current_user;
$client->rooms;
$client->room_id('gitterHQ/nodejs');
$client->room_users('the_user_id');
$client->send_message('my_text', 'room_id');

DESCRIPTION

An interface to Gitter REST API (v1). The methods will return a parsed JSON into hash via Data::Dumper. That is up to your freedom on specifically accessing each element in the hash.

METHODS

new(token_pass => $api_key)

You need to be registered at Gitter to get an api key. Take a look at https://developer.gitter.im/login for further information.

current_user

This will return the authenticated user (you) info in JSON through HASH. To see the response data, you can:

print $obj->current_user; 

and it will print the returned HASH map.

rooms

This will return the joined rooms by authenticated user (you) info in JSON through HASH. To see the response data, you can:

print $obj->rooms;

and it will print the returned HASH map.

room_id($room_uri)

$room_uri arguments is the room name, eg FreecodeCamp/FreeCodeCamp.

This method will return the room ID of the specified room name in JSON through HASH. To see the response data, you can:

print $obj->room_id($room_uri);

and it will print the returned HASH map.

room_users($room_id)

$room_id is the room ID. You can get this by running the "room_id($room_uri)" method.

This method will return the users in the specified room in JSON through HASH. To see the response data, you can:

print $obj->room_users($room_id);

and it will print the returned HASH map.

send_message($text, $room_id)

$text is your text message, eg 'HI!'. $room_id is the room ID you want to send message to. You can get the room ID by running "$room_id($room_uri)".

This method will send the message to the specified room through the room ID. To see the response data, you can:

print $obj->send_message($text, $room_id);

and it will print the returned HASH map.

SEE ALSO

LWP::UserAgent

Data::Dumper

JSON::MaybeXS

Gitter API Wiki for developer page

AUTHOR

faraco <skelic3@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by faraco.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.