2017 © Pedro Peláez
 

library slack-api

Wrapper for Slack.com WEB API. Based on Vagner do Carmo one, but compatible with GuzzleHttp6

image

craftyx/slack-api

Wrapper for Slack.com WEB API. Based on Vagner do Carmo one, but compatible with GuzzleHttp6

  • Monday, July 10, 2017
  • by JulienTant
  • Repository
  • 1 Watchers
  • 2 Stars
  • 164 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 30 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Slack API for Laravel 5

This package provides a simple way to use Slack API. It's based on the excellent Vluzrmos package, but it's compatible with Guzzle6, (*1)

Instalation

composer require craftyx/slack-api, (*2)

Instalation on Laravel 5

Add to config/app.php:, (*3)

 [
        Craftyx\SlackApi\SlackApiServiceProvider::class,
    ]
]

?>

The ::class notation is optional., (*4)

and add the Facades to your aliases, if you need it, (*5)

 [
        'SlackApi'              => Craftyx\SlackApi\Facades\SlackApi::class,
        'SlackChannel'          => Craftyx\SlackApi\Facades\SlackChannel::class,
        'SlackChat'             => Craftyx\SlackApi\Facades\SlackChat::class,
        'SlackGroup'            => Craftyx\SlackApi\Facades\SlackGroup::class,
        'SlackFile'             => Craftyx\SlackApi\Facades\SlackFile::class,
        'SlackSearch'           => Craftyx\SlackApi\Facades\SlackSearch::class,
        'SlackInstantMessage'   => Craftyx\SlackApi\Facades\SlackInstantMessage::class,
        'SlackUser'             => Craftyx\SlackApi\Facades\SlackUser::class,
        'SlackStar'             => Craftyx\SlackApi\Facades\SlackStar::class,
        'SlackUserAdmin'        => Craftyx\SlackApi\Facades\SlackUserAdmin::class,
        'SlackRealTimeMessage'  => Craftyx\SlackApi\Facades\SlackRealTimeMessage::class,
        'SlackTeam'             => Craftyx\SlackApi\Facades\SlackTeam::class,
    ]
]

?>

The ::class notation is optional., (*6)

Configuration

configure your slack team token in config/services.php, (*7)

 [
        'token' => 'your token here'
    ]
]

?>

Usage

 'John', 
    'last_name' => 'Doe'
]);

//Send a message to someone or channel or group
SlackChat::message('#general', 'Hello my friends!');

//Upload a file/snippet
SlackFile::upload([
    'filename' => 'sometext.txt', 
    'title' => 'text', 
    'content' => 'Nice contents',
    'channels' => 'C0440SZU6' //can be channel, users, or groups ID
]);

// Search for files or messages
SlackSearch::all('my message');

// Search for files
SlackSearch::files('my file');

// Search for messages
SlackSearch::messages('my message');

// or just use the helper

//Autoload the api
slack()->post('chat.postMessage', [...]);

//Autoload a Slack Method
slack('Chat')->message([...]);
slack('Team')->info();

?>

Using Dependency Injection

slackUser = $slackUser;   
    }
    
    public function controllerMethod(){
        $usersList = $this->slackUser->lists();
    }
}

?>

All Injectable Contracts:

Generic API

Craftyx\SlackApi\Contracts\SlackApi, (*8)

Allows you to do generic requests to the api with the following http verbs: get, post, put, patch, delete ... all allowed api methods you could see here: Slack Web API Methods., (*9)

And is also possible load a SlackMethod contract:, (*10)

load('Channel');
$channel->lists();

/** @var SlackChat $chat **/
$chat = $slack->load('Chat');
$chat->message('D98979F78', 'Hello my friend!');

/** @var SlackUserAdmin $chat **/
$admin = $slack('UserAdmin'); //Minimal syntax (invokable)
$admin->invite('jhon.doe@example.com'); 

?>

Channels API

Craftyx\SlackApi\Contracts\SlackChannel, (*11)

Allows you to operate channels: invite, archive, rename, join, kick, setPurpose ..., (*12)

Chat API

Craftyx\SlackApi\Contracts\SlackChat, (*13)

Allows you to send, update and delete messages with methods: delete, message, update., (*14)

Files API

Craftyx\SlackApi\Contracts\SlackFile, (*15)

Allows you to send, get info, delete, or just list files: info, lists, upload, delete., (*16)

Groups API

Craftyx\SlackApi\Contracts\SlackGroup, (*17)

Same methods of the SlackChannel, but that operates with groups and have adicional methods: open, close, createChild, (*18)

Instant Messages API (Direct Messages)

Craftyx\SlackApi\Contracts\SlackInstantMessage, (*19)

Allows you to manage direct messages to your team members., (*20)

Real Time Messages API

Craftyx\SlackApi\Contracts\SlackRealTimeMessage, (*21)

Allows you list all channels and user presence at the moment., (*22)

Search API

Craftyx\SlackApi\Contracts\SlackSearch, (*23)

Find messages or files., (*24)

Stars API

Craftyx\SlackApi\Contracts\SlackStar, (*25)

List all of starred itens., (*26)

Team API

Craftyx\SlackApi\Contracts\SlackTeam, (*27)

Get information about your team., (*28)

Users API

Craftyx\SlackApi\Contracts\SlackUser, (*29)

Get information about an user on your team or just check your presence ou status., (*30)

Users Admin API

Craftyx\SlackApi\Contracts\SlackUserAdmin, (*31)

Invite new members to your team., (*32)

License

DBAD License., (*33)

The Versions

10/07 2017

dev-master

9999999-dev

Wrapper for Slack.com WEB API. Based on Vagner do Carmo one, but compatible with GuzzleHttp6

  Sources   Download

dbad

The Requires

 

by Daniel Baron
by Julien Tant

laravel lumen slack