Skip to content
This repository has been archived by the owner. It is now read-only.
A library that provides a plain function-call interface to the Slack API web endpoints.
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.codeclimate.yml
.coveralls.yml
.gitignore
.rspec
.simplecov
.travis.yml
.yardopts
CHANGELOG.md
CODE_OF_CONDUCT.md
Gemfile
MIT-LICENSE
README.md
Rakefile
slack-api-wrapper.gemspec

README.md

Slack API Wrapper

Gem Version Build Status Code Climate Coverage Status

A library that provides a plain function-call interface to the Slack API web endpoints.

Installation

Add this line to your application's Gemfile:

gem 'slack-api-wrapper'

And then execute:

bundle

Or install it yourself as:

gem install 'slack-api-wrapper

Usage

You need to get an api token to use the ruby client. You can follow Slack documentation about it (https://api.slack.com/docs/oauth), or use omniauth-slack to get one.

# Initialize client
client = Slack::Client.new api_token

# Test user token
response = client.auth_test
puts "id: #{response['user_id']}, name: #{response['user']}"

# Get user teammates
response = client.users_list
response['members'].each do |user|
  puts "id: #{user['id']}, name: #{user['name']}"
end

# Get user channels
response = client.channels_list
response['channels'].each do |channel|
  puts "id: #{channel['id']}, name: #{channel['name']}"
end

# Get user private groups
response = client.groups_list
response['groups'].each do |group|
  puts "id: #{group['id']}, name: #{group['name']}"
end

# Posting a message
response = client.chat_post_message('channel'=> 'CXXXX', 'text'=> 'Testing Slack API', 'as_user'=> true)

Additional Resources

Slack API Docs: https://api.slack.com/

Contributing

  1. Fork it ( https://github.com/gssbzn/slack-api-wrapper/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

MIT License. Copyright 2015 Gustavo Bazan. http://gustavobazan.com

This software is not created by, affiliated with, or supported by Slack Technologies, Inc.

You can’t perform that action at this time.