From 10fe2fde7428be67d16779ef97fa35262035659a Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Mon, 9 Sep 2019 16:39:22 -0700 Subject: [PATCH 01/24] added slack_token_test --- slack_token_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 slack_token_test.rb diff --git a/slack_token_test.rb b/slack_token_test.rb new file mode 100644 index 00000000..d6e36043 --- /dev/null +++ b/slack_token_test.rb @@ -0,0 +1,16 @@ +require "dotenv" +require "httparty" + +Dotenv.load + +url = "https://slack.com/api/channels.list" + +query = { +token: ENV["SLACK_API_TOKEN"] +} + +response = HTTParty.get(url, query: query) + +response["channels"].each do |channel| + puts channel["name"] +end From 914696b2d09976b26a500ad950ec031c43901a47 Mon Sep 17 00:00:00 2001 From: Sabrina Lowney Date: Mon, 9 Sep 2019 16:52:06 -0700 Subject: [PATCH 02/24] Sabrina - added my slack token test to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 8d6a243f..f3ce94de 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,6 @@ build-iPhoneSimulator/ # Ignore cassette files /specs/cassettes/ + +# Ignore slack token verification +slack_token_verification_test.rb From 470c464d9a48566bdbeacfd4d7bda4e0189c3234 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Tue, 10 Sep 2019 14:15:24 -0700 Subject: [PATCH 03/24] Added User.all method --- .gitignore | 2 +- lib/recipient.rb | 20 +++++++++ lib/slack.rb | 18 ++++++-- lib/user.rb | 32 ++++++++++++++ lib/workspace.rb | 15 +++++++ slack_token_test.rb | 4 +- test/cassettes/users.yml | 95 ++++++++++++++++++++++++++++++++++++++++ test/test_helper.rb | 8 ++++ test/user_test.rb | 21 +++++++++ 9 files changed, 208 insertions(+), 7 deletions(-) create mode 100644 lib/recipient.rb create mode 100644 lib/user.rb create mode 100644 lib/workspace.rb create mode 100644 test/cassettes/users.yml create mode 100644 test/user_test.rb diff --git a/.gitignore b/.gitignore index f3ce94de..d17a69aa 100644 --- a/.gitignore +++ b/.gitignore @@ -49,7 +49,7 @@ build-iPhoneSimulator/ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc -# Ignore environemnt variables +# Ignore environment variables .env # Ignore cassette files diff --git a/lib/recipient.rb b/lib/recipient.rb new file mode 100644 index 00000000..f0d7f499 --- /dev/null +++ b/lib/recipient.rb @@ -0,0 +1,20 @@ +module SlackCLI + + class Recipient + attr_reader :slack_id, :name + def initialize(slack_id, name) + @slack_id = slack_id + @name = name + end + + def self.get(url, params) + raise NotImplementedError + end + + def self.list + + end + end + +end + diff --git a/lib/slack.rb b/lib/slack.rb index 960cf2f7..df54d5a7 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,11 +1,23 @@ #!/usr/bin/env ruby +require "dotenv" +require "httparty" + +Dotenv.load + + + + + + + def main puts "Welcome to the Ada Slack CLI!" - + # TODO project - + puts "Thank you for using the Ada Slack CLI" end -main if __FILE__ == $PROGRAM_NAME \ No newline at end of file +# main if __FILE__ == $PROGRAM_NAME + diff --git a/lib/user.rb b/lib/user.rb new file mode 100644 index 00000000..ad9dcd55 --- /dev/null +++ b/lib/user.rb @@ -0,0 +1,32 @@ +module SlackCLI + class User < Recipient + + attr_reader :real_name + def initialize(slack_id, name, real_name) + super(slack_id, name) + @real_name = real_name + end + + + + def self.get + url = "https://slack.com/api/users.list" + query = { token: ENV["SLACK_API_TOKEN"] } + response = HTTParty.get(url, query: query) + return response["members"] + end + + def self.all + users = [] + self.get.each do |member| + slack_id = member["id"] + name = member["name"] + real_name = member["real_name"] + + SlackCLI:: User.new(slack_id, name, real_name) + end + return users + + end + end +end diff --git a/lib/workspace.rb b/lib/workspace.rb new file mode 100644 index 00000000..b25fd6e2 --- /dev/null +++ b/lib/workspace.rb @@ -0,0 +1,15 @@ +module SlackCLI + class Workspace + + def initialize + @all_users = Users.all + + end + + + + end + + + +end \ No newline at end of file diff --git a/slack_token_test.rb b/slack_token_test.rb index d6e36043..d3de4294 100644 --- a/slack_token_test.rb +++ b/slack_token_test.rb @@ -5,9 +5,7 @@ url = "https://slack.com/api/channels.list" -query = { -token: ENV["SLACK_API_TOKEN"] -} +query = { token: ENV["SLACK_API_TOKEN"] } response = HTTParty.get(url, query: query) diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml new file mode 100644 index 00000000..89ae015c --- /dev/null +++ b/test/cassettes/users.yml @@ -0,0 +1,95 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token=xoxp-754316614912-753852241620-754331635701-77e6365696081bc6ba7788cd6412fca7 + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1610' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 21:14:33 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - acc341f3-6e84-4a8a-941c-4a16aef0c667 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-bd9x + X-Cache: + - Miss from cloudfront + Via: + - 1.1 b23fb37cd7fff033ab21e3284f558a28.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - dum03-TcYqSBfBGbwV70TIJ2f-J3pHMO0t-rZR7zvHUMUJhrjkmmuQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha + Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha + Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha + Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina + Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina + Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina + Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya + Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya + Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya + Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna + Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna + Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia + K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia + K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia + K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan + Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan + Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan + Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany + Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany + Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568150073,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 21:14:33 GMT +recorded_with: VCR 5.0.0 diff --git a/test/test_helper.rb b/test/test_helper.rb index 90aeb408..b52d3df2 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,6 +8,14 @@ require 'minitest/reporters' require 'minitest/skip_dsl' require 'vcr' +require "dotenv" +require "httparty" +require_relative "../lib/recipient" +require_relative "../lib/slack" +require_relative "../lib/user" +require_relative "../lib/workspace" + +Dotenv.load Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new diff --git a/test/user_test.rb b/test/user_test.rb new file mode 100644 index 00000000..7493a84a --- /dev/null +++ b/test/user_test.rb @@ -0,0 +1,21 @@ +require_relative "test_helper" + +describe "User class" do + + describe "Self.all method" do + it "Returns a list of all users" do + + VCR.use_cassette("users") do + all_users = SlackCLI::User.all + + expect(all_users).must_be_instance_of Array + + all_users.each do |user| + expect(user).must_be_instance_of SlackCLI::User + end + end + end + + + end +end From aa781421a3598dcc5c32d4804ec4118eb648a63b Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Tue, 10 Sep 2019 14:23:08 -0700 Subject: [PATCH 04/24] fixed all_users error --- lib/user.rb | 12 +++++++++--- test/user_test.rb | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/user.rb b/lib/user.rb index ad9dcd55..06ad500a 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -1,3 +1,5 @@ + + module SlackCLI class User < Recipient @@ -8,25 +10,29 @@ def initialize(slack_id, name, real_name) end - def self.get url = "https://slack.com/api/users.list" query = { token: ENV["SLACK_API_TOKEN"] } response = HTTParty.get(url, query: query) + return response["members"] end def self.all users = [] - self.get.each do |member| + + self.get().each do |member| slack_id = member["id"] name = member["name"] real_name = member["real_name"] - SlackCLI:: User.new(slack_id, name, real_name) + users << SlackCLI:: User.new(slack_id, name, real_name) + end return users end end end + + diff --git a/test/user_test.rb b/test/user_test.rb index 7493a84a..34f15cf3 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -9,6 +9,7 @@ all_users = SlackCLI::User.all expect(all_users).must_be_instance_of Array + expect(all_users.length).must_equal 8 all_users.each do |user| expect(user).must_be_instance_of SlackCLI::User From 7819a1e35eb1b5a29d64e4779390f39c0fa842a3 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Tue, 10 Sep 2019 14:49:20 -0700 Subject: [PATCH 05/24] removed cassette --- test/cassettes/users.yml | 95 ---------------------------------------- 1 file changed, 95 deletions(-) delete mode 100644 test/cassettes/users.yml diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml deleted file mode 100644 index 89ae015c..00000000 --- a/test/cassettes/users.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://slack.com/api/users.list?token=xoxp-754316614912-753852241620-754331635701-77e6365696081bc6ba7788cd6412fca7 - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '1610' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 21:14:33 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - acc341f3-6e84-4a8a-941c-4a16aef0c667 - X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot - Expires: - - Mon, 26 Jul 1997 05:00:00 GMT - Cache-Control: - - private, no-cache, no-store, must-revalidate - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - X-Xss-Protection: - - '0' - X-Accepted-Oauth-Scopes: - - users:read - Vary: - - Accept-Encoding - Pragma: - - no-cache - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-bd9x - X-Cache: - - Miss from cloudfront - Via: - - 1.1 b23fb37cd7fff033ab21e3284f558a28.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - dum03-TcYqSBfBGbwV70TIJ2f-J3pHMO0t-rZR7zvHUMUJhrjkmmuQ== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha - Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha - Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha - Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina - Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina - Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina - Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya - Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya - Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya - Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna - Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna - Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia - K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia - K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia - K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan - Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan - Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan - Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany - Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany - Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568150073,"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 21:14:33 GMT -recorded_with: VCR 5.0.0 From dabd90cb1650e9ddbb76465dea3d05fd2c60cba3 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Tue, 10 Sep 2019 14:59:21 -0700 Subject: [PATCH 06/24] added channel.all method --- lib/channel.rb | 37 +++++++++++++++ test/cassettes/channels.yml | 81 +++++++++++++++++++++++++++++++ test/cassettes/users.yml | 95 +++++++++++++++++++++++++++++++++++++ test/channel_test.rb | 22 +++++++++ test/test_helper.rb | 13 ++++- 5 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 lib/channel.rb create mode 100644 test/cassettes/channels.yml create mode 100644 test/cassettes/users.yml create mode 100644 test/channel_test.rb diff --git a/lib/channel.rb b/lib/channel.rb new file mode 100644 index 00000000..e21b0521 --- /dev/null +++ b/lib/channel.rb @@ -0,0 +1,37 @@ +module SlackCLI + class Channel < Recipient + + attr_reader :topic, :member_count + def initialize(slack_id:, name:, topic:, member_count:) + super(slack_id, name) + @topic = topic + @member_count = member_count + end + + + def self.get + url = "https://slack.com/api/channels.list" + query = { token: ENV["SLACK_API_TOKEN"] } + response = HTTParty.get(url, query: query) + return response["channels"] + end + + def self.all + channels = [] + + self.get().each do |channel| + slack_id = channel["id"] + name = channel["name"] + topic = channel["topic"]["value"] + member_count = channel["num_members"] + + channels << SlackCLI::Channel.new(slack_id: slack_id, name: name, topic: topic, member_count: member_count) + + end + return channels + + end + end +end + + diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml new file mode 100644 index 00000000..04a4dc86 --- /dev/null +++ b/test/cassettes/channels.yml @@ -0,0 +1,81 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '683' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 21:58:21 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 2cc71178-0105-44c8-9b98-4a7ebeea7aab + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-o27m + X-Cache: + - Miss from cloudfront + Via: + - 1.1 adc2002956acc4d61bfbf3b973fdf247.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - 8iWppjInNCqVUIzBRkxOo1WwAo2cU8x7dA5KCQQrE6ZLBrqER9A87w== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to + collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 21:58:21 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml new file mode 100644 index 00000000..75cc1195 --- /dev/null +++ b/test/cassettes/users.yml @@ -0,0 +1,95 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1610' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 21:58:21 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 4d27ff8c-b0de-46be-a13c-b525fd815c10 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-zscu + X-Cache: + - Miss from cloudfront + Via: + - 1.1 6a6653dfb47ccc5082f2a5b9d0d168ce.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - h1X8bQqCf52wo_mdiOay69mLsqBW_SWKy0VcWvnV7XFKYNcgE4rFFQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha + Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha + Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha + Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina + Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina + Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina + Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya + Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya + Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya + Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna + Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna + Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia + K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia + K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia + K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan + Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan + Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan + Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany + Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany + Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568152701,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 21:58:21 GMT +recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb new file mode 100644 index 00000000..ac23aa88 --- /dev/null +++ b/test/channel_test.rb @@ -0,0 +1,22 @@ +require_relative "test_helper" + +describe "Channel class" do + + describe "Self.all method" do + it "Returns a list of all channels" do + + VCR.use_cassette("channels") do + all_channels = SlackCLI::Channel.all + + expect(all_channels).must_be_instance_of Array + expect(all_channels.length).must_equal 4 + + all_channels.each do |channel| + expect(channel).must_be_instance_of SlackCLI::Channel + end + end + end + + + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index b52d3df2..ba7f7bad 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,12 +14,21 @@ require_relative "../lib/slack" require_relative "../lib/user" require_relative "../lib/workspace" +require_relative "../lib/channel" Dotenv.load Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new VCR.configure do |config| - config.cassette_library_dir = "test/cassettes" - config.hook_into :webmock + config.cassette_library_dir = "test/cassettes" # folder where casettes will be located + config.hook_into :webmock # tie into this other tool called webmock + config.default_cassette_options = { + :record => :new_episodes, # record new data when we don't have it yet + :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match + } + # Don't leave our token lying around in a cassette file. + config.filter_sensitive_data("") do + ENV["SLACK_API_TOKEN"] + end end From 7803a92562f8d85aca1b10f3ce62a0297ef6fbe8 Mon Sep 17 00:00:00 2001 From: Tiffany Chio Date: Tue, 10 Sep 2019 15:33:36 -0700 Subject: [PATCH 07/24] workspace.rb created. tests pass. --- lib/slack.rb | 34 ++++- lib/workspace.rb | 9 +- test/cassettes/channels.yml | 63 ++++++++++ test/cassettes/users.yml | 63 ++++++++++ test/cassettes/workspace.yml | 236 +++++++++++++++++++++++++++++++++++ test/test_helper.rb | 15 +-- test/workspace_test.rb | 31 +++++ 7 files changed, 435 insertions(+), 16 deletions(-) create mode 100644 test/cassettes/workspace.yml create mode 100644 test/workspace_test.rb diff --git a/lib/slack.rb b/lib/slack.rb index df54d5a7..f74fb3c5 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -2,10 +2,29 @@ require "dotenv" require "httparty" +require 'minitest' +require 'minitest/autorun' +require 'minitest/reporters' +require 'minitest/skip_dsl' +require 'vcr' +require "dotenv" +require "httparty" +require 'table_print' +require_relative "recipient" +require_relative "slack" +require_relative "user" +require_relative "workspace" +require_relative "channel" + Dotenv.load +Dotenv.load +def print_users + p WS.users +end +# tp workspace.users, "name", "real_name", "slack_id" @@ -13,11 +32,14 @@ def main puts "Welcome to the Ada Slack CLI!" + again = true + while again + puts "What would you like to do" + end + + puts "Thank you for using the Ada Slack CLI" + end - # TODO project + # main if __FILE__ == $PROGRAM_NAME - puts "Thank you for using the Ada Slack CLI" -end - -# main if __FILE__ == $PROGRAM_NAME - + \ No newline at end of file diff --git a/lib/workspace.rb b/lib/workspace.rb index b25fd6e2..0a6eee26 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,9 +1,12 @@ module SlackCLI class Workspace + attr_reader :users, :channels, :selected + def initialize - @all_users = Users.all - + @users = SlackCLI::User.all + @channels = SlackCLI::Channel.all + @selected = nil end @@ -12,4 +15,4 @@ def initialize -end \ No newline at end of file +end diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index 04a4dc86..2639cd4c 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -78,4 +78,67 @@ http_interactions: are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Tue, 10 Sep 2019 21:58:21 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '53' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:20:27 GMT + Server: + - Apache + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + X-Slack-Req-Id: + - 15411326-61b9-4fb6-be18-e48d76b5f79e + X-Xss-Protection: + - '0' + X-Content-Type-Options: + - nosniff + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-ejbj + X-Cache: + - Miss from cloudfront + Via: + - 1.1 ec2a2c75c16156e4d43504606c118b91.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - f_MZzyjBr_d1FpHd_34ZRS1ruPCZqwaXad0pP0r9ghTPilP69loSvQ== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"not_authed"}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:20:27 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index 75cc1195..25324d2e 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -92,4 +92,67 @@ http_interactions: Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568152701,"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Tue, 10 Sep 2019 21:58:21 GMT +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '53' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:20:28 GMT + Server: + - Apache + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + X-Slack-Req-Id: + - 20f75c8f-3574-4730-aa28-4fd46fb2a055 + X-Xss-Protection: + - '0' + X-Content-Type-Options: + - nosniff + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-w4yr + X-Cache: + - Miss from cloudfront + Via: + - 1.1 34f8ef0e4c880df0650a814412a26ea6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - aRIdDylMz4as-VzhPbmdRU6z4r2hGWce4CZrb4vDzKHWLYWr-Onb_g== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"not_authed"}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:20:28 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml new file mode 100644 index 00000000..385a47e9 --- /dev/null +++ b/test/cassettes/workspace.yml @@ -0,0 +1,236 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '53' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:20:28 GMT + Server: + - Apache + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + X-Slack-Req-Id: + - bf091ffb-4ee2-44d3-bae7-9c959ee81c0d + X-Xss-Protection: + - '0' + X-Content-Type-Options: + - nosniff + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-rjc8 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 d16c3f15bd14953a9d4109eaaa991de2.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - S6WBXTt8RuoGKpvxpqfjYoxQpA7_YEYCGzCU3PRqpUBtDKIsYlGrvg== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"not_authed"}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:20:28 GMT +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1605' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:21:48 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 7f542cf1-1c66-4d24-83dc-e0832ef9d2f0 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-bd9x + X-Cache: + - Miss from cloudfront + Via: + - 1.1 599f04a365a179d553682d476509c389.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - FMTYU272cwVO3iAXNksl3k1zSixhbp4UF1EVFY3_sFaOkfq9SmxBbw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha + Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha + Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha + Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina + Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina + Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina + Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya + Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya + Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya + Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna + Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna + Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia + K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia + K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia + K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan + Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan + Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan + Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany + Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany + Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568154108,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:21:48 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '683' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:21:48 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - cc24c57b-abcb-495f-82ec-acb1d2ed675b + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-oawk + X-Cache: + - Miss from cloudfront + Via: + - 1.1 efcf7b9d0f917f9ebf314db03e52d9b7.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - kVBZUtnGwej6pSP2E2w4C976WFr-tgNnO-_BHpNIWhf3ZShAWIAACQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to + collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:21:49 GMT +recorded_with: VCR 5.0.0 diff --git a/test/test_helper.rb b/test/test_helper.rb index ba7f7bad..34fe26cd 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,6 +10,7 @@ require 'vcr' require "dotenv" require "httparty" +require 'table_print' require_relative "../lib/recipient" require_relative "../lib/slack" require_relative "../lib/user" @@ -24,11 +25,11 @@ config.cassette_library_dir = "test/cassettes" # folder where casettes will be located config.hook_into :webmock # tie into this other tool called webmock config.default_cassette_options = { - :record => :new_episodes, # record new data when we don't have it yet - :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match - } - # Don't leave our token lying around in a cassette file. - config.filter_sensitive_data("") do - ENV["SLACK_API_TOKEN"] - end + :record => :new_episodes, # record new data when we don't have it yet + :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match +} +# Don't leave our token lying around in a cassette file. +config.filter_sensitive_data("") do + ENV["SLACK_API_TOKEN"] +end end diff --git a/test/workspace_test.rb b/test/workspace_test.rb new file mode 100644 index 00000000..7017c7dd --- /dev/null +++ b/test/workspace_test.rb @@ -0,0 +1,31 @@ +require_relative "test_helper" + +describe "Workspace class" do + + describe "Initialize Workspace" do + before do + VCR.use_cassette("workspace") do + @workspace = SlackCLI::Workspace.new + end + end + + it "Creates a new workspace" do + expect(@workspace).must_be_instance_of SlackCLI::Workspace + end + + it "Generates an array of users" do + expect(@workspace.users).must_be_instance_of Array + expect(@workspace.users.first).must_be_instance_of SlackCLI::User + end + + it "Generates an array of channels" do + expect(@workspace.channels).must_be_instance_of Array + expect(@workspace.channels.first).must_be_instance_of SlackCLI::Channel + end + + it "initializes selected as nil" do + expect(@workspace.selected).must_be_nil + end + end +end + From ce2f6ce7da0a37a469d8660a990d8c3aa62b4d3f Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Tue, 10 Sep 2019 16:03:26 -0700 Subject: [PATCH 08/24] implemented the command line loop --- lib/slack.rb | 61 ++++++++++++++++++++++++++++++--------------- test/test_helper.rb | 14 +++++------ 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index f74fb3c5..c113922f 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -2,44 +2,65 @@ require "dotenv" require "httparty" -require 'minitest' -require 'minitest/autorun' -require 'minitest/reporters' -require 'minitest/skip_dsl' -require 'vcr' -require "dotenv" -require "httparty" require 'table_print' require_relative "recipient" -require_relative "slack" require_relative "user" require_relative "workspace" require_relative "channel" Dotenv.load -Dotenv.load +PUMPKIN_SPICE = SlackCLI::Workspace.new() +MAIN_MENU = ["List Users", "List Channels", "Quit"] def print_users - p WS.users + puts "\n" + tp PUMPKIN_SPICE.users, "name", "real_name", "slack_id" end -# tp workspace.users, "name", "real_name", "slack_id" - - +def print_channels + puts "\n" + tp PUMPKIN_SPICE.channels, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" +end +def print_workplace_stats() + user_count = PUMPKIN_SPICE.users.length + channel_count = PUMPKIN_SPICE.channels.length + puts "This workplace has #{user_count} users and #{channel_count} channels." +end +def print_menu() + MAIN_MENU.each_with_index do |menu_item, index| + puts "#{index + 1}. #{menu_item}" + end +end def main - puts "Welcome to the Ada Slack CLI!" + puts "Welcome to the Ada Slack CLI!\n\n" + # lists number of users and channels + print_workplace_stats() + puts "\n" + again = true while again - puts "What would you like to do" - end + # lists menu options + print_menu() + print "\nWhat would you like to do: " + answer = gets.chomp.downcase - puts "Thank you for using the Ada Slack CLI" + case answer + when "list users", "1", "one" + print_users() + puts "\n" + when "list channels", "2", "two" + print_channels() + puts "\n" + when "quit", "3", "three", "exit" + again = false + end end - # main if __FILE__ == $PROGRAM_NAME - - \ No newline at end of file + puts "\nThank you for using the Ada Slack CLI" +end + +main if __FILE__ == $PROGRAM_NAME diff --git a/test/test_helper.rb b/test/test_helper.rb index 34fe26cd..4a2347c4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -25,11 +25,11 @@ config.cassette_library_dir = "test/cassettes" # folder where casettes will be located config.hook_into :webmock # tie into this other tool called webmock config.default_cassette_options = { - :record => :new_episodes, # record new data when we don't have it yet - :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match -} -# Don't leave our token lying around in a cassette file. -config.filter_sensitive_data("") do - ENV["SLACK_API_TOKEN"] -end + :record => :new_episodes, # record new data when we don't have it yet + :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match + } + # Don't leave our token lying around in a cassette file. + config.filter_sensitive_data("") do + ENV["SLACK_API_TOKEN"] + end end From 632bebf1259b78c607fb634bcdd78c815e97ce53 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Tue, 10 Sep 2019 16:39:26 -0700 Subject: [PATCH 09/24] added find_user method and test --- lib/recipient.rb | 6 +++++- lib/slack.rb | 31 ++++++++++++++++++++++++------- lib/user.rb | 3 --- lib/workspace.rb | 18 +++++++++++++----- test/test_helper.rb | 2 +- test/workspace_test.rb | 30 ++++++++++++++++++++++++------ 6 files changed, 67 insertions(+), 23 deletions(-) diff --git a/lib/recipient.rb b/lib/recipient.rb index f0d7f499..92bd0f5f 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -11,8 +11,12 @@ def self.get(url, params) raise NotImplementedError end + def details + raise NotImplementedError + end + def self.list - + raise NotImplementedError end end diff --git a/lib/slack.rb b/lib/slack.rb index c113922f..1b93d46b 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -11,7 +11,7 @@ Dotenv.load PUMPKIN_SPICE = SlackCLI::Workspace.new() -MAIN_MENU = ["List Users", "List Channels", "Quit"] +MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Quit"] def print_users puts "\n" @@ -30,32 +30,49 @@ def print_workplace_stats() end def print_menu() + puts "\n" MAIN_MENU.each_with_index do |menu_item, index| puts "#{index + 1}. #{menu_item}" end + puts "\n" end def main - puts "Welcome to the Ada Slack CLI!\n\n" + puts "Welcome to the Ada Slack CLI!" + puts "\n" # lists number of users and channels print_workplace_stats() - puts "\n" again = true while again # lists menu options print_menu() - print "\nWhat would you like to do: " + print "What would you like to do: " answer = gets.chomp.downcase case answer when "list users", "1", "one" print_users() - puts "\n" + when "list channels", "2", "two" print_channels() - puts "\n" - when "quit", "3", "three", "exit" + + when "select user", "3", "three" + print "Please enter the name or Slack ID of the user you want to select: " + search_term = gets.chomp + + result = PUMPKIN_SPICE.find_user(search_term) + + if result + puts "#{result.name} was found and selected." + else + puts "No user was found." + end + when "select channel", "4", "four" + puts "four" + when "details", "5", "five" + puts "five" + when "quit", "6", "six", "exit" again = false end end diff --git a/lib/user.rb b/lib/user.rb index 06ad500a..def052bc 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -1,5 +1,3 @@ - - module SlackCLI class User < Recipient @@ -9,7 +7,6 @@ def initialize(slack_id, name, real_name) @real_name = real_name end - def self.get url = "https://slack.com/api/users.list" query = { token: ENV["SLACK_API_TOKEN"] } diff --git a/lib/workspace.rb b/lib/workspace.rb index 0a6eee26..4c607132 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -9,10 +9,18 @@ def initialize @selected = nil end - - + def find_user(search_term) + found_user = users.find do |user| + user.name == search_term.downcase || user.slack_id == search_term.upcase + end + + if found_user + @selected = found_user + else + @selected = nil + end + + return selected + end end - - - end diff --git a/test/test_helper.rb b/test/test_helper.rb index 4a2347c4..ba6ac54f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,7 +10,7 @@ require 'vcr' require "dotenv" require "httparty" -require 'table_print' +# require 'table_print' require_relative "../lib/recipient" require_relative "../lib/slack" require_relative "../lib/user" diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 7017c7dd..e7291191 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -1,13 +1,13 @@ require_relative "test_helper" describe "Workspace class" do - - describe "Initialize Workspace" do - before do - VCR.use_cassette("workspace") do - @workspace = SlackCLI::Workspace.new - end + before do + VCR.use_cassette("workspace") do + @workspace = SlackCLI::Workspace.new end + end + describe "Initialize Workspace" do + it "Creates a new workspace" do expect(@workspace).must_be_instance_of SlackCLI::Workspace @@ -27,5 +27,23 @@ expect(@workspace.selected).must_be_nil end end + + describe "find_user method" do + it "Finds the correct user" do + user = @workspace.find_user("slackbot") + + expect(user).must_be_instance_of SlackCLI::User + expect(user.real_name).must_equal "Slackbot" + expect(user.slack_id).must_equal "USLACKBOT" + + end + + it "Returns nil if user isn't found" do + user = @workspace.find_user("goblin") + + expect(user).must_be_nil + end + end + end From 4f373cc0ea10ece3c4aee4c808311caa0a661d3e Mon Sep 17 00:00:00 2001 From: Tiffany Chio Date: Tue, 10 Sep 2019 17:01:47 -0700 Subject: [PATCH 10/24] added finding channel --- lib/slack.rb | 75 ++++++----- lib/workspace.rb | 15 +++ test/cassettes/channels.yml | 144 --------------------- test/cassettes/users.yml | 158 ----------------------- test/cassettes/workspace.yml | 236 ----------------------------------- test/workspace_test.rb | 36 +++++- 6 files changed, 97 insertions(+), 567 deletions(-) delete mode 100644 test/cassettes/channels.yml delete mode 100644 test/cassettes/users.yml delete mode 100644 test/cassettes/workspace.yml diff --git a/lib/slack.rb b/lib/slack.rb index 1b93d46b..b06881df 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -37,6 +37,32 @@ def print_menu() puts "\n" end +def select_user + print "Please enter the name or Slack ID of the user you want to select: " + search_term = gets.chomp + + result = PUMPKIN_SPICE.find_user(search_term) + + if result + puts "The user #{result.name} was found and selected." + else + puts "No user was found." + end +end + +def select_channel + print "Please enter the name or Slack ID of the channel you want to select: " + search_term = gets.chomp + + result = PUMPKIN_SPICE.find_channel(search_term) + + if result + puts "The channel #{result.name} was found and selected." + else + puts "No channel was found." + end +end + def main puts "Welcome to the Ada Slack CLI!" puts "\n" @@ -48,36 +74,29 @@ def main # lists menu options print_menu() print "What would you like to do: " - answer = gets.chomp.downcase - - case answer - when "list users", "1", "one" - print_users() - - when "list channels", "2", "two" - print_channels() - - when "select user", "3", "three" - print "Please enter the name or Slack ID of the user you want to select: " - search_term = gets.chomp + answer = gets.chomp.downcase - result = PUMPKIN_SPICE.find_user(search_term) - - if result - puts "#{result.name} was found and selected." - else - puts "No user was found." + case answer + when "list users", "1", "one" + print_users() + + when "list channels", "2", "two" + print_channels() + + when "select user", "3", "three" + select_user + + when "select channel", "4", "four" + select_channel + when "details", "5", "five" + puts "five" + when "quit", "6", "six", "exit" + again = false end - when "select channel", "4", "four" - puts "four" - when "details", "5", "five" - puts "five" - when "quit", "6", "six", "exit" - again = false end + + puts "\nThank you for using the Ada Slack CLI" end - puts "\nThank you for using the Ada Slack CLI" -end - -main if __FILE__ == $PROGRAM_NAME + main if __FILE__ == $PROGRAM_NAME + \ No newline at end of file diff --git a/lib/workspace.rb b/lib/workspace.rb index 4c607132..2e471a6b 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -22,5 +22,20 @@ def find_user(search_term) return selected end + + def find_channel(search_term) + + found_channel = channels.find do |channel| + channel.name == search_term.downcase || channel.slack_id == search_term.upcase + end + + if found_channel + @selected = found_channel + else + @selected = nil + end + + return selected + end end end diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml deleted file mode 100644 index 2639cd4c..00000000 --- a/test/cassettes/channels.yml +++ /dev/null @@ -1,144 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://slack.com/api/channels.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '683' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 21:58:21 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - 2cc71178-0105-44c8-9b98-4a7ebeea7aab - X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot - Expires: - - Mon, 26 Jul 1997 05:00:00 GMT - Cache-Control: - - private, no-cache, no-store, must-revalidate - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - X-Xss-Protection: - - '0' - X-Accepted-Oauth-Scopes: - - channels:read - Vary: - - Accept-Encoding - Pragma: - - no-cache - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-o27m - X-Cache: - - Miss from cloudfront - Via: - - 1.1 adc2002956acc4d61bfbf3b973fdf247.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - 8iWppjInNCqVUIzBRkxOo1WwAo2cU8x7dA5KCQQrE6ZLBrqER9A87w== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work - banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A - place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber - you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to - collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide - announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This - channel is for workspace-wide communication and announcements. All members - are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 21:58:21 GMT -- request: - method: get - uri: https://slack.com/api/channels.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '53' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 22:20:27 GMT - Server: - - Apache - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - X-Accepted-Oauth-Scopes: - - channels:read - Vary: - - Accept-Encoding - X-Slack-Req-Id: - - 15411326-61b9-4fb6-be18-e48d76b5f79e - X-Xss-Protection: - - '0' - X-Content-Type-Options: - - nosniff - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-ejbj - X-Cache: - - Miss from cloudfront - Via: - - 1.1 ec2a2c75c16156e4d43504606c118b91.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - f_MZzyjBr_d1FpHd_34ZRS1ruPCZqwaXad0pP0r9ghTPilP69loSvQ== - body: - encoding: ASCII-8BIT - string: '{"ok":false,"error":"not_authed"}' - http_version: - recorded_at: Tue, 10 Sep 2019 22:20:27 GMT -recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml deleted file mode 100644 index 25324d2e..00000000 --- a/test/cassettes/users.yml +++ /dev/null @@ -1,158 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://slack.com/api/users.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '1610' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 21:58:21 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - 4d27ff8c-b0de-46be-a13c-b525fd815c10 - X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot - Expires: - - Mon, 26 Jul 1997 05:00:00 GMT - Cache-Control: - - private, no-cache, no-store, must-revalidate - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - X-Xss-Protection: - - '0' - X-Accepted-Oauth-Scopes: - - users:read - Vary: - - Accept-Encoding - Pragma: - - no-cache - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-zscu - X-Cache: - - Miss from cloudfront - Via: - - 1.1 6a6653dfb47ccc5082f2a5b9d0d168ce.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - h1X8bQqCf52wo_mdiOay69mLsqBW_SWKy0VcWvnV7XFKYNcgE4rFFQ== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha - Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha - Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha - Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina - Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina - Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina - Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya - Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya - Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya - Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna - Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna - Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia - K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia - K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia - K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan - Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan - Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan - Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany - Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany - Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568152701,"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 21:58:21 GMT -- request: - method: get - uri: https://slack.com/api/users.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '53' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 22:20:28 GMT - Server: - - Apache - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - X-Accepted-Oauth-Scopes: - - users:read - Vary: - - Accept-Encoding - X-Slack-Req-Id: - - 20f75c8f-3574-4730-aa28-4fd46fb2a055 - X-Xss-Protection: - - '0' - X-Content-Type-Options: - - nosniff - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-w4yr - X-Cache: - - Miss from cloudfront - Via: - - 1.1 34f8ef0e4c880df0650a814412a26ea6.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - aRIdDylMz4as-VzhPbmdRU6z4r2hGWce4CZrb4vDzKHWLYWr-Onb_g== - body: - encoding: ASCII-8BIT - string: '{"ok":false,"error":"not_authed"}' - http_version: - recorded_at: Tue, 10 Sep 2019 22:20:28 GMT -recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml deleted file mode 100644 index 385a47e9..00000000 --- a/test/cassettes/workspace.yml +++ /dev/null @@ -1,236 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://slack.com/api/users.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '53' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 22:20:28 GMT - Server: - - Apache - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - X-Accepted-Oauth-Scopes: - - users:read - Vary: - - Accept-Encoding - X-Slack-Req-Id: - - bf091ffb-4ee2-44d3-bae7-9c959ee81c0d - X-Xss-Protection: - - '0' - X-Content-Type-Options: - - nosniff - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-rjc8 - X-Cache: - - Miss from cloudfront - Via: - - 1.1 d16c3f15bd14953a9d4109eaaa991de2.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - S6WBXTt8RuoGKpvxpqfjYoxQpA7_YEYCGzCU3PRqpUBtDKIsYlGrvg== - body: - encoding: ASCII-8BIT - string: '{"ok":false,"error":"not_authed"}' - http_version: - recorded_at: Tue, 10 Sep 2019 22:20:28 GMT -- request: - method: get - uri: https://slack.com/api/users.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '1605' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 22:21:48 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - 7f542cf1-1c66-4d24-83dc-e0832ef9d2f0 - X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot - Expires: - - Mon, 26 Jul 1997 05:00:00 GMT - Cache-Control: - - private, no-cache, no-store, must-revalidate - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - X-Xss-Protection: - - '0' - X-Accepted-Oauth-Scopes: - - users:read - Vary: - - Accept-Encoding - Pragma: - - no-cache - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-bd9x - X-Cache: - - Miss from cloudfront - Via: - - 1.1 599f04a365a179d553682d476509c389.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - FMTYU272cwVO3iAXNksl3k1zSixhbp4UF1EVFY3_sFaOkfq9SmxBbw== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha - Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha - Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha - Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina - Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina - Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina - Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya - Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya - Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya - Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna - Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna - Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia - K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia - K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia - K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan - Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan - Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan - Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany - Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany - Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568154108,"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 22:21:48 GMT -- request: - method: get - uri: https://slack.com/api/channels.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '683' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 22:21:48 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - cc24c57b-abcb-495f-82ec-acb1d2ed675b - X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot - Expires: - - Mon, 26 Jul 1997 05:00:00 GMT - Cache-Control: - - private, no-cache, no-store, must-revalidate - Access-Control-Expose-Headers: - - x-slack-req-id, retry-after - X-Xss-Protection: - - '0' - X-Accepted-Oauth-Scopes: - - channels:read - Vary: - - Accept-Encoding - Pragma: - - no-cache - Access-Control-Allow-Headers: - - slack-route, x-slack-version-ts - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload - Referrer-Policy: - - no-referrer - Access-Control-Allow-Origin: - - "*" - X-Via: - - haproxy-www-oawk - X-Cache: - - Miss from cloudfront - Via: - - 1.1 efcf7b9d0f917f9ebf314db03e52d9b7.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - kVBZUtnGwej6pSP2E2w4C976WFr-tgNnO-_BHpNIWhf3ZShAWIAACQ== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work - banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A - place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber - you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to - collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide - announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This - channel is for workspace-wide communication and announcements. All members - are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 22:21:49 GMT -recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index e7291191..bcf1f190 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -29,7 +29,7 @@ end describe "find_user method" do - it "Finds the correct user" do + it "Finds the correct user from username" do user = @workspace.find_user("slackbot") expect(user).must_be_instance_of SlackCLI::User @@ -38,6 +38,14 @@ end + it "Finds the correct user from slack ID" do + user = @workspace.find_user("USLACKBOT") + + expect(user).must_be_instance_of SlackCLI::User + expect(user.real_name).must_equal "Slackbot" + + end + it "Returns nil if user isn't found" do user = @workspace.find_user("goblin") @@ -45,5 +53,31 @@ end end + describe "find_channel method" do + it "Finds the correct channel from channel name" do + channel = @workspace.find_channel("random") + + expect(channel).must_be_instance_of SlackCLI::Channel + expect(channel.member_count).must_equal 7 + expect(channel.slack_id).must_equal "CMUR2JTNX" + + end + + it "Finds the correct channel from slack ID" do + channel = @workspace.find_channel("CN6A88SJZ") + + expect(channel).must_be_instance_of SlackCLI::Channel + expect(channel.member_count).must_equal 3 + expect(channel.name).must_equal "turkey" + + end + + it "Returns nil if channel isn't found" do + channel = @workspace.find_channel("goblin") + + expect(channel).must_be_nil + end + end + end From 6832248b9db971c3c990976c6c1825397831fe80 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Wed, 11 Sep 2019 13:41:41 -0700 Subject: [PATCH 11/24] updated user and channel tests to check selected --- lib/channel.rb | 6 +- lib/recipient.rb | 9 +- lib/slack.rb | 48 +++++----- lib/user.rb | 8 +- lib/workspace.rb | 1 - test/cassettes/channels.yml | 81 ++++++++++++++++ test/cassettes/users.yml | 95 +++++++++++++++++++ test/cassettes/workspace.yml | 173 +++++++++++++++++++++++++++++++++++ test/channel_test.rb | 5 +- test/test_helper.rb | 2 - test/user_test.rb | 2 - test/workspace_test.rb | 35 +++++-- 12 files changed, 408 insertions(+), 57 deletions(-) create mode 100644 test/cassettes/channels.yml create mode 100644 test/cassettes/users.yml create mode 100644 test/cassettes/workspace.yml diff --git a/lib/channel.rb b/lib/channel.rb index e21b0521..e6528770 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -2,13 +2,13 @@ module SlackCLI class Channel < Recipient attr_reader :topic, :member_count + def initialize(slack_id:, name:, topic:, member_count:) super(slack_id, name) @topic = topic @member_count = member_count end - def self.get url = "https://slack.com/api/channels.list" query = { token: ENV["SLACK_API_TOKEN"] } @@ -26,12 +26,8 @@ def self.all member_count = channel["num_members"] channels << SlackCLI::Channel.new(slack_id: slack_id, name: name, topic: topic, member_count: member_count) - end return channels - end end end - - diff --git a/lib/recipient.rb b/lib/recipient.rb index 92bd0f5f..305ef8e5 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -2,23 +2,22 @@ module SlackCLI class Recipient attr_reader :slack_id, :name + def initialize(slack_id, name) @slack_id = slack_id @name = name end - def self.get(url, params) + def details raise NotImplementedError end - def details + def self.get(url, params) raise NotImplementedError end - def self.list + def self.all raise NotImplementedError end end - end - diff --git a/lib/slack.rb b/lib/slack.rb index b06881df..ba4b06b3 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require "dotenv" require "httparty" - require 'table_print' require_relative "recipient" require_relative "user" @@ -73,30 +72,31 @@ def main while again # lists menu options print_menu() - print "What would you like to do: " - answer = gets.chomp.downcase + print "What would you like to do? " + answer = gets.chomp.downcase + + case answer + when "list users", "1", "one" + print_users() + + when "list channels", "2", "two" + print_channels() + + when "select user", "3", "three" + select_user + + when "select channel", "4", "four" + select_channel - case answer - when "list users", "1", "one" - print_users() - - when "list channels", "2", "two" - print_channels() - - when "select user", "3", "three" - select_user - - when "select channel", "4", "four" - select_channel - when "details", "5", "five" - puts "five" - when "quit", "6", "six", "exit" - again = false - end + when "details", "5", "five" + puts "five" + + when "quit", "6", "six", "exit" + again = false end - - puts "\nThank you for using the Ada Slack CLI" end - main if __FILE__ == $PROGRAM_NAME - \ No newline at end of file + puts "\nThank you for using the Ada Slack CLI" +end + +main if __FILE__ == $PROGRAM_NAME diff --git a/lib/user.rb b/lib/user.rb index def052bc..674473c9 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -2,7 +2,8 @@ module SlackCLI class User < Recipient attr_reader :real_name - def initialize(slack_id, name, real_name) + + def initialize(slack_id:, name:, real_name:) super(slack_id, name) @real_name = real_name end @@ -23,13 +24,10 @@ def self.all name = member["name"] real_name = member["real_name"] - users << SlackCLI:: User.new(slack_id, name, real_name) + users << SlackCLI:: User.new(slack_id: slack_id, name: name, real_name: real_name) end return users - end end end - - diff --git a/lib/workspace.rb b/lib/workspace.rb index 2e471a6b..135cda9e 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -24,7 +24,6 @@ def find_user(search_term) end def find_channel(search_term) - found_channel = channels.find do |channel| channel.name == search_term.downcase || channel.slack_id == search_term.upcase end diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml new file mode 100644 index 00000000..200caa63 --- /dev/null +++ b/test/cassettes/channels.yml @@ -0,0 +1,81 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '683' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 15:21:19 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - f2a7c0c2-4d5b-400c-aef1-99a8028cd6a5 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-aaa1 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 39688168a2a3353be1f3c9378d12d89f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - IgLgOjxy7fFWuXirojf78NAkBmfRHGceGy-iPb0TmyfyELRSm_QLHQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to + collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 15:21:19 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml new file mode 100644 index 00000000..4a1b8d6e --- /dev/null +++ b/test/cassettes/users.yml @@ -0,0 +1,95 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1609' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 15:21:19 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - ea4959fb-bd38-4048-9735-7dc720497339 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-ggp6 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 2bedbeaa49b4a77447d30097858cb81a.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - t7ow58O6WpjDmDMs_gyyWhuQgqhb8ko508qCKF4oGVqhbbnfwTZe3g== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha + Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha + Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha + Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina + Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina + Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina + Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya + Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya + Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya + Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna + Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna + Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia + K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia + K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia + K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan + Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan + Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan + Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany + Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany + Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568215279,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 15:21:19 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml new file mode 100644 index 00000000..cc9f41a5 --- /dev/null +++ b/test/cassettes/workspace.yml @@ -0,0 +1,173 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1609' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 15:21:19 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - e329c77e-24ae-4168-9107-679e36058b8e + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-3caj + X-Cache: + - Miss from cloudfront + Via: + - 1.1 476c2ba6d9f6cd69dbcedbd65688cbc0.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - 6ZEKChXayy33-pzDm9inV1dnD4s9kbnB6fppLSQYOJjPoU4jxtmZvQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha + Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha + Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha + Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina + Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina + Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina + Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya + Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya + Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya + Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna + Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna + Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia + K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia + K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia + K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan + Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan + Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan + Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany + Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany + Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568215279,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 15:21:19 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '683' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 15:21:19 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - b0445b08-0c1c-4fbf-9d23-d092f0806049 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-asnz + X-Cache: + - Miss from cloudfront + Via: + - 1.1 98aedae6661e3904540676966998ed89.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - UHGIAHrcpNeQ1gno1V7LXpQBlW9SDXAYOYJZyRzKzAsQSYYQzNwTVA== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to + collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 15:21:19 GMT +recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index ac23aa88..4008fb40 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -1,10 +1,9 @@ require_relative "test_helper" -describe "Channel class" do +describe "Channel class" do describe "Self.all method" do it "Returns a list of all channels" do - VCR.use_cassette("channels") do all_channels = SlackCLI::Channel.all @@ -16,7 +15,5 @@ end end end - - end end diff --git a/test/test_helper.rb b/test/test_helper.rb index ba6ac54f..68faaa06 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,9 +10,7 @@ require 'vcr' require "dotenv" require "httparty" -# require 'table_print' require_relative "../lib/recipient" -require_relative "../lib/slack" require_relative "../lib/user" require_relative "../lib/workspace" require_relative "../lib/channel" diff --git a/test/user_test.rb b/test/user_test.rb index 34f15cf3..7bc17a9e 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -16,7 +16,5 @@ end end end - - end end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index bcf1f190..4b5cd381 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -6,9 +6,8 @@ @workspace = SlackCLI::Workspace.new end end + describe "Initialize Workspace" do - - it "Creates a new workspace" do expect(@workspace).must_be_instance_of SlackCLI::Workspace end @@ -35,7 +34,6 @@ expect(user).must_be_instance_of SlackCLI::User expect(user.real_name).must_equal "Slackbot" expect(user.slack_id).must_equal "USLACKBOT" - end it "Finds the correct user from slack ID" do @@ -43,7 +41,6 @@ expect(user).must_be_instance_of SlackCLI::User expect(user.real_name).must_equal "Slackbot" - end it "Returns nil if user isn't found" do @@ -51,6 +48,18 @@ expect(user).must_be_nil end + + it "Changes selected to the chosen user" do + user = @workspace.find_user("slackbot") + + expect(@workspace.selected).must_equal user + end + + it "Changes selected to nil if no user found" do + user = @workspace.find_user("garbage") + + expect(@workspace.selected).must_be_nil + end end describe "find_channel method" do @@ -60,7 +69,6 @@ expect(channel).must_be_instance_of SlackCLI::Channel expect(channel.member_count).must_equal 7 expect(channel.slack_id).must_equal "CMUR2JTNX" - end it "Finds the correct channel from slack ID" do @@ -69,7 +77,6 @@ expect(channel).must_be_instance_of SlackCLI::Channel expect(channel.member_count).must_equal 3 expect(channel.name).must_equal "turkey" - end it "Returns nil if channel isn't found" do @@ -77,7 +84,17 @@ expect(channel).must_be_nil end - end - + + it "Changes selected to the chosen channel" do + channel = @workspace.find_channel("random") + + expect(@workspace.selected).must_equal channel + end + + it "Changes selected to nil if no user found" do + channel = @workspace.find_channel("garbage") + + expect(@workspace.selected).must_be_nil + end + end end - From 2901ef4d405e33cfe8d4ee825094c3c76d5e773e Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Wed, 11 Sep 2019 13:55:24 -0700 Subject: [PATCH 12/24] refactored self.get to be a Recipient method, implemented 'details' command --- lib/channel.rb | 11 +++-------- lib/recipient.rb | 18 ++++++++++++++++-- lib/slack.rb | 17 +++++++++++++++-- lib/user.rb | 12 +++--------- test/cassettes/channels.yml | 21 ++++++++++++--------- test/cassettes/users.yml | 14 +++++++------- test/cassettes/workspace.yml | 35 +++++++++++++++++++---------------- test/workspace_test.rb | 4 ++-- 8 files changed, 77 insertions(+), 55 deletions(-) diff --git a/lib/channel.rb b/lib/channel.rb index e6528770..c581931f 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -9,17 +9,12 @@ def initialize(slack_id:, name:, topic:, member_count:) @member_count = member_count end - def self.get - url = "https://slack.com/api/channels.list" - query = { token: ENV["SLACK_API_TOKEN"] } - response = HTTParty.get(url, query: query) - return response["channels"] - end - def self.all channels = [] - self.get().each do |channel| + response = Channel.get("channels.list") + + response["channels"].each do |channel| slack_id = channel["id"] name = channel["name"] topic = channel["topic"]["value"] diff --git a/lib/recipient.rb b/lib/recipient.rb index 305ef8e5..762f0451 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -12,10 +12,24 @@ def details raise NotImplementedError end - def self.get(url, params) - raise NotImplementedError + # def self.get(url, params) + # raise NotImplementedError + # end + + def self.get(url) + base_url = "https://slack.com/api/" + url = base_url + url + query = { token: ENV["SLACK_API_TOKEN"] } + response = HTTParty.get(url, query: query) + return response + + # return response["members"] end + + + + def self.all raise NotImplementedError end diff --git a/lib/slack.rb b/lib/slack.rb index ba4b06b3..b6660821 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -42,6 +42,7 @@ def select_user result = PUMPKIN_SPICE.find_user(search_term) + puts if result puts "The user #{result.name} was found and selected." else @@ -55,6 +56,7 @@ def select_channel result = PUMPKIN_SPICE.find_channel(search_term) + puts if result puts "The channel #{result.name} was found and selected." else @@ -62,9 +64,20 @@ def select_channel end end +def print_details() + puts + if PUMPKIN_SPICE.selected.class == SlackCLI::User + tp PUMPKIN_SPICE.selected, "name", "real_name", "slack_id" + elsif PUMPKIN_SPICE.selected.class == SlackCLI::Channel + tp PUMPKIN_SPICE.selected, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" + else + puts "There is no recipient selected." + end +end + def main puts "Welcome to the Ada Slack CLI!" - puts "\n" + puts # lists number of users and channels print_workplace_stats() @@ -89,7 +102,7 @@ def main select_channel when "details", "5", "five" - puts "five" + print_details() when "quit", "6", "six", "exit" again = false diff --git a/lib/user.rb b/lib/user.rb index 674473c9..14cfd1ec 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -8,18 +8,12 @@ def initialize(slack_id:, name:, real_name:) @real_name = real_name end - def self.get - url = "https://slack.com/api/users.list" - query = { token: ENV["SLACK_API_TOKEN"] } - response = HTTParty.get(url, query: query) - - return response["members"] - end - def self.all users = [] - self.get().each do |member| + response = User.get("users.list") + + response["members"].each do |member| slack_id = member["id"] name = member["name"] real_name = member["real_name"] diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index 200caa63..aa60ac79 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -21,17 +21,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '683' + - '713' Connection: - keep-alive Date: - - Wed, 11 Sep 2019 15:21:19 GMT + - Wed, 11 Sep 2019 20:47:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - f2a7c0c2-4d5b-400c-aef1-99a8028cd6a5 + - 91379e9a-8bd1-411f-a6cf-2f4ac1a3d1a6 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,25 +57,28 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-aaa1 + - haproxy-www-s1xo X-Cache: - Miss from cloudfront Via: - - 1.1 39688168a2a3353be1f3c9378d12d89f.cloudfront.net (CloudFront) + - 1.1 82ea95080f526df99896343fb7269b07.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - IgLgOjxy7fFWuXirojf78NAkBmfRHGceGy-iPb0TmyfyELRSm_QLHQ== + - qkTpTlzHTb87v5-GrLdYFd4P-TDjKr3WI1WEWt1J-7tlZGZJQD0vHg== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber - you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to - collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide + you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"To + collect images of turkeys and information about turkeys","creator":"UN5R273J8","last_set":1568232705},"purpose":{"value":"to + collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Posts + about the Slack CLI project","creator":"UN5R273J8","last_set":1568232665},"purpose":{"value":"Posts + about the Slack CLI project","creator":"UN5R273J8","last_set":1568232660},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 15:21:19 GMT + recorded_at: Wed, 11 Sep 2019 20:47:57 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index 4a1b8d6e..2fa74d36 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 15:21:19 GMT + - Wed, 11 Sep 2019 20:47:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - ea4959fb-bd38-4048-9735-7dc720497339 + - 5d95708e-d5e5-43a5-92da-bbb15e78c203 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-ggp6 + - haproxy-www-zscu X-Cache: - Miss from cloudfront Via: - - 1.1 2bedbeaa49b4a77447d30097858cb81a.cloudfront.net (CloudFront) + - 1.1 760139201585481b26f947c5f776103a.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - t7ow58O6WpjDmDMs_gyyWhuQgqhb8ko508qCKF4oGVqhbbnfwTZe3g== + - HdOe9Cf1zeiGrlSh9InwarBX_t67u3on-F7XAvnGBCDmNvFmXR-9oQ== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,7 +89,7 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568215279,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568234877,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 15:21:19 GMT + recorded_at: Wed, 11 Sep 2019 20:47:57 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index cc9f41a5..6bf31d68 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 15:21:19 GMT + - Wed, 11 Sep 2019 20:47:56 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - e329c77e-24ae-4168-9107-679e36058b8e + - c1923b64-5011-4da0-9d1d-7c24c7122c47 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-3caj + - haproxy-www-gdn8 X-Cache: - Miss from cloudfront Via: - - 1.1 476c2ba6d9f6cd69dbcedbd65688cbc0.cloudfront.net (CloudFront) + - 1.1 d8792dbd3191bbe722eba5b536b979c8.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - 6ZEKChXayy33-pzDm9inV1dnD4s9kbnB6fppLSQYOJjPoU4jxtmZvQ== + - szQX9MmHZfQkhSW648fcOkPwQXO6JnodX44pcU9pjCnzuApqklvrvw== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568215279,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568234876,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 15:21:19 GMT + recorded_at: Wed, 11 Sep 2019 20:47:56 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -113,17 +113,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '683' + - '713' Connection: - keep-alive Date: - - Wed, 11 Sep 2019 15:21:19 GMT + - Wed, 11 Sep 2019 20:47:56 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - b0445b08-0c1c-4fbf-9d23-d092f0806049 + - 06aed4f0-9154-48ae-80b7-9aed3663ee38 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -149,25 +149,28 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-asnz + - haproxy-www-wjvt X-Cache: - Miss from cloudfront Via: - - 1.1 98aedae6661e3904540676966998ed89.cloudfront.net (CloudFront) + - 1.1 a3bd0eb50c22e4d5fbda56a30b96002d.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - UHGIAHrcpNeQ1gno1V7LXpQBlW9SDXAYOYJZyRzKzAsQSYYQzNwTVA== + - 0z28Cp8OePPc3LiL-Nqa31dQPx5stO5amSGnB6w2jtZ8RTYLSZ4Kxg== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber - you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"to - collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide + you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"To + collect images of turkeys and information about turkeys","creator":"UN5R273J8","last_set":1568232705},"purpose":{"value":"to + collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Posts + about the Slack CLI project","creator":"UN5R273J8","last_set":1568232665},"purpose":{"value":"Posts + about the Slack CLI project","creator":"UN5R273J8","last_set":1568232660},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 15:21:19 GMT + recorded_at: Wed, 11 Sep 2019 20:47:56 GMT recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 4b5cd381..32773481 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -56,7 +56,7 @@ end it "Changes selected to nil if no user found" do - user = @workspace.find_user("garbage") + @workspace.find_user("garbage") expect(@workspace.selected).must_be_nil end @@ -92,7 +92,7 @@ end it "Changes selected to nil if no user found" do - channel = @workspace.find_channel("garbage") + @workspace.find_channel("garbage") expect(@workspace.selected).must_be_nil end From 9f320f8af70645e5c26a591826f411f766b04bdf Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Wed, 11 Sep 2019 14:42:50 -0700 Subject: [PATCH 13/24] added send_message command option; moved workplace-related slack.rb helper methods to workspace.rb --- lib/slack.rb | 59 ++++--------- lib/workspace.rb | 66 +++++++++++++++ test/cassettes/channels.yml | 14 ++-- test/cassettes/send_message.yml | 141 ++++++++++++++++++++++++++++++++ test/cassettes/users.yml | 16 ++-- test/cassettes/workspace.yml | 32 ++++---- test/workspace_test.rb | 51 ++++++++++++ 7 files changed, 306 insertions(+), 73 deletions(-) create mode 100644 test/cassettes/send_message.yml diff --git a/lib/slack.rb b/lib/slack.rb index b6660821..9c0667d3 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -10,7 +10,7 @@ Dotenv.load PUMPKIN_SPICE = SlackCLI::Workspace.new() -MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Quit"] +MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Send Message", "Quit"] def print_users puts "\n" @@ -23,9 +23,7 @@ def print_channels end def print_workplace_stats() - user_count = PUMPKIN_SPICE.users.length - channel_count = PUMPKIN_SPICE.channels.length - puts "This workplace has #{user_count} users and #{channel_count} channels." + puts PUMPKIN_SPICE.get_workplace_stats() end def print_menu() @@ -36,42 +34,16 @@ def print_menu() puts "\n" end -def select_user - print "Please enter the name or Slack ID of the user you want to select: " - search_term = gets.chomp - - result = PUMPKIN_SPICE.find_user(search_term) - - puts - if result - puts "The user #{result.name} was found and selected." - else - puts "No user was found." - end -end - -def select_channel - print "Please enter the name or Slack ID of the channel you want to select: " - search_term = gets.chomp - - result = PUMPKIN_SPICE.find_channel(search_term) - - puts - if result - puts "The channel #{result.name} was found and selected." - else - puts "No channel was found." - end -end - -def print_details() +def get_message() puts - if PUMPKIN_SPICE.selected.class == SlackCLI::User - tp PUMPKIN_SPICE.selected, "name", "real_name", "slack_id" - elsif PUMPKIN_SPICE.selected.class == SlackCLI::Channel - tp PUMPKIN_SPICE.selected, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" + if PUMPKIN_SPICE.selected + print "Please enter a message: " + message = gets.chomp + + PUMPKIN_SPICE.send_message(message) else - puts "There is no recipient selected." + puts + puts "You need to select a recipient." end end @@ -96,15 +68,18 @@ def main print_channels() when "select user", "3", "three" - select_user + PUMPKIN_SPICE.select_user when "select channel", "4", "four" - select_channel + PUMPKIN_SPICE.select_channel when "details", "5", "five" - print_details() + PUMPKIN_SPICE.print_details() + + when "send message", "6", "six" + get_message() - when "quit", "6", "six", "exit" + when "quit", "7", "seven", "exit" again = false end end diff --git a/lib/workspace.rb b/lib/workspace.rb index 135cda9e..a41c9635 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -36,5 +36,71 @@ def find_channel(search_term) return selected end + + def send_message(message_text) + + if selected.nil? + return nil + end + + response = HTTParty.post( + "https://slack.com/api/chat.postMessage", + body: { + token: ENV["SLACK_API_TOKEN"], + text: message_text, + channel: selected.slack_id + }, + headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } + ) + + return response + end + + # Console methods + def select_user + print "Please enter the name or Slack ID of the user you want to select: " + search_term = gets.chomp + + result = find_user(search_term) + + puts + if result + puts "The user #{result.name} was found and selected." + else + puts "No user was found." + end + end + + def select_channel + print "Please enter the name or Slack ID of the channel you want to select: " + search_term = gets.chomp + + result = find_channel(search_term) + + puts + if result + puts "The channel #{result.name} was found and selected." + else + puts "No channel was found." + end + end + + def print_details() + puts + if selected.class == SlackCLI::User + tp selected, "name", "real_name", "slack_id" + elsif selected.class == SlackCLI::Channel + tp selected, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" + else + puts "There is no recipient selected." + end + end + + def get_workplace_stats() + user_count = users.length + channel_count = channels.length + return "This workplace has #{user_count} users and #{channel_count} channels." + end + end end diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index aa60ac79..cf8498b3 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 20:47:57 GMT + - Wed, 11 Sep 2019 21:37:28 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 91379e9a-8bd1-411f-a6cf-2f4ac1a3d1a6 + - a2fcfea5-6fea-4c9c-b913-3654e6da625e X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-s1xo + - haproxy-www-dqjh X-Cache: - Miss from cloudfront Via: - - 1.1 82ea95080f526df99896343fb7269b07.cloudfront.net (CloudFront) + - 1.1 ba150248cd293ea895c35304503c9f27.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - qkTpTlzHTb87v5-GrLdYFd4P-TDjKr3WI1WEWt1J-7tlZGZJQD0vHg== + - J7D50n6oBY1i1xTnyD0oSQeO_vP54N4bK3oA0k-nyWn6Nft8-GAhdA== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -80,5 +80,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 20:47:57 GMT + recorded_at: Wed, 11 Sep 2019 21:37:28 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/send_message.yml b/test/cassettes/send_message.yml new file mode 100644 index 00000000..6498551a --- /dev/null +++ b/test/cassettes/send_message.yml @@ -0,0 +1,141 @@ +--- +http_interactions: +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:37:29 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 95a249f1-86a2-435a-9b10-7bd1b2d07428 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-iuw2 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 5d89a565ccf3467bf90667ebfc36953c.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19 + X-Amz-Cf-Id: + - cUVDp7pWrlPjG2jX4-wOH78qcU_nsf-g3MFVsMo0cdv6loKJrZEraQ== + body: + encoding: UTF-8 + string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568237849.000400","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568237849.000400","username":"Leaves - Dianna + - API Project","bot_id":"BMW7Z23K5"}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:37:29 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:37:29 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - d4c42c7a-6e95-4ac4-bbc5-247e1bb2c432 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-7kp7 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 fa751ee53e2bf18781ae98b293ff9375.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19 + X-Amz-Cf-Id: + - sNgTfAmNOlcc7k16c1E5MD-y5qDg5Ljy5sqhMm7uPkdsBwDwJRo9TA== + body: + encoding: UTF-8 + string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568237849.000200","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a user","ts":"1568237849.000200","username":"Leaves - Dianna + - API Project","bot_id":"BMW7Z23K5"}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:37:29 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index 2fa74d36..08442d5e 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 20:47:57 GMT + - Wed, 11 Sep 2019 21:37:29 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 5d95708e-d5e5-43a5-92da-bbb15e78c203 + - 4a8afa99-80f2-43c8-9d16-5f813e929065 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-zscu + - haproxy-www-c05t X-Cache: - Miss from cloudfront Via: - - 1.1 760139201585481b26f947c5f776103a.cloudfront.net (CloudFront) + - 1.1 a8a06e035420932f2808c2efee52f455.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - HdOe9Cf1zeiGrlSh9InwarBX_t67u3on-F7XAvnGBCDmNvFmXR-9oQ== + - 6sqqRz7syCRQygr0xZ2yKxjvkDcLY7ADLkhuYB_VME55spRakGqqmw== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,7 +89,7 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568234877,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568237849,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 20:47:57 GMT + recorded_at: Wed, 11 Sep 2019 21:37:29 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index 6bf31d68..9df470bf 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -21,17 +21,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1609' + - '1610' Connection: - keep-alive Date: - - Wed, 11 Sep 2019 20:47:56 GMT + - Wed, 11 Sep 2019 21:37:28 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - c1923b64-5011-4da0-9d1d-7c24c7122c47 + - 1e22c9e8-ae89-4fac-977c-8efdb3a2a848 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-gdn8 + - haproxy-www-cxk3 X-Cache: - Miss from cloudfront Via: - - 1.1 d8792dbd3191bbe722eba5b536b979c8.cloudfront.net (CloudFront) + - 1.1 9f2fa0c5a611130a0b26673bb62c8388.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - szQX9MmHZfQkhSW648fcOkPwQXO6JnodX44pcU9pjCnzuApqklvrvw== + - PKEyB7mdPcJao4ER_gItx0pzV27OT6JTSLvl03VjgSzCg8t2HgqLuw== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568234876,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568237848,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 20:47:56 GMT + recorded_at: Wed, 11 Sep 2019 21:37:28 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 20:47:56 GMT + - Wed, 11 Sep 2019 21:37:28 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 06aed4f0-9154-48ae-80b7-9aed3663ee38 + - 2f61cd4a-f32f-4b08-8f3d-f0f7b778f949 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -149,15 +149,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-wjvt + - haproxy-www-cfdl X-Cache: - Miss from cloudfront Via: - - 1.1 a3bd0eb50c22e4d5fbda56a30b96002d.cloudfront.net (CloudFront) + - 1.1 2dc84924ce70e874a873764fe1415858.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - 0z28Cp8OePPc3LiL-Nqa31dQPx5stO5amSGnB6w2jtZ8RTYLSZ4Kxg== + - boFxlaAvSpYctxKGKWMEmP-D8x62KOgDHMDcvOckg4-rJfsKHLwAQQ== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -172,5 +172,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 20:47:56 GMT + recorded_at: Wed, 11 Sep 2019 21:37:29 GMT recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 32773481..550d9ac5 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -97,4 +97,55 @@ expect(@workspace.selected).must_be_nil end end + + describe "send_message" do + + it "sends a message to a user" do + VCR.use_cassette("send_message") do + @workspace.find_user("sabrina") + message_text = "I'm a message to a user" + + response = @workspace.send_message(message_text) + + expect(response["ok"]).must_equal true + expect(response["message"]["text"]).must_equal message_text + end + end + + it "sends a message to a channel" do + VCR.use_cassette("send_message") do + @workspace.find_channel("random") + message_text = "I'm a message to a channel" + + response = @workspace.send_message(message_text) + + expect(response["ok"]).must_equal true + expect(response["message"]["text"]).must_equal message_text + end + end + + it "returns channel_not_found for a nonexistent user" do + VCR.use_cassette("send_message") do + @workspace.find_user("goblin") + message_text = "I won't get sent to a user" + + response = @workspace.send_message(message_text) + + expect(response).must_be_nil + end + end + + it "returns channel_not_found for a nonexistent channel" do + VCR.use_cassette("send_message") do + @workspace.find_user("goblin") + message_text = "I won't get sent to a channel" + + response = @workspace.send_message(message_text) + + expect(response).must_be_nil + end + end + + end + end From 0d469a345a4b7cd2490774daab791d7b1a1d82f6 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Wed, 11 Sep 2019 15:23:19 -0700 Subject: [PATCH 14/24] added change bot settings --- lib/slack.rb | 17 +++++++++++-- lib/workspace.rb | 14 ++++++++++- test/cassettes/channels.yml | 14 +++++------ test/cassettes/send_message.yml | 42 ++++++++++++++++----------------- test/cassettes/users.yml | 16 ++++++------- test/cassettes/workspace.yml | 32 ++++++++++++------------- 6 files changed, 79 insertions(+), 56 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 9c0667d3..704abdb2 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -10,7 +10,7 @@ Dotenv.load PUMPKIN_SPICE = SlackCLI::Workspace.new() -MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Send Message", "Quit"] +MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Send Message", "Change Bot Settings", "Quit"] def print_users puts "\n" @@ -47,6 +47,8 @@ def get_message() end end + + def main puts "Welcome to the Ada Slack CLI!" puts @@ -79,7 +81,18 @@ def main when "send message", "6", "six" get_message() - when "quit", "7", "seven", "exit" + when "change bot settings", "7", "seven" + print "Please enter the bot's new name: " + name = gets.chomp + PUMPKIN_SPICE.bot_name = name + puts "The bot's new name is #{name}!" + + print "Please enter the bot's new avatar: " + avatar = gets.chomp + PUMPKIN_SPICE.bot_avatar = avatar + puts "The bot's new avatar is #{avatar}!" + + when "quit", "8", "eight", "exit" again = false end end diff --git a/lib/workspace.rb b/lib/workspace.rb index a41c9635..321a30c8 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -2,11 +2,14 @@ module SlackCLI class Workspace attr_reader :users, :channels, :selected + attr_accessor :bot_name, :bot_avatar def initialize @users = SlackCLI::User.all @channels = SlackCLI::Channel.all @selected = nil + @bot_name = "slackbot" + @bot_avatar = "t-rex" end def find_user(search_term) @@ -43,12 +46,17 @@ def send_message(message_text) return nil end + bot_avatar_symbol = ":#{bot_avatar}:" + response = HTTParty.post( "https://slack.com/api/chat.postMessage", body: { token: ENV["SLACK_API_TOKEN"], text: message_text, - channel: selected.slack_id + channel: selected.slack_id, + as_user: false, + username: bot_name, + icon_emoji: bot_avatar_symbol }, headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } ) @@ -56,6 +64,10 @@ def send_message(message_text) return response end + def change_settings + + end + # Console methods def select_user print "Please enter the name or Slack ID of the user you want to select: " diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index cf8498b3..f4789837 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 21:37:28 GMT + - Wed, 11 Sep 2019 22:09:09 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - a2fcfea5-6fea-4c9c-b913-3654e6da625e + - 388da1a7-eac9-455d-b9a5-d477d708beaf X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-dqjh + - haproxy-www-zrg4 X-Cache: - Miss from cloudfront Via: - - 1.1 ba150248cd293ea895c35304503c9f27.cloudfront.net (CloudFront) + - 1.1 42ef990e439ae115ff739f04e3945234.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C1 X-Amz-Cf-Id: - - J7D50n6oBY1i1xTnyD0oSQeO_vP54N4bK3oA0k-nyWn6Nft8-GAhdA== + - 8VczP4F3TQFp_UuQn8tPjSZOby9dUcBcIB-uHY2JEtFIoYHZMmsmZA== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -80,5 +80,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 21:37:28 GMT + recorded_at: Wed, 11 Sep 2019 22:09:09 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/send_message.yml b/test/cassettes/send_message.yml index 6498551a..444fd3f8 100644 --- a/test/cassettes/send_message.yml +++ b/test/cassettes/send_message.yml @@ -5,7 +5,7 @@ http_interactions: uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX + string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -21,13 +21,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 21:37:29 GMT + - Wed, 11 Sep 2019 22:09:08 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 95a249f1-86a2-435a-9b10-7bd1b2d07428 + - c5431400-d20b-4237-8bfa-6749be069f12 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -53,28 +53,27 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-iuw2 + - haproxy-www-xqej X-Cache: - Miss from cloudfront Via: - - 1.1 5d89a565ccf3467bf90667ebfc36953c.cloudfront.net (CloudFront) + - 1.1 34f8ef0e4c880df0650a814412a26ea6.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C1 X-Amz-Cf-Id: - - cUVDp7pWrlPjG2jX4-wOH78qcU_nsf-g3MFVsMo0cdv6loKJrZEraQ== + - T4_YFveiA2dq7sOShHf3E17eoMhI64SxZ1a99te9BxvG-QcMXMYIRg== body: encoding: UTF-8 - string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568237849.000400","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568237849.000400","username":"Leaves - Dianna - - API Project","bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568239748.001300","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a user","ts":"1568239748.001300","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Wed, 11 Sep 2019 21:37:29 GMT + recorded_at: Wed, 11 Sep 2019 22:09:08 GMT - request: method: post uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX + string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -90,13 +89,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 21:37:29 GMT + - Wed, 11 Sep 2019 22:09:08 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - d4c42c7a-6e95-4ac4-bbc5-247e1bb2c432 + - 0ab7d678-cb9b-41da-ade9-1e2824451b49 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -122,20 +121,19 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-7kp7 + - haproxy-www-5nvv X-Cache: - Miss from cloudfront Via: - - 1.1 fa751ee53e2bf18781ae98b293ff9375.cloudfront.net (CloudFront) + - 1.1 aabd01c4a20dae837d162bd972422efc.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C1 X-Amz-Cf-Id: - - sNgTfAmNOlcc7k16c1E5MD-y5qDg5Ljy5sqhMm7uPkdsBwDwJRo9TA== + - 7rgqKdc8zL6JE6FZxdHFOh4bKVixR5d3p8eXuVKF_P8XkfiXPrF84w== body: encoding: UTF-8 - string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568237849.000200","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a user","ts":"1568237849.000200","username":"Leaves - Dianna - - API Project","bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568239748.001400","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568239748.001400","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Wed, 11 Sep 2019 21:37:29 GMT + recorded_at: Wed, 11 Sep 2019 22:09:09 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index 08442d5e..234f0387 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 21:37:29 GMT + - Wed, 11 Sep 2019 22:09:09 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 4a8afa99-80f2-43c8-9d16-5f813e929065 + - 4553536e-2cad-48a1-a4bb-84f48e5807dd X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-c05t + - haproxy-www-q42r X-Cache: - Miss from cloudfront Via: - - 1.1 a8a06e035420932f2808c2efee52f455.cloudfront.net (CloudFront) + - 1.1 10b37ec1ede3e33f11dd42b87558cd1f.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C1 X-Amz-Cf-Id: - - 6sqqRz7syCRQygr0xZ2yKxjvkDcLY7ADLkhuYB_VME55spRakGqqmw== + - gqbVBQkV6fr8pWpwm91Q_VGj17dxQ0FE6i3278F6JjwWD7MmQ8FeDA== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,7 +89,7 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568237849,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568239749,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 21:37:29 GMT + recorded_at: Wed, 11 Sep 2019 22:09:09 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index 9df470bf..6cf20731 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -21,17 +21,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1610' + - '1609' Connection: - keep-alive Date: - - Wed, 11 Sep 2019 21:37:28 GMT + - Wed, 11 Sep 2019 22:09:08 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 1e22c9e8-ae89-4fac-977c-8efdb3a2a848 + - eedd1193-dec4-4d6c-9971-9fe9700c7588 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-cxk3 + - haproxy-www-dzl1 X-Cache: - Miss from cloudfront Via: - - 1.1 9f2fa0c5a611130a0b26673bb62c8388.cloudfront.net (CloudFront) + - 1.1 d90109c5a0c30f43223e0db85921c5c2.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C1 X-Amz-Cf-Id: - - PKEyB7mdPcJao4ER_gItx0pzV27OT6JTSLvl03VjgSzCg8t2HgqLuw== + - oI9a9bgQ3xopqAymspKj05H0Tju9vimYUxk5_tlSMky1RYvS2LzeOg== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568237848,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568239748,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 21:37:28 GMT + recorded_at: Wed, 11 Sep 2019 22:09:08 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 21:37:28 GMT + - Wed, 11 Sep 2019 22:09:08 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 2f61cd4a-f32f-4b08-8f3d-f0f7b778f949 + - 1e5d4685-d235-4b9f-b5ca-883f782dda2b X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -149,15 +149,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-cfdl + - haproxy-www-zscu X-Cache: - Miss from cloudfront Via: - - 1.1 2dc84924ce70e874a873764fe1415858.cloudfront.net (CloudFront) + - 1.1 b48dedcc55e63f14261aa92cf2d61522.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C1 X-Amz-Cf-Id: - - boFxlaAvSpYctxKGKWMEmP-D8x62KOgDHMDcvOckg4-rJfsKHLwAQQ== + - 9zIvhoV2etSWNfxZ68-2xyjVnkRuY7dJRcdJAZEtJoAJFqUldcE6DQ== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -172,5 +172,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 21:37:29 GMT + recorded_at: Wed, 11 Sep 2019 22:09:08 GMT recorded_with: VCR 5.0.0 From d5b7b8b8b0b2e315cfdefb66ab5fbd57b99b1e60 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Wed, 11 Sep 2019 15:54:26 -0700 Subject: [PATCH 15/24] can change bot settings and save them to json --- bot-settings.json | 1 + lib/slack.rb | 1 + lib/workspace.rb | 17 ++++++++++---- test/cassettes/channels.yml | 14 ++++++------ test/cassettes/send_message.yml | 40 ++++++++++++++++----------------- test/cassettes/users.yml | 16 ++++++------- test/cassettes/workspace.yml | 30 ++++++++++++------------- test/workspace_test.rb | 12 ++++++++++ 8 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 bot-settings.json diff --git a/bot-settings.json b/bot-settings.json new file mode 100644 index 00000000..c2fbd421 --- /dev/null +++ b/bot-settings.json @@ -0,0 +1 @@ +{"bot_name":"Slackbot","bot_avatar":"jack_o_lantern"} \ No newline at end of file diff --git a/lib/slack.rb b/lib/slack.rb index 704abdb2..7648072a 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -93,6 +93,7 @@ def main puts "The bot's new avatar is #{avatar}!" when "quit", "8", "eight", "exit" + PUMPKIN_SPICE.save_settings again = false end end diff --git a/lib/workspace.rb b/lib/workspace.rb index 321a30c8..7570abcf 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,15 +1,20 @@ +require 'json' + module SlackCLI class Workspace attr_reader :users, :channels, :selected attr_accessor :bot_name, :bot_avatar - def initialize + def initialize() @users = SlackCLI::User.all @channels = SlackCLI::Channel.all @selected = nil - @bot_name = "slackbot" - @bot_avatar = "t-rex" + + settings = File.read("bot-settings.json") + settings_hash = JSON.parse(settings) + @bot_name = settings_hash["bot_name"] + @bot_avatar = settings_hash["bot_avatar"] end def find_user(search_term) @@ -64,8 +69,12 @@ def send_message(message_text) return response end - def change_settings + def save_settings + settings_hash = {bot_name: bot_name, bot_avatar: bot_avatar} + File.open("bot-settings.json", "w") do |f| + f.write(settings_hash.to_json) + end end # Console methods diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index f4789837..66f9c2aa 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:09:09 GMT + - Wed, 11 Sep 2019 22:53:19 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 388da1a7-eac9-455d-b9a5-d477d708beaf + - 3850a030-4814-46fe-aa1b-a859f74a4765 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-zrg4 + - haproxy-www-o786 X-Cache: - Miss from cloudfront Via: - - 1.1 42ef990e439ae115ff739f04e3945234.cloudfront.net (CloudFront) + - 1.1 d8792dbd3191bbe722eba5b536b979c8.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C1 + - SEA19-C2 X-Amz-Cf-Id: - - 8VczP4F3TQFp_UuQn8tPjSZOby9dUcBcIB-uHY2JEtFIoYHZMmsmZA== + - WH71gKgCac3NSb4Yg0fvdgHS_c3Zt6fHiHhXy7zauvWnzrquoNtLNg== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -80,5 +80,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:09:09 GMT + recorded_at: Wed, 11 Sep 2019 22:53:19 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/send_message.yml b/test/cassettes/send_message.yml index 444fd3f8..70edb0a0 100644 --- a/test/cassettes/send_message.yml +++ b/test/cassettes/send_message.yml @@ -5,7 +5,7 @@ http_interactions: uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=slackbot&icon_emoji=%3Ajack_o_lantern%3A + string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -21,13 +21,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:09:08 GMT + - Wed, 11 Sep 2019 22:53:19 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - c5431400-d20b-4237-8bfa-6749be069f12 + - 96f69f59-7bf7-4cdb-ab8c-2e85fbcb5e2e X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -53,27 +53,27 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-xqej + - haproxy-www-1zz5 X-Cache: - Miss from cloudfront Via: - - 1.1 34f8ef0e4c880df0650a814412a26ea6.cloudfront.net (CloudFront) + - 1.1 eab8a154a09e69260fbfe4df90182b2f.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C1 + - SEA19-C2 X-Amz-Cf-Id: - - T4_YFveiA2dq7sOShHf3E17eoMhI64SxZ1a99te9BxvG-QcMXMYIRg== + - tAf4tq0KGOgEdwlkO7mMcny4L8HfzoNmNwhOMjI3p45ScSfMgoxOdQ== body: encoding: UTF-8 - string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568239748.001300","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a user","ts":"1568239748.001300","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568242399.002200","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a user","ts":"1568242399.002200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:09:08 GMT + recorded_at: Wed, 11 Sep 2019 22:53:19 GMT - request: method: post uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=slackbot&icon_emoji=%3Ajack_o_lantern%3A + string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -89,13 +89,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:09:08 GMT + - Wed, 11 Sep 2019 22:53:19 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 0ab7d678-cb9b-41da-ade9-1e2824451b49 + - c8a9835d-d292-44d1-a8c2-66e761cff889 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -121,19 +121,19 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-5nvv + - haproxy-www-gxt6 X-Cache: - Miss from cloudfront Via: - - 1.1 aabd01c4a20dae837d162bd972422efc.cloudfront.net (CloudFront) + - 1.1 be082a2326b7d49643607b097f1e7181.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C1 + - SEA19-C2 X-Amz-Cf-Id: - - 7rgqKdc8zL6JE6FZxdHFOh4bKVixR5d3p8eXuVKF_P8XkfiXPrF84w== + - Yx7NY0Lm2Fxz64Q7W09FthNyejcey7V-N1571aYgh9P56RU-yEVjnQ== body: encoding: UTF-8 - string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568239748.001400","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568239748.001400","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568242399.002300","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568242399.002300","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:09:09 GMT + recorded_at: Wed, 11 Sep 2019 22:53:19 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index 234f0387..9c64dd8a 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:09:09 GMT + - Wed, 11 Sep 2019 22:53:19 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 4553536e-2cad-48a1-a4bb-84f48e5807dd + - 36b0c831-64d1-4b64-a389-dc81f0c99555 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-q42r + - haproxy-www-z42f X-Cache: - Miss from cloudfront Via: - - 1.1 10b37ec1ede3e33f11dd42b87558cd1f.cloudfront.net (CloudFront) + - 1.1 6a9b42e38e76b7d4a4044ebe0e0eca09.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C1 + - SEA19-C2 X-Amz-Cf-Id: - - gqbVBQkV6fr8pWpwm91Q_VGj17dxQ0FE6i3278F6JjwWD7MmQ8FeDA== + - njxOPGrumMkor2OsK2AFut9zsHhno7YornaPX4MRBjsSGJLbdP9AKw== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,7 +89,7 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568239749,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568242399,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:09:09 GMT + recorded_at: Wed, 11 Sep 2019 22:53:19 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index 6cf20731..723d21f0 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:09:08 GMT + - Wed, 11 Sep 2019 22:53:18 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - eedd1193-dec4-4d6c-9971-9fe9700c7588 + - 87a3bba8-a259-403b-ac3d-108bbf79cbf5 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-dzl1 + - haproxy-www-s1xo X-Cache: - Miss from cloudfront Via: - - 1.1 d90109c5a0c30f43223e0db85921c5c2.cloudfront.net (CloudFront) + - 1.1 591683988172c7980c4ebb318cbf18a9.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C1 + - SEA19-C2 X-Amz-Cf-Id: - - oI9a9bgQ3xopqAymspKj05H0Tju9vimYUxk5_tlSMky1RYvS2LzeOg== + - kl_9Qs1ofyCl2QzSVtt-UlSlEeCah5pAt4X_Q2PCAv72ikSemlt4iA== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568239748,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568242399,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:09:08 GMT + recorded_at: Wed, 11 Sep 2019 22:53:19 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:09:08 GMT + - Wed, 11 Sep 2019 22:53:19 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 1e5d4685-d235-4b9f-b5ca-883f782dda2b + - 2a291bf9-a666-4f7c-ab4d-cade5f29f7c0 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -149,15 +149,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-zscu + - haproxy-www-33wb X-Cache: - Miss from cloudfront Via: - - 1.1 b48dedcc55e63f14261aa92cf2d61522.cloudfront.net (CloudFront) + - 1.1 98aedae6661e3904540676966998ed89.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C1 + - SEA19-C2 X-Amz-Cf-Id: - - 9zIvhoV2etSWNfxZ68-2xyjVnkRuY7dJRcdJAZEtJoAJFqUldcE6DQ== + - XZ6xagFgZ92rIOTgm8NOJZ89t-Qa9uC7M0k41q10unjUMGfQbnk1tA== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -172,5 +172,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:09:08 GMT + recorded_at: Wed, 11 Sep 2019 22:53:19 GMT recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 550d9ac5..69993924 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -27,6 +27,18 @@ end end + describe "load_bot_settings" do + + it "sets the workplace's username" do + expect(@workspace.bot_name).must_equal "Slackbot" + end + + it "sets the workplace's icon emoji" do + expect(@workspace.bot_avatar).must_equal "jack_o_lantern" + end + + end + describe "find_user method" do it "Finds the correct user from username" do user = @workspace.find_user("slackbot") From 6f476784122dd65042127ccee2d0ad389457275f Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Thu, 12 Sep 2019 13:56:30 -0700 Subject: [PATCH 16/24] added tests for save json --- lib/channel.rb | 1 - lib/recipient.rb | 10 --- lib/slack.rb | 134 ++++++++++++++++++++------------ lib/user.rb | 4 +- lib/workspace.rb | 88 ++++----------------- test/cassettes/channels.yml | 12 +-- test/cassettes/send_message.yml | 32 ++++---- test/cassettes/users.yml | 14 ++-- test/cassettes/workspace.yml | 26 +++---- test/channel_test.rb | 11 +++ test/recipient_test.rb | 25 ++++++ test/test_helper.rb | 13 ++-- test/user_test.rb | 13 +++- test/workspace_test.rb | 48 +++++++++--- 14 files changed, 235 insertions(+), 196 deletions(-) create mode 100644 test/recipient_test.rb diff --git a/lib/channel.rb b/lib/channel.rb index c581931f..8374847f 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -1,6 +1,5 @@ module SlackCLI class Channel < Recipient - attr_reader :topic, :member_count def initialize(slack_id:, name:, topic:, member_count:) diff --git a/lib/recipient.rb b/lib/recipient.rb index 762f0451..c36b7788 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -12,24 +12,14 @@ def details raise NotImplementedError end - # def self.get(url, params) - # raise NotImplementedError - # end - def self.get(url) base_url = "https://slack.com/api/" url = base_url + url query = { token: ENV["SLACK_API_TOKEN"] } response = HTTParty.get(url, query: query) return response - - # return response["members"] end - - - - def self.all raise NotImplementedError end diff --git a/lib/slack.rb b/lib/slack.rb index 7648072a..0fc70d98 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -10,8 +10,21 @@ Dotenv.load PUMPKIN_SPICE = SlackCLI::Workspace.new() + MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Send Message", "Change Bot Settings", "Quit"] +def print_workplace_stats() + puts PUMPKIN_SPICE.get_workplace_stats() +end + +def print_menu() + puts "\nMAIN MENU" + MAIN_MENU.each_with_index do |menu_item, index| + puts "#{index + 1}. #{menu_item}" + end + puts "\n" +end + def print_users puts "\n" tp PUMPKIN_SPICE.users, "name", "real_name", "slack_id" @@ -22,16 +35,43 @@ def print_channels tp PUMPKIN_SPICE.channels, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" end -def print_workplace_stats() - puts PUMPKIN_SPICE.get_workplace_stats() +def select_user + print "Please enter the name or Slack ID of the user you want to select: " + search_term = gets.chomp + + result = PUMPKIN_SPICE.find_user(search_term) + + puts + if result + puts "The user #{result.name} was found and selected." + else + puts "No user was found." + end end -def print_menu() - puts "\n" - MAIN_MENU.each_with_index do |menu_item, index| - puts "#{index + 1}. #{menu_item}" +def select_channel + print "Please enter the name or Slack ID of the channel you want to select: " + search_term = gets.chomp + + result = PUMPKIN_SPICE.find_channel(search_term) + + puts + if result + puts "The channel #{result.name} was found and selected." + else + puts "No channel was found." + end +end + +def print_details() + puts + if selected.class == SlackCLI::User + tp selected, "name", "real_name", "slack_id" + elsif selected.class == SlackCLI::Channel + tp selected, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" + else + puts "There is no recipient selected." end - puts "\n" end def get_message() @@ -42,13 +82,11 @@ def get_message() PUMPKIN_SPICE.send_message(message) else - puts + # puts puts "You need to select a recipient." end end - - def main puts "Welcome to the Ada Slack CLI!" puts @@ -60,45 +98,45 @@ def main # lists menu options print_menu() print "What would you like to do? " - answer = gets.chomp.downcase - - case answer - when "list users", "1", "one" - print_users() - - when "list channels", "2", "two" - print_channels() - - when "select user", "3", "three" - PUMPKIN_SPICE.select_user - - when "select channel", "4", "four" - PUMPKIN_SPICE.select_channel - - when "details", "5", "five" - PUMPKIN_SPICE.print_details() + answer = gets.chomp.downcase - when "send message", "6", "six" - get_message() - - when "change bot settings", "7", "seven" - print "Please enter the bot's new name: " - name = gets.chomp - PUMPKIN_SPICE.bot_name = name - puts "The bot's new name is #{name}!" - - print "Please enter the bot's new avatar: " - avatar = gets.chomp - PUMPKIN_SPICE.bot_avatar = avatar - puts "The bot's new avatar is #{avatar}!" - - when "quit", "8", "eight", "exit" - PUMPKIN_SPICE.save_settings - again = false + case answer + when "list users", "1", "one" + print_users + + when "list channels", "2", "two" + print_channels + + when "select user", "3", "three" + select_user + + when "select channel", "4", "four" + select_channel + + when "details", "5", "five" + print_details + + when "send message", "6", "six" + get_message + + when "change bot settings", "7", "seven" + print "Please enter the bot's new name: " + name = gets.chomp + PUMPKIN_SPICE.bot_name = name + puts "The bot's new name is #{name}!" + + print "Please enter the bot's new avatar: " + avatar = gets.chomp + PUMPKIN_SPICE.bot_avatar = avatar + puts "The bot's new avatar is #{avatar}!" + + when "quit", "8", "eight", "exit" + PUMPKIN_SPICE.save_settings + again = false + end end + puts "\nThank you for using the Ada Slack CLI" end - puts "\nThank you for using the Ada Slack CLI" -end - -main if __FILE__ == $PROGRAM_NAME + main if __FILE__ == $PROGRAM_NAME + \ No newline at end of file diff --git a/lib/user.rb b/lib/user.rb index 14cfd1ec..6588f586 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -1,6 +1,5 @@ module SlackCLI - class User < Recipient - + class User < Recipient attr_reader :real_name def initialize(slack_id:, name:, real_name:) @@ -19,7 +18,6 @@ def self.all real_name = member["real_name"] users << SlackCLI:: User.new(slack_id: slack_id, name: name, real_name: real_name) - end return users end diff --git a/lib/workspace.rb b/lib/workspace.rb index 7570abcf..d844e3fa 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,8 +1,5 @@ -require 'json' - module SlackCLI class Workspace - attr_reader :users, :channels, :selected attr_accessor :bot_name, :bot_avatar @@ -17,16 +14,18 @@ def initialize() @bot_avatar = settings_hash["bot_avatar"] end + def get_workplace_stats() + user_count = users.length + channel_count = channels.length + return "This workplace has #{user_count} users and #{channel_count} channels." + end + def find_user(search_term) found_user = users.find do |user| user.name == search_term.downcase || user.slack_id == search_term.upcase end - if found_user - @selected = found_user - else - @selected = nil - end + found_user ? @selected = found_user : @selected = nil return selected end @@ -36,17 +35,12 @@ def find_channel(search_term) channel.name == search_term.downcase || channel.slack_id == search_term.upcase end - if found_channel - @selected = found_channel - else - @selected = nil - end + found_channel ? @selected = found_channel : @selected = nil return selected end def send_message(message_text) - if selected.nil? return nil end @@ -54,18 +48,15 @@ def send_message(message_text) bot_avatar_symbol = ":#{bot_avatar}:" response = HTTParty.post( - "https://slack.com/api/chat.postMessage", - body: { - token: ENV["SLACK_API_TOKEN"], - text: message_text, - channel: selected.slack_id, - as_user: false, - username: bot_name, - icon_emoji: bot_avatar_symbol - }, - headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } + "https://slack.com/api/chat.postMessage", + body: { token: ENV["SLACK_API_TOKEN"], + text: message_text, + channel: selected.slack_id, + as_user: false, + username: bot_name, + icon_emoji: bot_avatar_symbol }, + headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } ) - return response end @@ -76,52 +67,5 @@ def save_settings f.write(settings_hash.to_json) end end - - # Console methods - def select_user - print "Please enter the name or Slack ID of the user you want to select: " - search_term = gets.chomp - - result = find_user(search_term) - - puts - if result - puts "The user #{result.name} was found and selected." - else - puts "No user was found." - end - end - - def select_channel - print "Please enter the name or Slack ID of the channel you want to select: " - search_term = gets.chomp - - result = find_channel(search_term) - - puts - if result - puts "The channel #{result.name} was found and selected." - else - puts "No channel was found." - end - end - - def print_details() - puts - if selected.class == SlackCLI::User - tp selected, "name", "real_name", "slack_id" - elsif selected.class == SlackCLI::Channel - tp selected, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" - else - puts "There is no recipient selected." - end - end - - def get_workplace_stats() - user_count = users.length - channel_count = channels.length - return "This workplace has #{user_count} users and #{channel_count} channels." - end - end end diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index 66f9c2aa..aba2e052 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:53:19 GMT + - Thu, 12 Sep 2019 20:47:14 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 3850a030-4814-46fe-aa1b-a859f74a4765 + - ecbc14a8-dcdf-4f4f-8471-6f4fb302a24b X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-o786 + - haproxy-www-cxk3 X-Cache: - Miss from cloudfront Via: - - 1.1 d8792dbd3191bbe722eba5b536b979c8.cloudfront.net (CloudFront) + - 1.1 82ea95080f526df99896343fb7269b07.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - WH71gKgCac3NSb4Yg0fvdgHS_c3Zt6fHiHhXy7zauvWnzrquoNtLNg== + - 4OGacAN0zcIqlhpSSdIc7H_WcNC6VU1Ha1vLu5h1-BPHnxn063gSxw== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -80,5 +80,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:53:19 GMT + recorded_at: Thu, 12 Sep 2019 20:47:14 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/send_message.yml b/test/cassettes/send_message.yml index 70edb0a0..36f683c6 100644 --- a/test/cassettes/send_message.yml +++ b/test/cassettes/send_message.yml @@ -21,13 +21,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:53:19 GMT + - Thu, 12 Sep 2019 20:47:15 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 96f69f59-7bf7-4cdb-ab8c-2e85fbcb5e2e + - 6baf0ba4-a03a-4c8d-8b37-4cdf252e15ef X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -53,21 +53,21 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-1zz5 + - haproxy-www-wuu0 X-Cache: - Miss from cloudfront Via: - - 1.1 eab8a154a09e69260fbfe4df90182b2f.cloudfront.net (CloudFront) + - 1.1 570075675953459325e00b7bcd171df3.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - tAf4tq0KGOgEdwlkO7mMcny4L8HfzoNmNwhOMjI3p45ScSfMgoxOdQ== + - tIwjKKXGCTCKtF17xL27S021XYTXCOohAh8ghdhb7tiQJLSib_2ohA== body: encoding: UTF-8 - string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568242399.002200","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a user","ts":"1568242399.002200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568321235.000400","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a user","ts":"1568321235.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:53:19 GMT + recorded_at: Thu, 12 Sep 2019 20:47:15 GMT - request: method: post uri: https://slack.com/api/chat.postMessage @@ -89,13 +89,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:53:19 GMT + - Thu, 12 Sep 2019 20:47:15 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - c8a9835d-d292-44d1-a8c2-66e761cff889 + - 15727ccf-10e8-41e5-befa-bd8291831354 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -121,19 +121,19 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-gxt6 + - haproxy-www-dqjh X-Cache: - Miss from cloudfront Via: - - 1.1 be082a2326b7d49643607b097f1e7181.cloudfront.net (CloudFront) + - 1.1 0732be5515ffeda639cfe5f22fb04df6.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - Yx7NY0Lm2Fxz64Q7W09FthNyejcey7V-N1571aYgh9P56RU-yEVjnQ== + - 7zqzelmeIFlbSVu0GbdYEkKInSyH2KArUTuOhnv9znrioAQ8DJeqHA== body: encoding: UTF-8 - string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568242399.002300","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568242399.002300","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568321235.000400","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568321235.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:53:19 GMT + recorded_at: Thu, 12 Sep 2019 20:47:15 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index 9c64dd8a..ef7df6ed 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:53:19 GMT + - Thu, 12 Sep 2019 20:47:14 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 36b0c831-64d1-4b64-a389-dc81f0c99555 + - 5d7d5c73-d80a-405e-a924-426cc36e9a72 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-z42f + - haproxy-www-admz X-Cache: - Miss from cloudfront Via: - - 1.1 6a9b42e38e76b7d4a4044ebe0e0eca09.cloudfront.net (CloudFront) + - 1.1 3cd7af07832481c336aa1c93c9b4a6fe.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - njxOPGrumMkor2OsK2AFut9zsHhno7YornaPX4MRBjsSGJLbdP9AKw== + - 4fsv878bVjbRAh_clH3yL53kjUvTnDq58pOzrGN7qVwpSz2PF9_mYQ== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,7 +89,7 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568242399,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568321235,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:53:19 GMT + recorded_at: Thu, 12 Sep 2019 20:47:15 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index 723d21f0..544cea5e 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:53:18 GMT + - Thu, 12 Sep 2019 20:47:15 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 87a3bba8-a259-403b-ac3d-108bbf79cbf5 + - 806a3fc9-fd12-4814-8078-6d31e55c06f4 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-s1xo + - haproxy-www-1ir4 X-Cache: - Miss from cloudfront Via: - - 1.1 591683988172c7980c4ebb318cbf18a9.cloudfront.net (CloudFront) + - 1.1 82ea95080f526df99896343fb7269b07.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - kl_9Qs1ofyCl2QzSVtt-UlSlEeCah5pAt4X_Q2PCAv72ikSemlt4iA== + - _FH81k1joeVrS8lDbo5xz20jd_9Btkkft5Zmj0yXdU3OM_x83XqWVQ== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568242399,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568321235,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:53:19 GMT + recorded_at: Thu, 12 Sep 2019 20:47:15 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Wed, 11 Sep 2019 22:53:19 GMT + - Thu, 12 Sep 2019 20:47:15 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 2a291bf9-a666-4f7c-ab4d-cade5f29f7c0 + - b5771b1e-9428-41fd-8bc5-c9e085532475 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -149,15 +149,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-33wb + - haproxy-www-g8yt X-Cache: - Miss from cloudfront Via: - - 1.1 98aedae6661e3904540676966998ed89.cloudfront.net (CloudFront) + - 1.1 eab8a154a09e69260fbfe4df90182b2f.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C2 X-Amz-Cf-Id: - - XZ6xagFgZ92rIOTgm8NOJZ89t-Qa9uC7M0k41q10unjUMGfQbnk1tA== + - NcILQnUBidoR-7ut711lXnQ1cGhr-xOZHqFVbKzpIs4DPAoqOIXaHQ== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -172,5 +172,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Wed, 11 Sep 2019 22:53:19 GMT + recorded_at: Thu, 12 Sep 2019 20:47:15 GMT recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index 4008fb40..03ae88ef 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -1,6 +1,17 @@ require_relative "test_helper" describe "Channel class" do + describe "Initialize method" do + it "Initializes a new channel" do + channel = SlackCLI::Channel.new(slack_id: 123, name: "test channel", topic: "tests", member_count: 10) + + expect(channel).must_be_instance_of SlackCLI::Channel + expect(channel.slack_id).must_equal 123 + expect(channel.name).must_equal "test channel" + expect(channel.topic).must_equal "tests" + expect(channel.member_count).must_equal 10 + end + end describe "Self.all method" do it "Returns a list of all channels" do diff --git a/test/recipient_test.rb b/test/recipient_test.rb new file mode 100644 index 00000000..8b3d5e3a --- /dev/null +++ b/test/recipient_test.rb @@ -0,0 +1,25 @@ +require_relative "test_helper" + +describe "Recipient class" do + let(:recipient) { SlackCLI::Recipient.new(123, "test") } + + describe "Initialize method" do + it "Creates an instance of recipient" do + expect(recipient).must_be_instance_of SlackCLI::Recipient + expect(recipient.slack_id).must_equal 123 + expect(recipient.name).must_equal "test" + end + end + + describe "details" do + it "Raises an exception for the details method" do + expect{recipient.details}.must_raise NotImplementedError + end + end + + describe "self.all" do + it "Raises an exception for the self.all method" do + expect{SlackCLI::Recipient.all}.must_raise NotImplementedError + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 68faaa06..67449f15 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,6 +10,7 @@ require 'vcr' require "dotenv" require "httparty" +require "json" require_relative "../lib/recipient" require_relative "../lib/user" require_relative "../lib/workspace" @@ -20,13 +21,11 @@ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new VCR.configure do |config| - config.cassette_library_dir = "test/cassettes" # folder where casettes will be located - config.hook_into :webmock # tie into this other tool called webmock - config.default_cassette_options = { - :record => :new_episodes, # record new data when we don't have it yet - :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match - } - # Don't leave our token lying around in a cassette file. + config.cassette_library_dir = "test/cassettes" + config.hook_into :webmock + config.default_cassette_options = { :record => :new_episodes, + :match_requests_on => [:method, :uri, :body] } + config.filter_sensitive_data("") do ENV["SLACK_API_TOKEN"] end diff --git a/test/user_test.rb b/test/user_test.rb index 7bc17a9e..d6ccc50d 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -1,10 +1,19 @@ require_relative "test_helper" describe "User class" do + describe "Initialize method" do + it "Initializes a new user" do + user = SlackCLI::User.new(slack_id: 123, name: "test", real_name: "Test Name") + + expect(user).must_be_instance_of SlackCLI::User + expect(user.slack_id).must_equal 123 + expect(user.name).must_equal "test" + expect(user.real_name).must_equal "Test Name" + end + end describe "Self.all method" do - it "Returns a list of all users" do - + it "Returns a list of all users" do VCR.use_cassette("users") do all_users = SlackCLI::User.all diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 69993924..7dd040db 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -22,21 +22,26 @@ expect(@workspace.channels.first).must_be_instance_of SlackCLI::Channel end - it "initializes selected as nil" do + it "Initializes selected as nil" do expect(@workspace.selected).must_be_nil end - end - - describe "load_bot_settings" do - it "sets the workplace's username" do + it "Sets the workplace's username" do expect(@workspace.bot_name).must_equal "Slackbot" end - it "sets the workplace's icon emoji" do + it "Sets the workplace's icon emoji" do expect(@workspace.bot_avatar).must_equal "jack_o_lantern" end - + end + + describe "get_workplace_stats method" do + it "Returns a summary with the number of users and channels" do + actual_summary = "This workplace has 8 users and 4 channels." + + summary = @workspace.get_workplace_stats + expect(summary).must_equal actual_summary + end end describe "find_user method" do @@ -111,7 +116,6 @@ end describe "send_message" do - it "sends a message to a user" do VCR.use_cassette("send_message") do @workspace.find_user("sabrina") @@ -136,7 +140,7 @@ end end - it "returns channel_not_found for a nonexistent user" do + it "returns nil for a nonexistent user" do VCR.use_cassette("send_message") do @workspace.find_user("goblin") message_text = "I won't get sent to a user" @@ -147,7 +151,7 @@ end end - it "returns channel_not_found for a nonexistent channel" do + it "returns nil for a nonexistent channel" do VCR.use_cassette("send_message") do @workspace.find_user("goblin") message_text = "I won't get sent to a channel" @@ -157,7 +161,29 @@ expect(response).must_be_nil end end - end + describe "save_settings" do + it "Saves settings in a json file" do + @workspace.bot_name = "T-Rex" + @workspace.bot_avatar = "t-rex" + expected_output = {"bot_name"=>"T-Rex", "bot_avatar"=>"t-rex"} + + @workspace.save_settings + file = File.read("bot-settings.json") + final_output = JSON.parse(file) + + expect(final_output).must_equal expected_output + + # Change settings back to default + @workspace.bot_name = "Slackbot" + @workspace.bot_avatar = "jack_o_lantern" + @workspace.save_settings + + expect(@workspace.bot_name).must_equal "Slackbot" + expect(@workspace.bot_avatar).must_equal "jack_o_lantern" + + + end + end end From 3bdeaf1c614545895667424b2691ebfc0af6205d Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Thu, 12 Sep 2019 15:40:02 -0700 Subject: [PATCH 17/24] added get channel message history --- lib/channel.rb | 12 +++++++++++ lib/slack.rb | 31 ++++++++++++++++++++++++++--- lib/user.rb | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/lib/channel.rb b/lib/channel.rb index 8374847f..2bf9e438 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -8,6 +8,18 @@ def initialize(slack_id:, name:, topic:, member_count:) @member_count = member_count end + def get_message_history + url = "https://slack.com/api/conversations.history" + # url = base_url + url + query = { token: ENV["SLACK_API_TOKEN"] , channel: slack_id, limit: 25} + response = HTTParty.get(url, query: query) + + return response + + + + end + def self.all channels = [] diff --git a/lib/slack.rb b/lib/slack.rb index 0fc70d98..a6de6d03 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -11,7 +11,7 @@ PUMPKIN_SPICE = SlackCLI::Workspace.new() -MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Send Message", "Change Bot Settings", "Quit"] +MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Send Message", "Get Message History", "Change Bot Settings", "Quit"] def print_workplace_stats() puts PUMPKIN_SPICE.get_workplace_stats() @@ -87,6 +87,26 @@ def get_message() end end +def format_message_history(response) + table = [] + + response["messages"].each do |message| + if message["username"] + table.push({name: message["username"], text: message["text"]}) + else + found_user = PUMPKIN_SPICE.find_user(message["user"]) + + modified_message = message["text"].gsub(/^<@\w+>/, "#{found_user.name}") + + table.push({name: found_user.name, text: modified_message}) + end + end + + table.reverse! + + tp table, {:name=>{:width => 45}}, {:text=>{:width => 80}} +end + def main puts "Welcome to the Ada Slack CLI!" puts @@ -119,7 +139,12 @@ def main when "send message", "6", "six" get_message - when "change bot settings", "7", "seven" + when "get message history", "7", "seven" + response = PUMPKIN_SPICE.selected.get_message_history + + format_message_history(response) + + when "change bot settings", "8", "eight" print "Please enter the bot's new name: " name = gets.chomp PUMPKIN_SPICE.bot_name = name @@ -130,7 +155,7 @@ def main PUMPKIN_SPICE.bot_avatar = avatar puts "The bot's new avatar is #{avatar}!" - when "quit", "8", "eight", "exit" + when "quit", "9", "nine", "exit" PUMPKIN_SPICE.save_settings again = false end diff --git a/lib/user.rb b/lib/user.rb index 6588f586..9eef299b 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -7,6 +7,60 @@ def initialize(slack_id:, name:, real_name:) @real_name = real_name end + def get_dm_channels + url = "https://slack.com/api/im.list" + query = { token: ENV["SLACK_API_TOKEN"]} + response = HTTParty.get(url, query: query) + + puts response + + + im_history_url = "https://slack.com/api/im.history" + query = { token: ENV["SLACK_API_TOKEN"], channel: "DN69AJ9K2"} + response2 = HTTParty.get(im_history_url, query: query) + + + puts "\n" + puts response2 + + + + im_history_url2 = "https://slack.com/api/im.history" + query = { token: ENV["SLACK_API_TOKEN"], channel: "DN85DC8MD"} + response3 = HTTParty.get(im_history_url2, query: query) + + + + + + + + # im_history_url = "https://slack.com/api/search.messages" + # query = { token: ENV["SLACK_API_TOKEN"], query: "slackbot"} + # response3 = HTTParty.get(url, query: query) + + + + + + puts "\n" + + puts response3 + + end + + + + + # def get_message_history + # url = "https://slack.com/api/im.history" + + # query = { token: ENV["SLACK_API_TOKEN"], channel: ""} + # response = HTTParty.get(url, query: query) + + # puts response + # end + def self.all users = [] From 1cdcddf7f24152a13aa5293ee858aa7d95a2c9e7 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Thu, 12 Sep 2019 16:04:40 -0700 Subject: [PATCH 18/24] added message history for user --- lib/slack.rb | 8 +++---- lib/user.rb | 59 ++++++++++++---------------------------------------- 2 files changed, 17 insertions(+), 50 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index a6de6d03..a2af212a 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -65,10 +65,10 @@ def select_channel def print_details() puts - if selected.class == SlackCLI::User - tp selected, "name", "real_name", "slack_id" - elsif selected.class == SlackCLI::Channel - tp selected, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" + if PUMPKIN_SPICE.selected.class == SlackCLI::User + tp PUMPKIN_SPICE.selected, "name", "real_name", "slack_id" + elsif PUMPKIN_SPICE.selected.class == SlackCLI::Channel + tp PUMPKIN_SPICE.selected, "name", {"topic" => {:width => 60}}, "member_count", "slack_id" else puts "There is no recipient selected." end diff --git a/lib/user.rb b/lib/user.rb index 9eef299b..547f2cfb 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -7,60 +7,27 @@ def initialize(slack_id:, name:, real_name:) @real_name = real_name end - def get_dm_channels - url = "https://slack.com/api/im.list" - query = { token: ENV["SLACK_API_TOKEN"]} - response = HTTParty.get(url, query: query) - - puts response - - - im_history_url = "https://slack.com/api/im.history" - query = { token: ENV["SLACK_API_TOKEN"], channel: "DN69AJ9K2"} - response2 = HTTParty.get(im_history_url, query: query) - - - puts "\n" - puts response2 - - - - im_history_url2 = "https://slack.com/api/im.history" - query = { token: ENV["SLACK_API_TOKEN"], channel: "DN85DC8MD"} - response3 = HTTParty.get(im_history_url2, query: query) - - - - - - - - # im_history_url = "https://slack.com/api/search.messages" - # query = { token: ENV["SLACK_API_TOKEN"], query: "slackbot"} - # response3 = HTTParty.get(url, query: query) - + def get_message_history + im_url = "https://slack.com/api/im.list" + im_query = { token: ENV["SLACK_API_TOKEN"]} + im_response = HTTParty.get(im_url, query: im_query) + ims = im_response["ims"] + direct_channel = ims.find do |im| + im["user"] == slack_id + end - puts "\n" + direct_channel_id = direct_channel["id"] - puts response3 + url = "https://slack.com/api/conversations.history" + query = { token: ENV["SLACK_API_TOKEN"] , channel: direct_channel_id} + response = HTTParty.get(url, query: query) + return response end - - - - # def get_message_history - # url = "https://slack.com/api/im.history" - - # query = { token: ENV["SLACK_API_TOKEN"], channel: ""} - # response = HTTParty.get(url, query: query) - - # puts response - # end - def self.all users = [] From 18d1f11fceaf6af50690331cfab5551900b39d5f Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Thu, 12 Sep 2019 16:20:57 -0700 Subject: [PATCH 19/24] added tests for get_message_history --- lib/channel.rb | 4 - test/cassettes/channels.yml | 117 +++++++++++++++++++-- test/cassettes/send_message.yml | 44 ++++---- test/cassettes/users.yml | 176 ++++++++++++++++++++++++++++++-- test/cassettes/workspace.yml | 36 +++---- test/channel_test.rb | 12 +++ test/user_test.rb | 12 +++ test/workspace_test.rb | 2 - 8 files changed, 339 insertions(+), 64 deletions(-) diff --git a/lib/channel.rb b/lib/channel.rb index 2bf9e438..20b9c01b 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -10,14 +10,10 @@ def initialize(slack_id:, name:, topic:, member_count:) def get_message_history url = "https://slack.com/api/conversations.history" - # url = base_url + url query = { token: ENV["SLACK_API_TOKEN"] , channel: slack_id, limit: 25} response = HTTParty.get(url, query: query) return response - - - end def self.all diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index aba2e052..226eeac5 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -25,15 +25,15 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 20:47:14 GMT + - Thu, 12 Sep 2019 23:20:28 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - ecbc14a8-dcdf-4f4f-8471-6f4fb302a24b + - 63ee54b9-9299-41e6-ac76-dce7ae1de0c8 X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: - Mon, 26 Jul 1997 05:00:00 GMT Cache-Control: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-cxk3 + - haproxy-www-vdbk X-Cache: - Miss from cloudfront Via: - - 1.1 82ea95080f526df99896343fb7269b07.cloudfront.net (CloudFront) + - 1.1 fb1574d5a6ba2d77d2a656aba08aa3c3.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - 4OGacAN0zcIqlhpSSdIc7H_WcNC6VU1Ha1vLu5h1-BPHnxn063gSxw== + - ZLNu1LGAmhkhU9w0kWL4Zg1Zx0-Mu_mAGukB1eIzU5Z07swBTxpS7Q== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -80,5 +80,106 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 20:47:14 GMT + recorded_at: Thu, 12 Sep 2019 23:20:28 GMT +- request: + method: get + uri: https://slack.com/api/conversations.history?channel=CMUR2JTNX&limit=25&token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '822' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:20:28 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 25a7d51d-db91-4faf-bc0f-106c8476e7f6 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:history,groups:history,mpim:history,im:history,read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-x0x4 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 bbc0c6d660c6b9bfbf22053687e12fba.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19 + X-Amz-Cf-Id: + - K3I3ETPdI3Dpfa4roRhrOQbrQ80jzXgqlTFPJoMYEizNhOzaTEoDpw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568330348.000500","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568321235.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568321181.000300","username":"T-Rex","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568321083.000200","username":"T-Rex","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568321009.000100","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568242399.002300","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568242326.002200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568241517.002100","user":"USLACKBOT","username":"slackbot","icons":{"emoji":"::jack_o_lantern::"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568241481.002000","username":"Leaves - Dianna + - API Project","icons":{"emoji":"::"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568241458.001900","username":"dinobot","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"will + this go through?","ts":"1568240526.001800","username":"Sabrina","icons":{"emoji":"nil"},"bot_id":"BN85KS74P"},{"type":"message","subtype":"bot_message","text":"will + this go through?","ts":"1568240515.001700","username":"Sabrina","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BN85KS74P"},{"type":"message","subtype":"bot_message","text":"will + this go through?","ts":"1568240503.001600","username":"Sabrina","icons":{"emoji":":leprechaun:"},"bot_id":"BN85KS74P"},{"type":"message","subtype":"bot_message","text":":poultry_leg: + :t-rex:","ts":"1568240426.001500","username":"Sabrina","icons":{"emoji":":leprechaun:"},"bot_id":"BN85KS74P"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568239748.001400","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568239337.001300","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568239206.001200","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"client_msg_id":"c05f1f48-7e5a-454c-a579-c172e69c0358","type":"message","text":"spacer + test","user":"UMUR43REX","ts":"1568239188.001100","team":"TN69AJ2SU"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568239173.000600","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568239026.000500","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":pumpkin:"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568237849.000400","username":"Leaves - Dianna + - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568237560.000300","username":"Leaves - Dianna + - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I + can be sent to Pumpkin Spice!","ts":"1568237163.000200","username":"Leaves + - Dianna - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I + can be sent to Pumpkin Spice!","ts":"1568237089.000100","username":"Leaves + - Dianna - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"Change","ts":"1568225927.004400","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"}],"has_more":true,"pin_count":0,"response_metadata":{"next_cursor":"bmV4dF90czoxNTY4MjI1NzAzMDA0MTAw"}}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:20:28 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/send_message.yml b/test/cassettes/send_message.yml index 36f683c6..af42ccd6 100644 --- a/test/cassettes/send_message.yml +++ b/test/cassettes/send_message.yml @@ -5,7 +5,7 @@ http_interactions: uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A + string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -21,15 +21,15 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 20:47:15 GMT + - Thu, 12 Sep 2019 23:20:28 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 6baf0ba4-a03a-4c8d-8b37-4cdf252e15ef + - 3aeb2765-d413-4409-8266-543c0d0a2cde X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: - Mon, 26 Jul 1997 05:00:00 GMT Cache-Control: @@ -53,27 +53,27 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-wuu0 + - haproxy-www-f2n6 X-Cache: - Miss from cloudfront Via: - - 1.1 570075675953459325e00b7bcd171df3.cloudfront.net (CloudFront) + - 1.1 a2a7227d0a99f50bffb8ba79de64ab0f.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - tIwjKKXGCTCKtF17xL27S021XYTXCOohAh8ghdhb7tiQJLSib_2ohA== + - OnU-pJOfJFQg1S0fmgffYn3mr5KtKhgIv1k5V1YBjyu-TJBWVhK70Q== body: encoding: UTF-8 - string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568321235.000400","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a user","ts":"1568321235.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568330428.000600","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568330428.000600","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Thu, 12 Sep 2019 20:47:15 GMT + recorded_at: Thu, 12 Sep 2019 23:20:28 GMT - request: method: post uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A + string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -89,15 +89,15 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 20:47:15 GMT + - Thu, 12 Sep 2019 23:20:29 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 15727ccf-10e8-41e5-befa-bd8291831354 + - fa121ba6-7474-437a-b24b-84f230ac8b22 X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: - Mon, 26 Jul 1997 05:00:00 GMT Cache-Control: @@ -121,19 +121,19 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-dqjh + - haproxy-www-u916 X-Cache: - Miss from cloudfront Via: - - 1.1 0732be5515ffeda639cfe5f22fb04df6.cloudfront.net (CloudFront) + - 1.1 4ffd1199c1038a2d2062d6a465270ae2.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - 7zqzelmeIFlbSVu0GbdYEkKInSyH2KArUTuOhnv9znrioAQ8DJeqHA== + - t7dH-1ONCQXtSygVu_0RK9toceL47CIHn4VDAiXJ-NJMvQc8pB68Xg== body: encoding: UTF-8 - string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568321235.000400","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568321235.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568330429.000200","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a user","ts":"1568330429.000200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Thu, 12 Sep 2019 20:47:15 GMT + recorded_at: Thu, 12 Sep 2019 23:20:29 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index ef7df6ed..c5cf4dc4 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -21,19 +21,19 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1609' + - '1608' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 20:47:14 GMT + - Thu, 12 Sep 2019 23:20:29 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 5d7d5c73-d80a-405e-a924-426cc36e9a72 + - 6aa592d4-d905-4c1f-a0b3-a51fc10bfb91 X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: - Mon, 26 Jul 1997 05:00:00 GMT Cache-Control: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-admz + - haproxy-www-lwyj X-Cache: - Miss from cloudfront Via: - - 1.1 3cd7af07832481c336aa1c93c9b4a6fe.cloudfront.net (CloudFront) + - 1.1 3403c96e1b1db500ff6526f1a7bc6813.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - 4fsv878bVjbRAh_clH3yL53kjUvTnDq58pOzrGN7qVwpSz2PF9_mYQ== + - h63J321CZGt5NgGk6qMwFaOPnCZsRgoty7isDVeADe2TrB1P2EX5uQ== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,7 +89,163 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568321235,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568330429,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 20:47:15 GMT + recorded_at: Thu, 12 Sep 2019 23:20:29 GMT +- request: + method: get + uri: https://slack.com/api/im.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '310' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:20:29 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 7e2db4bd-04e3-49c4-912a-6963663a8d21 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - im:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-vdbk + X-Cache: + - Miss from cloudfront + Via: + - 1.1 400e19a7f70282e0817451f6606ca8f9.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19 + X-Amz-Cf-Id: + - yOHMZ7O5phYZ37tdvfVHwCi3ESYPc9uaFtdojK077mrLt9MI3OyfrQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"ims":[{"id":"DN85DC8MD","created":1568071309,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMZSUVBED","is_user_deleted":false,"priority":0},{"id":"DN85DBRC7","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3N6P6","is_user_deleted":false,"priority":0},{"id":"DN69K4V61","created":1568071310,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3NYUU","is_user_deleted":false,"priority":0},{"id":"DN69C3L3S","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMUR43REX","is_user_deleted":false,"priority":0},{"id":"DN69AJ9K2","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R273J8","is_user_deleted":false,"priority":0},{"id":"DN5R3NKDJ","created":1568071308,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMTG0S5D0","is_user_deleted":false,"priority":0},{"id":"DMUR2JRB5","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"USLACKBOT","is_user_deleted":false,"priority":0},{"id":"DMTG0RLMQ","created":1568071306,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN69C37BJ","is_user_deleted":false,"priority":0}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:20:29 GMT +- request: + method: get + uri: https://slack.com/api/conversations.history?channel=DMUR2JRB5&token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '543' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:20:29 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 3af58efe-99d5-48df-a317-bbbe61696d5f + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:history,groups:history,mpim:history,im:history,read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-dqjh + X-Cache: + - Miss from cloudfront + Via: + - 1.1 a2a7227d0a99f50bffb8ba79de64ab0f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19 + X-Amz-Cf-Id: + - 0R4Z0_I0QrSdM3dI-OCFY7yFSzd2F4kfPYYyTRatX2C4kK_xjwsOXw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"default + settings!","ts":"1568242282.001400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"who + am I???","ts":"1568242155.001300","username":"pumpkin","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"who + am i?","ts":"1568242101.001200","username":"dino","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"this + better be a jack o lantern","ts":"1568241614.001100","user":"USLACKBOT","username":"slackbot","icons":{"emoji":"::jack_o_lantern::"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"is + this a trex?","ts":"1568240139.001000","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"test + default sender","ts":"1568240116.000900","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"message + to dianna","ts":"1568238074.000800","username":"Leaves - Dianna - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233791.000700","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233781.000600","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233754.000500","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233721.000400","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233719.000300","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test","ts":"1568233699.000200","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test","ts":"1568233638.000100","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"}],"has_more":false,"pin_count":0}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:20:29 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index 544cea5e..feb8b993 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -21,19 +21,19 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1609' + - '1608' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 20:47:15 GMT + - Thu, 12 Sep 2019 23:20:28 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 806a3fc9-fd12-4814-8078-6d31e55c06f4 + - 70c96323-d4d1-489c-a361-b5d6751825d2 X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: - Mon, 26 Jul 1997 05:00:00 GMT Cache-Control: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-1ir4 + - haproxy-www-61a2 X-Cache: - Miss from cloudfront Via: - - 1.1 82ea95080f526df99896343fb7269b07.cloudfront.net (CloudFront) + - 1.1 5afc8eca980390e71a86518c6f90001a.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - _FH81k1joeVrS8lDbo5xz20jd_9Btkkft5Zmj0yXdU3OM_x83XqWVQ== + - kbnZFl5uvlBIJcabx5hGceQSq96-ae83Kd-kp7lpFPsjL7-j0Q1amA== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568321235,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568330428,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 20:47:15 GMT + recorded_at: Thu, 12 Sep 2019 23:20:28 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -117,15 +117,15 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 20:47:15 GMT + - Thu, 12 Sep 2019 23:20:28 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - b5771b1e-9428-41fd-8bc5-c9e085532475 + - 55b960a8-54c3-4046-9cc7-ef32f769add8 X-Oauth-Scopes: - - identify,channels:read,users:read,chat:write:bot + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: - Mon, 26 Jul 1997 05:00:00 GMT Cache-Control: @@ -149,15 +149,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-g8yt + - haproxy-www-7ui7 X-Cache: - Miss from cloudfront Via: - - 1.1 eab8a154a09e69260fbfe4df90182b2f.cloudfront.net (CloudFront) + - 1.1 9bb9e176e1eb7840931dbe73ecc961f7.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19 X-Amz-Cf-Id: - - NcILQnUBidoR-7ut711lXnQ1cGhr-xOZHqFVbKzpIs4DPAoqOIXaHQ== + - wt6-mWAEy7e_p6x6Uv9baSHYxVcBs5DxZC-N-ybb1k3mnge90TV3vg== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -172,5 +172,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 20:47:15 GMT + recorded_at: Thu, 12 Sep 2019 23:20:28 GMT recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index 03ae88ef..8f48e929 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -13,6 +13,18 @@ end end + describe "get_message_history" do + it "Gets message history for a channel" do + VCR.use_cassette("channels") do + all_channels = SlackCLI::Channel.all + result = all_channels.first.get_message_history + + expect(result.code).must_equal 200 + expect(result["ok"]).must_equal true + end + end + end + describe "Self.all method" do it "Returns a list of all channels" do VCR.use_cassette("channels") do diff --git a/test/user_test.rb b/test/user_test.rb index d6ccc50d..2d4d483a 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -12,6 +12,18 @@ end end + describe "get_message_history" do + it "Gets message history for a user" do + VCR.use_cassette("users") do + all_users = SlackCLI::User.all + result = all_users.first.get_message_history + + expect(result.code).must_equal 200 + expect(result["ok"]).must_equal true + end + end + end + describe "Self.all method" do it "Returns a list of all users" do VCR.use_cassette("users") do diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 7dd040db..d757a46e 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -182,8 +182,6 @@ expect(@workspace.bot_name).must_equal "Slackbot" expect(@workspace.bot_avatar).must_equal "jack_o_lantern" - - end end end From d05932412af77dd46f38a4fe53c30fffe5984019 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Thu, 12 Sep 2019 19:17:15 -0700 Subject: [PATCH 20/24] Added SlackAPIError and error handling --- lib/channel.rb | 4 +++ lib/errors.rb | 4 +++ lib/recipient.rb | 5 ++++ lib/slack.rb | 2 +- lib/user.rb | 5 +++- lib/workspace.rb | 13 +++++----- test/cassettes/channels.yml | 40 ++++++++++++++-------------- test/cassettes/send_message.yml | 40 ++++++++++++++-------------- test/cassettes/users.yml | 46 ++++++++++++++++----------------- test/cassettes/workspace.yml | 32 +++++++++++------------ test/channel_test.rb | 2 +- test/recipient_test.rb | 6 ++--- test/test_helper.rb | 1 + test/user_test.rb | 2 +- test/workspace_test.rb | 6 ++--- 15 files changed, 112 insertions(+), 96 deletions(-) create mode 100644 lib/errors.rb diff --git a/lib/channel.rb b/lib/channel.rb index 20b9c01b..4835f985 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -13,6 +13,10 @@ def get_message_history query = { token: ENV["SLACK_API_TOKEN"] , channel: slack_id, limit: 25} response = HTTParty.get(url, query: query) + unless response.code == 200 && response.parsed_response["ok"] + raise SlackAPIError, "Error when getting message history, error: #{response.parsed_response["error"]}" + end + return response end diff --git a/lib/errors.rb b/lib/errors.rb new file mode 100644 index 00000000..34742c7c --- /dev/null +++ b/lib/errors.rb @@ -0,0 +1,4 @@ +module SlackCLI + class SlackAPIError < StandardError + end +end diff --git a/lib/recipient.rb b/lib/recipient.rb index c36b7788..ab0a19ef 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -17,6 +17,11 @@ def self.get(url) url = base_url + url query = { token: ENV["SLACK_API_TOKEN"] } response = HTTParty.get(url, query: query) + + unless response.code == 200 && response.parsed_response["ok"] + raise SlackAPIError, "Error: #{response.parsed_response["error"]}" + end + return response end diff --git a/lib/slack.rb b/lib/slack.rb index a2af212a..3c0900e8 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -6,6 +6,7 @@ require_relative "user" require_relative "workspace" require_relative "channel" +require_relative "errors" Dotenv.load @@ -141,7 +142,6 @@ def main when "get message history", "7", "seven" response = PUMPKIN_SPICE.selected.get_message_history - format_message_history(response) when "change bot settings", "8", "eight" diff --git a/lib/user.rb b/lib/user.rb index 547f2cfb..53626268 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -8,7 +8,6 @@ def initialize(slack_id:, name:, real_name:) end def get_message_history - im_url = "https://slack.com/api/im.list" im_query = { token: ENV["SLACK_API_TOKEN"]} im_response = HTTParty.get(im_url, query: im_query) @@ -25,6 +24,10 @@ def get_message_history query = { token: ENV["SLACK_API_TOKEN"] , channel: direct_channel_id} response = HTTParty.get(url, query: query) + unless response.code == 200 && response.parsed_response["ok"] + raise SlackAPIError, "Error when getting message history, error: #{response.parsed_response["error"]}" + end + return response end diff --git a/lib/workspace.rb b/lib/workspace.rb index d844e3fa..c9f56f08 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -21,22 +21,18 @@ def get_workplace_stats() end def find_user(search_term) - found_user = users.find do |user| + @selected = users.find do |user| user.name == search_term.downcase || user.slack_id == search_term.upcase end - found_user ? @selected = found_user : @selected = nil - return selected end def find_channel(search_term) - found_channel = channels.find do |channel| + @selected = channels.find do |channel| channel.name == search_term.downcase || channel.slack_id == search_term.upcase end - found_channel ? @selected = found_channel : @selected = nil - return selected end @@ -57,6 +53,11 @@ def send_message(message_text) icon_emoji: bot_avatar_symbol }, headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } ) + + unless response.code == 200 && response.parsed_response["ok"] + raise SlackAPIError, "Error when posting message, error: #{response.parsed_response["error"]}" + end + return response end diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index 226eeac5..6231f64d 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:28 GMT + - Thu, 12 Sep 2019 23:48:34 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 63ee54b9-9299-41e6-ac76-dce7ae1de0c8 + - b1952085-4443-4282-90d9-8107eac863c4 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-vdbk + - haproxy-www-fc14 X-Cache: - Miss from cloudfront Via: - - 1.1 fb1574d5a6ba2d77d2a656aba08aa3c3.cloudfront.net (CloudFront) + - 1.1 112d82578d402a38d8d02e8b857617e1.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - ZLNu1LGAmhkhU9w0kWL4Zg1Zx0-Mu_mAGukB1eIzU5Z07swBTxpS7Q== + - eGkdASLf9QDsb1sBDEhNuuspzA6l7wEezGY8Ottsni3lxCJyDsWz9g== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -80,7 +80,7 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:28 GMT + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT - request: method: get uri: https://slack.com/api/conversations.history?channel=CMUR2JTNX&limit=25&token= @@ -102,17 +102,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '822' + - '781' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:28 GMT + - Thu, 12 Sep 2019 23:48:34 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 25a7d51d-db91-4faf-bc0f-106c8476e7f6 + - 5552f2de-d9b1-4be4-aaca-3c69ca8eda0d X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -138,18 +138,21 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-x0x4 + - haproxy-www-fdpw X-Cache: - Miss from cloudfront Via: - - 1.1 bbc0c6d660c6b9bfbf22053687e12fba.cloudfront.net (CloudFront) + - 1.1 3cd7af07832481c336aa1c93c9b4a6fe.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - K3I3ETPdI3Dpfa4roRhrOQbrQ80jzXgqlTFPJoMYEizNhOzaTEoDpw== + - KC6uM5IxAglqqqpk51I4TxIlF6ax8TQSWz_q-MOaYVIjtcUP0EyyAA== body: encoding: ASCII-8BIT string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568331869.000800","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568330837.000700","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568330428.000600","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568330348.000500","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568321235.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568321181.000300","username":"T-Rex","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m @@ -174,12 +177,7 @@ http_interactions: a message to a channel","ts":"1568237849.000400","username":"Leaves - Dianna - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568237560.000300","username":"Leaves - Dianna - - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I - can be sent to Pumpkin Spice!","ts":"1568237163.000200","username":"Leaves - - Dianna - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I - can be sent to Pumpkin Spice!","ts":"1568237089.000100","username":"Leaves - - Dianna - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"Change","ts":"1568225927.004400","username":"Leaves - - Tiffany - API Project","bot_id":"BMURAQX7D"}],"has_more":true,"pin_count":0,"response_metadata":{"next_cursor":"bmV4dF90czoxNTY4MjI1NzAzMDA0MTAw"}}' + - API Project","bot_id":"BMW7Z23K5"}],"has_more":true,"pin_count":0,"response_metadata":{"next_cursor":"bmV4dF90czoxNTY4MjM3MTYzMDAwMjAw"}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:28 GMT + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/send_message.yml b/test/cassettes/send_message.yml index af42ccd6..eecf38c7 100644 --- a/test/cassettes/send_message.yml +++ b/test/cassettes/send_message.yml @@ -5,7 +5,7 @@ http_interactions: uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A + string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -21,13 +21,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:28 GMT + - Thu, 12 Sep 2019 23:48:35 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 3aeb2765-d413-4409-8266-543c0d0a2cde + - 52c79a75-1126-4b94-a6ff-d419366bbfd4 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -53,27 +53,27 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-f2n6 + - haproxy-www-ntnv X-Cache: - Miss from cloudfront Via: - - 1.1 a2a7227d0a99f50bffb8ba79de64ab0f.cloudfront.net (CloudFront) + - 1.1 0732be5515ffeda639cfe5f22fb04df6.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - OnU-pJOfJFQg1S0fmgffYn3mr5KtKhgIv1k5V1YBjyu-TJBWVhK70Q== + - Q-ATPzeXLtOAXQdFiG3AajOoYqczwZz-PMpxFXm2BrGbhAOFpibpBA== body: encoding: UTF-8 - string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568330428.000600","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568330428.000600","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568332115.000200","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a user","ts":"1568332115.000200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:28 GMT + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT - request: method: post uri: https://slack.com/api/chat.postMessage body: encoding: UTF-8 - string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A + string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A headers: Content-Type: - application/x-www-form-urlencoded @@ -89,13 +89,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:29 GMT + - Thu, 12 Sep 2019 23:48:35 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - fa121ba6-7474-437a-b24b-84f230ac8b22 + - a920e6c2-c482-41d6-bd2a-8b1516207b6e X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -121,19 +121,19 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-u916 + - haproxy-www-dzl1 X-Cache: - Miss from cloudfront Via: - - 1.1 4ffd1199c1038a2d2062d6a465270ae2.cloudfront.net (CloudFront) + - 1.1 61bc723adb3b1884ed759711e84e13a9.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - t7dH-1ONCQXtSygVu_0RK9toceL47CIHn4VDAiXJ-NJMvQc8pB68Xg== + - tuGIxxFEq5M7wqi47ahVYbt8R00PnsHbOcVYNYr5ve27YRxC5Vw4SA== body: encoding: UTF-8 - string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568330429.000200","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a user","ts":"1568330429.000200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568332115.000900","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568332115.000900","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:29 GMT + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index c5cf4dc4..e056dbc2 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -21,17 +21,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1608' + - '1610' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:29 GMT + - Thu, 12 Sep 2019 23:48:34 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 6aa592d4-d905-4c1f-a0b3-a51fc10bfb91 + - f9cea927-fb40-44bc-9209-80179136079d X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-lwyj + - haproxy-www-64vz X-Cache: - Miss from cloudfront Via: - - 1.1 3403c96e1b1db500ff6526f1a7bc6813.cloudfront.net (CloudFront) + - 1.1 d6a002c70d55f415107618b0750d493d.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - h63J321CZGt5NgGk6qMwFaOPnCZsRgoty7isDVeADe2TrB1P2EX5uQ== + - IWbIbqKx6a1Voppa3ftwImSc8RgTaJ1B5mjUhdTKfuU6wecp3fMsbg== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568330429,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568332114,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:29 GMT + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT - request: method: get uri: https://slack.com/api/im.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:29 GMT + - Thu, 12 Sep 2019 23:48:35 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 7e2db4bd-04e3-49c4-912a-6963663a8d21 + - 7866861f-770c-4fba-8f1f-c026c591a1d0 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -149,20 +149,20 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-vdbk + - haproxy-www-5nvv X-Cache: - Miss from cloudfront Via: - - 1.1 400e19a7f70282e0817451f6606ca8f9.cloudfront.net (CloudFront) + - 1.1 4c7c693b007dfce603c83f138e31bccb.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - yOHMZ7O5phYZ37tdvfVHwCi3ESYPc9uaFtdojK077mrLt9MI3OyfrQ== + - wvgd7IIEzp8DQgQqAxYKKPCuXpnLlHr7ztz1IUwu0N3fEMeVQg_w7g== body: encoding: ASCII-8BIT string: '{"ok":true,"ims":[{"id":"DN85DC8MD","created":1568071309,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMZSUVBED","is_user_deleted":false,"priority":0},{"id":"DN85DBRC7","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3N6P6","is_user_deleted":false,"priority":0},{"id":"DN69K4V61","created":1568071310,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3NYUU","is_user_deleted":false,"priority":0},{"id":"DN69C3L3S","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMUR43REX","is_user_deleted":false,"priority":0},{"id":"DN69AJ9K2","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R273J8","is_user_deleted":false,"priority":0},{"id":"DN5R3NKDJ","created":1568071308,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMTG0S5D0","is_user_deleted":false,"priority":0},{"id":"DMUR2JRB5","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"USLACKBOT","is_user_deleted":false,"priority":0},{"id":"DMTG0RLMQ","created":1568071306,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN69C37BJ","is_user_deleted":false,"priority":0}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:29 GMT + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT - request: method: get uri: https://slack.com/api/conversations.history?channel=DMUR2JRB5&token= @@ -188,13 +188,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:29 GMT + - Thu, 12 Sep 2019 23:48:35 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 3af58efe-99d5-48df-a317-bbbe61696d5f + - e9ff0ac4-3000-4349-ad4c-9d60f4ffb0a6 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -220,15 +220,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-dqjh + - haproxy-www-f5e7 X-Cache: - Miss from cloudfront Via: - - 1.1 a2a7227d0a99f50bffb8ba79de64ab0f.cloudfront.net (CloudFront) + - 1.1 57a21088b36c69a83578b5a5579df58f.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - 0R4Z0_I0QrSdM3dI-OCFY7yFSzd2F4kfPYYyTRatX2C4kK_xjwsOXw== + - aj9dNHnRaf9QtZWXNuy7_-EHyyER161rmSPtJqwc-SxQNp1ZvHMbbQ== body: encoding: ASCII-8BIT string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"default @@ -247,5 +247,5 @@ http_interactions: - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test","ts":"1568233638.000100","username":"Leaves - Tiffany - API Project","bot_id":"BMURAQX7D"}],"has_more":false,"pin_count":0}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:29 GMT + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index feb8b993..3f13b98f 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -21,17 +21,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1608' + - '1610' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:28 GMT + - Thu, 12 Sep 2019 23:48:34 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 70c96323-d4d1-489c-a361-b5d6751825d2 + - f07f3b44-41fd-4ae4-92d8-7d17430868a5 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-61a2 + - haproxy-www-78ya X-Cache: - Miss from cloudfront Via: - - 1.1 5afc8eca980390e71a86518c6f90001a.cloudfront.net (CloudFront) + - 1.1 570075675953459325e00b7bcd171df3.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - kbnZFl5uvlBIJcabx5hGceQSq96-ae83Kd-kp7lpFPsjL7-j0Q1amA== + - 1psEQKErkTlhNZmIVcPBzcaRyyCU_gQeR3DZA4Uo0cUU9IA0X0JmVA== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568330428,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568332114,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:28 GMT + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:20:28 GMT + - Thu, 12 Sep 2019 23:48:34 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 55b960a8-54c3-4046-9cc7-ef32f769add8 + - c09f721e-9e1d-4b84-a5a1-e81cba343f18 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -149,15 +149,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-7ui7 + - haproxy-www-lwkq X-Cache: - Miss from cloudfront Via: - - 1.1 9bb9e176e1eb7840931dbe73ecc961f7.cloudfront.net (CloudFront) + - 1.1 61bc723adb3b1884ed759711e84e13a9.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19 + - SEA19-C2 X-Amz-Cf-Id: - - wt6-mWAEy7e_p6x6Uv9baSHYxVcBs5DxZC-N-ybb1k3mnge90TV3vg== + - b50_cScswHlmZo4tm4sTf-ybJH9aQkt04Dw0wuTUDKZnq77-eZRiEw== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -172,5 +172,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:20:28 GMT + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index 8f48e929..aa59e92b 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" describe "Channel class" do - describe "Initialize method" do + describe "initialize method" do it "Initializes a new channel" do channel = SlackCLI::Channel.new(slack_id: 123, name: "test channel", topic: "tests", member_count: 10) diff --git a/test/recipient_test.rb b/test/recipient_test.rb index 8b3d5e3a..2e7fb9ba 100644 --- a/test/recipient_test.rb +++ b/test/recipient_test.rb @@ -3,7 +3,7 @@ describe "Recipient class" do let(:recipient) { SlackCLI::Recipient.new(123, "test") } - describe "Initialize method" do + describe "initialize method" do it "Creates an instance of recipient" do expect(recipient).must_be_instance_of SlackCLI::Recipient expect(recipient.slack_id).must_equal 123 @@ -11,13 +11,13 @@ end end - describe "details" do + describe "details method" do it "Raises an exception for the details method" do expect{recipient.details}.must_raise NotImplementedError end end - describe "self.all" do + describe "self.all method" do it "Raises an exception for the self.all method" do expect{SlackCLI::Recipient.all}.must_raise NotImplementedError end diff --git a/test/test_helper.rb b/test/test_helper.rb index 67449f15..b2edc0ef 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,6 +15,7 @@ require_relative "../lib/user" require_relative "../lib/workspace" require_relative "../lib/channel" +require_relative "../lib/errors" Dotenv.load diff --git a/test/user_test.rb b/test/user_test.rb index 2d4d483a..8b0d2011 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" describe "User class" do - describe "Initialize method" do + describe "initialize method" do it "Initializes a new user" do user = SlackCLI::User.new(slack_id: 123, name: "test", real_name: "Test Name") diff --git a/test/workspace_test.rb b/test/workspace_test.rb index d757a46e..4c147aa2 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -7,7 +7,7 @@ end end - describe "Initialize Workspace" do + describe "initialize method" do it "Creates a new workspace" do expect(@workspace).must_be_instance_of SlackCLI::Workspace end @@ -115,7 +115,7 @@ end end - describe "send_message" do + describe "send_message method" do it "sends a message to a user" do VCR.use_cassette("send_message") do @workspace.find_user("sabrina") @@ -163,7 +163,7 @@ end end - describe "save_settings" do + describe "save_settings method" do it "Saves settings in a json file" do @workspace.bot_name = "T-Rex" @workspace.bot_avatar = "t-rex" From 4443b179c6eea3a5722560bef779f45558e194e9 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Fri, 13 Sep 2019 13:41:57 -0700 Subject: [PATCH 21/24] final version --- lib/recipient.rb | 4 - lib/user.rb | 6 +- test/cassettes/bad_channels.yml | 155 +++++++++++++ test/cassettes/bad_conversations_list.yml | 237 ++++++++++++++++++++ test/cassettes/bad_ims_list.yml | 251 ++++++++++++++++++++++ test/cassettes/bad_recipient.yml | 64 ++++++ test/cassettes/bad_send_message.yml | 137 ++++++++++++ test/channel_test.rb | 8 + test/recipient_test.rb | 8 +- test/user_test.rb | 16 ++ test/workspace_test.rb | 9 + 11 files changed, 887 insertions(+), 8 deletions(-) create mode 100644 test/cassettes/bad_channels.yml create mode 100644 test/cassettes/bad_conversations_list.yml create mode 100644 test/cassettes/bad_ims_list.yml create mode 100644 test/cassettes/bad_recipient.yml create mode 100644 test/cassettes/bad_send_message.yml diff --git a/lib/recipient.rb b/lib/recipient.rb index ab0a19ef..7dd36edd 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -8,10 +8,6 @@ def initialize(slack_id, name) @name = name end - def details - raise NotImplementedError - end - def self.get(url) base_url = "https://slack.com/api/" url = base_url + url diff --git a/lib/user.rb b/lib/user.rb index 53626268..75d5b1e0 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -12,6 +12,10 @@ def get_message_history im_query = { token: ENV["SLACK_API_TOKEN"]} im_response = HTTParty.get(im_url, query: im_query) + unless im_response.code == 200 && im_response.parsed_response["ok"] + raise SlackAPIError, "Error when getting im list, error: #{im_response.parsed_response["error"]}" + end + ims = im_response["ims"] direct_channel = ims.find do |im| @@ -25,7 +29,7 @@ def get_message_history response = HTTParty.get(url, query: query) unless response.code == 200 && response.parsed_response["ok"] - raise SlackAPIError, "Error when getting message history, error: #{response.parsed_response["error"]}" + raise SlackAPIError, "Error when getting conversations history, error: #{response.parsed_response["error"]}" end return response diff --git a/test/cassettes/bad_channels.yml b/test/cassettes/bad_channels.yml new file mode 100644 index 00000000..974215ac --- /dev/null +++ b/test/cassettes/bad_channels.yml @@ -0,0 +1,155 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '713' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:48:34 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - b1952085-4443-4282-90d9-8107eac863c4 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-fc14 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 112d82578d402a38d8d02e8b857617e1.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - eGkdASLf9QDsb1sBDEhNuuspzA6l7wEezGY8Ottsni3lxCJyDsWz9g== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"A + place for non-work-related flimflam, faffing, hodge-podge or jibber-jabber + you''d prefer to keep out of more focused work-related channels.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7},{"id":"CN6A88SJZ","name":"turkey","is_channel":true,"created":1568073346,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMUR43REX","name_normalized":"turkey","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMUR43REX","UN5R273J8","UN69C37BJ"],"topic":{"value":"To + collect images of turkeys and information about turkeys","creator":"UN5R273J8","last_set":1568232705},"purpose":{"value":"to + collect images of turkeys and information about turkeys","creator":"UMUR43REX","last_set":1568073347},"previous_names":[],"num_members":3},{"id":"CN85BSBQF","name":"slack-cli","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Posts + about the Slack CLI project","creator":"UN5R273J8","last_set":1568232665},"purpose":{"value":"Posts + about the Slack CLI project","creator":"UN5R273J8","last_set":1568232660},"previous_names":[],"num_members":7},{"id":"CN8FME7AS","name":"general","is_channel":true,"created":1568071183,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN5R273J8","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN5R273J8","last_set":1568071183},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT +- request: + method: get + uri: https://slack.com/api/conversations.history?channel=CMUR2JTNX&limit=25&token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 503 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '781' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:48:34 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 5552f2de-d9b1-4be4-aaca-3c69ca8eda0d + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:history,groups:history,mpim:history,im:history,read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-fdpw + X-Cache: + - Miss from cloudfront + Via: + - 1.1 3cd7af07832481c336aa1c93c9b4a6fe.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - KC6uM5IxAglqqqpk51I4TxIlF6ax8TQSWz_q-MOaYVIjtcUP0EyyAA== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"service_unavailable"}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/bad_conversations_list.yml b/test/cassettes/bad_conversations_list.yml new file mode 100644 index 00000000..e0ba3350 --- /dev/null +++ b/test/cassettes/bad_conversations_list.yml @@ -0,0 +1,237 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1610' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:48:34 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - f9cea927-fb40-44bc-9209-80179136079d + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-64vz + X-Cache: + - Miss from cloudfront + Via: + - 1.1 d6a002c70d55f415107618b0750d493d.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - IWbIbqKx6a1Voppa3ftwImSc8RgTaJ1B5mjUhdTKfuU6wecp3fMsbg== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha + Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha + Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha + Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina + Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina + Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina + Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya + Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya + Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya + Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna + Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna + Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia + K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia + K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia + K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan + Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan + Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan + Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany + Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany + Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568332114,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:48:34 GMT +- request: + method: get + uri: https://slack.com/api/im.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '310' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:48:35 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 7866861f-770c-4fba-8f1f-c026c591a1d0 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - im:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-5nvv + X-Cache: + - Miss from cloudfront + Via: + - 1.1 4c7c693b007dfce603c83f138e31bccb.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - wvgd7IIEzp8DQgQqAxYKKPCuXpnLlHr7ztz1IUwu0N3fEMeVQg_w7g== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"ims":[{"id":"DN85DC8MD","created":1568071309,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMZSUVBED","is_user_deleted":false,"priority":0},{"id":"DN85DBRC7","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3N6P6","is_user_deleted":false,"priority":0},{"id":"DN69K4V61","created":1568071310,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3NYUU","is_user_deleted":false,"priority":0},{"id":"DN69C3L3S","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMUR43REX","is_user_deleted":false,"priority":0},{"id":"DN69AJ9K2","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R273J8","is_user_deleted":false,"priority":0},{"id":"DN5R3NKDJ","created":1568071308,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMTG0S5D0","is_user_deleted":false,"priority":0},{"id":"DMUR2JRB5","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"USLACKBOT","is_user_deleted":false,"priority":0},{"id":"DMTG0RLMQ","created":1568071306,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN69C37BJ","is_user_deleted":false,"priority":0}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT +- request: + method: get + uri: https://slack.com/api/conversations.history?channel=DMUR2JRB5&token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 503 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '543' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:48:35 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - e9ff0ac4-3000-4349-ad4c-9d60f4ffb0a6 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:history,groups:history,mpim:history,im:history,read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-f5e7 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 57a21088b36c69a83578b5a5579df58f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - aj9dNHnRaf9QtZWXNuy7_-EHyyER161rmSPtJqwc-SxQNp1ZvHMbbQ== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"service_unavailable"}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/bad_ims_list.yml b/test/cassettes/bad_ims_list.yml new file mode 100644 index 00000000..7171fdf1 --- /dev/null +++ b/test/cassettes/bad_ims_list.yml @@ -0,0 +1,251 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1609' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 18:26:54 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - f938e3ce-af40-4b4c-b83b-4dc039cd94f5 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-gt7p + X-Cache: + - Miss from cloudfront + Via: + - 1.1 bb14b7a4f45e3e0b1ae5065c59f7826f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - tYdlN8uXjP0humJl88rW-hug3fMSoX7eyDJbAjk_oQ16s-TItO1D7w== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Slackbot","real_name_normalized":"Slackbot","display_name":"Slackbot","display_name_normalized":"Slackbot","fields":null,"status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"sv41d8cd98f0","always_active":true,"first_name":"slackbot","last_name":"","image_24":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_24.png","image_32":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_32.png","image_48":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_48.png","image_72":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_72.png","image_192":"https:\/\/a.slack-edge.com\/80588\/marketing\/img\/avatars\/slackbot\/avatar-slackbot.png","image_512":"https:\/\/a.slack-edge.com\/80588\/img\/slackbot_512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":0},{"id":"UMTG0S5D0","team_id":"TN69AJ2SU","name":"samantha.collares","deleted":false,"color":"674b1b","real_name":"Samantha + Collares","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Samantha + Collares","real_name_normalized":"Samantha Collares","display_name":"Samantha + Collares","display_name_normalized":"Samantha Collares","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge444d412eed","image_24":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e444d412eed1a77c04bbf0fb2c43d8b8.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071698,"has_2fa":false},{"id":"UMUR43REX","team_id":"TN69AJ2SU","name":"sabrina","deleted":false,"color":"e7392d","real_name":"Sabrina + Lowney","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Sabrina + Lowney","real_name_normalized":"Sabrina Lowney","display_name":"Sabrina Lowney","display_name_normalized":"Sabrina + Lowney","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3826fd588f7","image_24":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3826fd588f7f72df044c1512a719f733.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0013-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071592,"has_2fa":false},{"id":"UMZSUVBED","team_id":"TN69AJ2SU","name":"mariya.burrows","deleted":false,"color":"e96699","real_name":"Mariya + Burrows","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mariya + Burrows","real_name_normalized":"Mariya Burrows","display_name":"Mariya Burrows","display_name_normalized":"Mariya + Burrows","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g742995f6521","image_24":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/742995f6521248254aa31fc269323b35.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0001-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071452,"has_2fa":false},{"id":"UN5R273J8","team_id":"TN69AJ2SU","name":"dtingg","deleted":false,"color":"9f69e7","real_name":"Dianna + Tingg","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Dianna + Tingg","real_name_normalized":"Dianna Tingg","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g18e16502755","first_name":"Dianna","last_name":"Tingg","image_24":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/18e16502755f0b33603d2f0476f51f79.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":true,"is_owner":true,"is_primary_owner":true,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071477,"has_2fa":false},{"id":"UN5R3N6P6","team_id":"TN69AJ2SU","name":"juliakingreyworks","deleted":false,"color":"3c989f","real_name":"Julia + K","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Julia + K","real_name_normalized":"Julia K","display_name":"Julia K","display_name_normalized":"Julia + K","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g8ae03401380","image_24":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/8ae034013803a39e79167e24e08629fc.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0003-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071668,"has_2fa":false},{"id":"UN5R3NYUU","team_id":"TN69AJ2SU","name":"morganlschuler","deleted":false,"color":"e0a729","real_name":"Morgan + Schuler","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Morgan + Schuler","real_name_normalized":"Morgan Schuler","display_name":"Morgan Schuler","display_name_normalized":"Morgan + Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany + Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany + Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568399214,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 18:26:54 GMT +- request: + method: get + uri: https://slack.com/api/im.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 503 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '310' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 18:26:54 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - dc4ccde6-c20e-4e90-8bab-1ea3c5742a36 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - im:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-d7ix + X-Cache: + - Miss from cloudfront + Via: + - 1.1 4db3f26ee4fd9a14a343fada3315105f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - Kqvpo3Q8Cu6giTkTbLpbROBxYRTYDEsClHA2Q_kKQ1rt77KKgmk7XA== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"service_unavailable"}' + http_version: + recorded_at: Fri, 13 Sep 2019 18:26:54 GMT +- request: + method: get + uri: https://slack.com/api/conversations.history?channel=DMUR2JRB5&token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '543' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 18:26:54 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 3a8f1baa-3d9b-4fc2-b0aa-4db7477d0ead + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:history,groups:history,mpim:history,im:history,read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-g1op + X-Cache: + - Miss from cloudfront + Via: + - 1.1 e109fb33da247873a89335ea6b680b25.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - 8B_-WVenDq1gRaO4IW4YuAbFZEhlHI0M7xENJqCZAvb0VPCaU6gRQw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"default + settings!","ts":"1568242282.001400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"who + am I???","ts":"1568242155.001300","username":"pumpkin","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"who + am i?","ts":"1568242101.001200","username":"dino","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"this + better be a jack o lantern","ts":"1568241614.001100","user":"USLACKBOT","username":"slackbot","icons":{"emoji":"::jack_o_lantern::"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"is + this a trex?","ts":"1568240139.001000","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"test + default sender","ts":"1568240116.000900","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"message + to dianna","ts":"1568238074.000800","username":"Leaves - Dianna - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233791.000700","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233781.000600","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233754.000500","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233721.000400","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test-false","ts":"1568233719.000300","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test","ts":"1568233699.000200","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test","ts":"1568233638.000100","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"}],"has_more":false,"pin_count":0}' + http_version: + recorded_at: Fri, 13 Sep 2019 18:26:54 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/bad_recipient.yml b/test/cassettes/bad_recipient.yml new file mode 100644 index 00000000..bd9abecf --- /dev/null +++ b/test/cassettes/bad_recipient.yml @@ -0,0 +1,64 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/test?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '70' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 16:32:32 GMT + Server: + - Apache + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Vary: + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - bcc5cf7f-7c68-459d-b97b-669396d22acd + X-Xss-Protection: + - '0' + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-ntnv + X-Cache: + - Miss from cloudfront + Via: + - 1.1 3a5c7b53ec8bee631ff6043996ffc1ce.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - 9HEpn18ePdkJ2a89YrJrOSh7fr-imtSlxKaO25gDKBjvBaWYbQAccQ== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"unknown_method","req_method":"test"}' + http_version: + recorded_at: Fri, 13 Sep 2019 16:32:33 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/bad_send_message.yml b/test/cassettes/bad_send_message.yml new file mode 100644 index 00000000..2a1b116e --- /dev/null +++ b/test/cassettes/bad_send_message.yml @@ -0,0 +1,137 @@ +--- +http_interactions: +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=I%27m%20a%20message%20to%20a%20user&channel=UMUR43REX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 503 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:48:35 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 52c79a75-1126-4b94-a6ff-d419366bbfd4 + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-ntnv + X-Cache: + - Miss from cloudfront + Via: + - 1.1 0732be5515ffeda639cfe5f22fb04df6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - Q-ATPzeXLtOAXQdFiG3AajOoYqczwZz-PMpxFXm2BrGbhAOFpibpBA== + body: + encoding: UTF-8 + string: '{"ok":false,"error":"service_unavailable"}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=I%27m%20a%20message%20to%20a%20channel&channel=CMUR2JTNX&as_user=false&username=Slackbot&icon_emoji=%3Ajack_o_lantern%3A + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 503 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:48:35 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - a920e6c2-c482-41d6-bd2a-8b1516207b6e + X-Oauth-Scopes: + - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - chat:write:bot + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-dzl1 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 61bc723adb3b1884ed759711e84e13a9.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - tuGIxxFEq5M7wqi47ahVYbt8R00PnsHbOcVYNYr5ve27YRxC5Vw4SA== + body: + encoding: UTF-8 + string: '{"ok":false,"error":"service_unavailable"}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:48:35 GMT +recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index aa59e92b..b93f2ba1 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -23,6 +23,14 @@ expect(result["ok"]).must_equal true end end + + it "Raises an error if code is not 200 or result is not ok" do + VCR.use_cassette("bad_channels") do + all_channels = SlackCLI::Channel.all + + expect{all_channels.first.get_message_history}.must_raise SlackCLI::SlackAPIError + end + end end describe "Self.all method" do diff --git a/test/recipient_test.rb b/test/recipient_test.rb index 2e7fb9ba..8ad25a0e 100644 --- a/test/recipient_test.rb +++ b/test/recipient_test.rb @@ -11,9 +11,11 @@ end end - describe "details method" do - it "Raises an exception for the details method" do - expect{recipient.details}.must_raise NotImplementedError + describe "self.get method" do + it "Raises an exception if code isn't 200 or ok isn't true" do + VCR.use_cassette("bad_recipient") do + expect{SlackCLI::Recipient.get("test")}.must_raise SlackCLI::SlackAPIError + end end end diff --git a/test/user_test.rb b/test/user_test.rb index 8b0d2011..ac459089 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -22,6 +22,22 @@ expect(result["ok"]).must_equal true end end + + it "Raises an error for IM list if code isn't 200 or ok isn't true" do + VCR.use_cassette("bad_ims_list") do + all_users = SlackCLI::User.all + + expect{all_users.first.get_message_history}.must_raise SlackCLI::SlackAPIError + end + end + + it "Raises an error for Converstaions list if code isn't 200 or ok isn't true" do + VCR.use_cassette("bad_conversations_list") do + all_users = SlackCLI::User.all + + expect{all_users.first.get_message_history}.must_raise SlackCLI::SlackAPIError + end + end end describe "Self.all method" do diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 4c147aa2..8e508722 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -140,6 +140,15 @@ end end + it "Raises an error if code is not 200 or ok is false" do + VCR.use_cassette("bad_send_message") do + @workspace.find_channel("random") + message_text = "I'm a message to a channel" + + expect{@workspace.send_message(message_text)}.must_raise SlackCLI::SlackAPIError + end + end + it "returns nil for a nonexistent user" do VCR.use_cassette("send_message") do @workspace.find_user("goblin") From deb9446a2dcaba379ba05e20be248fc6d9d57299 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Fri, 13 Sep 2019 14:01:45 -0700 Subject: [PATCH 22/24] fixed bug for message_history when selected is nil --- lib/slack.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 3c0900e8..4975f75f 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -83,7 +83,6 @@ def get_message() PUMPKIN_SPICE.send_message(message) else - # puts puts "You need to select a recipient." end end @@ -141,8 +140,11 @@ def main get_message when "get message history", "7", "seven" - response = PUMPKIN_SPICE.selected.get_message_history - format_message_history(response) + if PUMPKIN_SPICE.selected + response = PUMPKIN_SPICE.selected.get_message_history + else + puts "You need to select a recipient." + end when "change bot settings", "8", "eight" print "Please enter the bot's new name: " From 382a8f91a952fa9d50074561a695ace21689bf1d Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Fri, 13 Sep 2019 14:08:49 -0700 Subject: [PATCH 23/24] added line break and fixed bug --- lib/slack.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/slack.rb b/lib/slack.rb index 4975f75f..cb76e500 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -142,8 +142,9 @@ def main when "get message history", "7", "seven" if PUMPKIN_SPICE.selected response = PUMPKIN_SPICE.selected.get_message_history + format_message_history(response) else - puts "You need to select a recipient." + puts "\nYou need to select a recipient." end when "change bot settings", "8", "eight" From d3074e646ee9acda86ac9498a798ee5eda4c2ca2 Mon Sep 17 00:00:00 2001 From: Dianna Tingg Date: Fri, 13 Sep 2019 15:27:43 -0700 Subject: [PATCH 24/24] added select user and select channel methods --- lib/slack.rb | 5 ++-- lib/workspace.rb | 20 +++++++++---- test/cassettes/channels.yml | 42 +++++++++++++-------------- test/cassettes/send_message.yml | 36 +++++++++++------------ test/cassettes/users.yml | 51 +++++++++++++++++---------------- test/cassettes/workspace.yml | 30 +++++++++---------- test/workspace_test.rb | 44 ++++++++++++---------------- 7 files changed, 116 insertions(+), 112 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index cb76e500..be007098 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -40,7 +40,7 @@ def select_user print "Please enter the name or Slack ID of the user you want to select: " search_term = gets.chomp - result = PUMPKIN_SPICE.find_user(search_term) + result = PUMPKIN_SPICE.select_user(search_term) puts if result @@ -54,7 +54,7 @@ def select_channel print "Please enter the name or Slack ID of the channel you want to select: " search_term = gets.chomp - result = PUMPKIN_SPICE.find_channel(search_term) + result = PUMPKIN_SPICE.select_channel(search_term) puts if result @@ -142,6 +142,7 @@ def main when "get message history", "7", "seven" if PUMPKIN_SPICE.selected response = PUMPKIN_SPICE.selected.get_message_history + puts format_message_history(response) else puts "\nYou need to select a recipient." diff --git a/lib/workspace.rb b/lib/workspace.rb index c9f56f08..b47cdf58 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,7 +1,7 @@ module SlackCLI class Workspace - attr_reader :users, :channels, :selected - attr_accessor :bot_name, :bot_avatar + attr_reader :users, :channels + attr_accessor :bot_name, :bot_avatar, :selected def initialize() @users = SlackCLI::User.all @@ -21,18 +21,28 @@ def get_workplace_stats() end def find_user(search_term) - @selected = users.find do |user| + found = users.find do |user| user.name == search_term.downcase || user.slack_id == search_term.upcase end - return selected + return found end def find_channel(search_term) - @selected = channels.find do |channel| + found = channels.find do |channel| channel.name == search_term.downcase || channel.slack_id == search_term.upcase end + return found + end + + def select_user(search_term) + @selected = find_user(search_term) + return selected + end + + def select_channel(search_term) + @selected = find_channel(search_term) return selected end diff --git a/test/cassettes/channels.yml b/test/cassettes/channels.yml index 6231f64d..6a6724d1 100644 --- a/test/cassettes/channels.yml +++ b/test/cassettes/channels.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:34 GMT + - Fri, 13 Sep 2019 22:23:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - b1952085-4443-4282-90d9-8107eac863c4 + - 191cdc08-064f-455d-9593-73b0a6ce1321 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-fc14 + - haproxy-www-u916 X-Cache: - Miss from cloudfront Via: - - 1.1 112d82578d402a38d8d02e8b857617e1.cloudfront.net (CloudFront) + - 1.1 60b744e5b364d04abea9fa6686121242.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - eGkdASLf9QDsb1sBDEhNuuspzA6l7wEezGY8Ottsni3lxCJyDsWz9g== + - tsrsS9GUCxRenGaN98DGXDFTKppHwwTMHiY4oFTsWoMk5VEEmbdOkg== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -80,7 +80,7 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:34 GMT + recorded_at: Fri, 13 Sep 2019 22:23:57 GMT - request: method: get uri: https://slack.com/api/conversations.history?channel=CMUR2JTNX&limit=25&token= @@ -102,17 +102,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '781' + - '828' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:34 GMT + - Fri, 13 Sep 2019 22:23:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 5552f2de-d9b1-4be4-aaca-3c69ca8eda0d + - fa212d47-ba35-48ef-a51c-f57c6535ac42 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -138,24 +138,26 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-fdpw + - haproxy-www-idv8 X-Cache: - Miss from cloudfront Via: - - 1.1 3cd7af07832481c336aa1c93c9b4a6fe.cloudfront.net (CloudFront) + - 1.1 3a6260aec53985f2e6eb8a637c47918d.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - KC6uM5IxAglqqqpk51I4TxIlF6ax8TQSWz_q-MOaYVIjtcUP0EyyAA== + - VDRHu-j0uHUFUUO-JWPhRpxYS-f3vA8UnNwXr3WDCK3uxz4JgmA08A== body: encoding: ASCII-8BIT string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568413349.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"asdfghjkl","ts":"1568412968.000300","username":"Leaves + - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"hi!","ts":"1568412761.000200","username":"Leaves + - Mariya - API Project","bot_id":"BMW5VR8TV"},{"type":"message","subtype":"bot_message","text":"hi!","ts":"1568412621.000100","username":"Leaves + - Mariya - API Project","bot_id":"BMW5VR8TV"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568331869.000800","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568330837.000700","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568330428.000600","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568330348.000500","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568321235.000400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568321181.000300","username":"T-Rex","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568321083.000200","username":"T-Rex","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568321009.000100","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568242399.002300","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m @@ -173,11 +175,7 @@ http_interactions: a message to a channel","ts":"1568239206.001200","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"client_msg_id":"c05f1f48-7e5a-454c-a579-c172e69c0358","type":"message","text":"spacer test","user":"UMUR43REX","ts":"1568239188.001100","team":"TN69AJ2SU"},{"type":"message","subtype":"bot_message","text":"I''m a message to a channel","ts":"1568239173.000600","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568239026.000500","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":pumpkin:"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568237849.000400","username":"Leaves - Dianna - - API Project","bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568237560.000300","username":"Leaves - Dianna - - API Project","bot_id":"BMW7Z23K5"}],"has_more":true,"pin_count":0,"response_metadata":{"next_cursor":"bmV4dF90czoxNTY4MjM3MTYzMDAwMjAw"}}' + a message to a channel","ts":"1568239026.000500","user":"USLACKBOT","username":"slackbot","icons":{"emoji":":pumpkin:"},"bot_id":"BMW7Z23K5"}],"has_more":true,"pin_count":0,"response_metadata":{"next_cursor":"bmV4dF90czoxNTY4MjM3ODQ5MDAwNDAw"}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:34 GMT + recorded_at: Fri, 13 Sep 2019 22:23:57 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/send_message.yml b/test/cassettes/send_message.yml index eecf38c7..36b5069b 100644 --- a/test/cassettes/send_message.yml +++ b/test/cassettes/send_message.yml @@ -21,13 +21,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:35 GMT + - Fri, 13 Sep 2019 22:23:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 52c79a75-1126-4b94-a6ff-d419366bbfd4 + - 8fef71e1-b7c1-40c2-b03f-cf5e5890ba9e X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -53,21 +53,21 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-ntnv + - haproxy-www-qt4f X-Cache: - Miss from cloudfront Via: - - 1.1 0732be5515ffeda639cfe5f22fb04df6.cloudfront.net (CloudFront) + - 1.1 82ee5868f58a60e97a683c1fda270de3.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - Q-ATPzeXLtOAXQdFiG3AajOoYqczwZz-PMpxFXm2BrGbhAOFpibpBA== + - DOTq4WLZ_CglK-qwzz7eP0tORHSY1ZTT_plvipggoDVOd2620OJspw== body: encoding: UTF-8 - string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568332115.000200","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a user","ts":"1568332115.000200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"DN85DBHQX","ts":"1568413437.000200","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a user","ts":"1568413437.000200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:35 GMT + recorded_at: Fri, 13 Sep 2019 22:23:57 GMT - request: method: post uri: https://slack.com/api/chat.postMessage @@ -89,13 +89,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:35 GMT + - Fri, 13 Sep 2019 22:23:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - a920e6c2-c482-41d6-bd2a-8b1516207b6e + - a8432275-1a53-497c-9e71-df98de6a7130 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -121,19 +121,19 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-dzl1 + - haproxy-www-4tyc X-Cache: - Miss from cloudfront Via: - - 1.1 61bc723adb3b1884ed759711e84e13a9.cloudfront.net (CloudFront) + - 1.1 ec2a2c75c16156e4d43504606c118b91.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - tuGIxxFEq5M7wqi47ahVYbt8R00PnsHbOcVYNYr5ve27YRxC5Vw4SA== + - Saz2Hjw9_GBZj4i6iE1mq-N9lqZrRpKi7OqbN6x_J4QxK7L-_Q8Aaw== body: encoding: UTF-8 - string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568332115.000900","message":{"type":"message","subtype":"bot_message","text":"I''m - a message to a channel","ts":"1568332115.000900","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' + string: '{"ok":true,"channel":"CMUR2JTNX","ts":"1568413437.000500","message":{"type":"message","subtype":"bot_message","text":"I''m + a message to a channel","ts":"1568413437.000500","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:35 GMT + recorded_at: Fri, 13 Sep 2019 22:23:57 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users.yml b/test/cassettes/users.yml index e056dbc2..38973afe 100644 --- a/test/cassettes/users.yml +++ b/test/cassettes/users.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:34 GMT + - Fri, 13 Sep 2019 22:23:55 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - f9cea927-fb40-44bc-9209-80179136079d + - f04d4b0e-0c34-40a8-a40d-0fa150454838 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-64vz + - haproxy-www-f8tg X-Cache: - Miss from cloudfront Via: - - 1.1 d6a002c70d55f415107618b0750d493d.cloudfront.net (CloudFront) + - 1.1 adc2002956acc4d61bfbf3b973fdf247.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - IWbIbqKx6a1Voppa3ftwImSc8RgTaJ1B5mjUhdTKfuU6wecp3fMsbg== + - Ai3vCfuTc0vzJhvhhfkFoPYxVpyxP5o_SW9OXOSINRq2an2RlNa3Ag== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568332114,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568413435,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:34 GMT + recorded_at: Fri, 13 Sep 2019 22:23:56 GMT - request: method: get uri: https://slack.com/api/im.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:35 GMT + - Fri, 13 Sep 2019 22:23:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 7866861f-770c-4fba-8f1f-c026c591a1d0 + - 839d9617-965a-4488-8778-3242ae57aea8 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -149,20 +149,20 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-5nvv + - haproxy-www-qija X-Cache: - Miss from cloudfront Via: - - 1.1 4c7c693b007dfce603c83f138e31bccb.cloudfront.net (CloudFront) + - 1.1 34f8ef0e4c880df0650a814412a26ea6.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - wvgd7IIEzp8DQgQqAxYKKPCuXpnLlHr7ztz1IUwu0N3fEMeVQg_w7g== + - 6BaHPOhzdm44fON1lT3U1rvb-2juMc2KrOYC62JeC8k0MSGnPvhzHw== body: encoding: ASCII-8BIT string: '{"ok":true,"ims":[{"id":"DN85DC8MD","created":1568071309,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMZSUVBED","is_user_deleted":false,"priority":0},{"id":"DN85DBRC7","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3N6P6","is_user_deleted":false,"priority":0},{"id":"DN69K4V61","created":1568071310,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R3NYUU","is_user_deleted":false,"priority":0},{"id":"DN69C3L3S","created":1568071307,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMUR43REX","is_user_deleted":false,"priority":0},{"id":"DN69AJ9K2","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN5R273J8","is_user_deleted":false,"priority":0},{"id":"DN5R3NKDJ","created":1568071308,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UMTG0S5D0","is_user_deleted":false,"priority":0},{"id":"DMUR2JRB5","created":1568071183,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"USLACKBOT","is_user_deleted":false,"priority":0},{"id":"DMTG0RLMQ","created":1568071306,"is_archived":false,"is_im":true,"is_org_shared":false,"user":"UN69C37BJ","is_user_deleted":false,"priority":0}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:35 GMT + recorded_at: Fri, 13 Sep 2019 22:23:57 GMT - request: method: get uri: https://slack.com/api/conversations.history?channel=DMUR2JRB5&token= @@ -184,17 +184,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '543' + - '606' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:35 GMT + - Fri, 13 Sep 2019 22:23:57 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - e9ff0ac4-3000-4349-ad4c-9d60f4ffb0a6 + - 30c4e979-4dd2-4f18-8646-4f57fd748dcc X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -220,18 +220,21 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-f5e7 + - haproxy-www-sk4y X-Cache: - Miss from cloudfront Via: - - 1.1 57a21088b36c69a83578b5a5579df58f.cloudfront.net (CloudFront) + - 1.1 d042f60a962591f741406f28a8170c5a.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - aj9dNHnRaf9QtZWXNuy7_-EHyyER161rmSPtJqwc-SxQNp1ZvHMbbQ== + - bTE_lIq9i3ItQXKmBnN-VxEUhxB0yUQ957h7nvo-IqRfxil2OvTJJw== body: encoding: ASCII-8BIT - string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"default + string: '{"ok":true,"messages":[{"type":"message","subtype":"bot_message","text":"trex + grrr","ts":"1568409173.000400","username":"trex","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"test + to dianna","ts":"1568409095.000200","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"From + Diannabot to Dianna","ts":"1568408046.000100","username":"Diannabot","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"default settings!","ts":"1568242282.001400","username":"Slackbot","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"who am I???","ts":"1568242155.001300","username":"pumpkin","icons":{"emoji":":jack_o_lantern:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f383.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"who am i?","ts":"1568242101.001200","username":"dino","icons":{"emoji":":t-rex:","image_64":"https:\/\/a.slack-edge.com\/80588\/img\/emoji_2017_12_06\/apple\/1f996.png"},"bot_id":"BMW7Z23K5"},{"type":"message","subtype":"bot_message","text":"this @@ -247,5 +250,5 @@ http_interactions: - Tiffany - API Project","bot_id":"BMURAQX7D"},{"type":"message","subtype":"bot_message","text":"Test","ts":"1568233638.000100","username":"Leaves - Tiffany - API Project","bot_id":"BMURAQX7D"}],"has_more":false,"pin_count":0}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:35 GMT + recorded_at: Fri, 13 Sep 2019 22:23:57 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index 3f13b98f..3c75776e 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -25,13 +25,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:34 GMT + - Fri, 13 Sep 2019 22:23:56 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - f07f3b44-41fd-4ae4-92d8-7d17430868a5 + - fc541889-f4f3-4047-8116-81c7d5ba33d3 X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-78ya + - haproxy-www-f2n6 X-Cache: - Miss from cloudfront Via: - - 1.1 570075675953459325e00b7bcd171df3.cloudfront.net (CloudFront) + - 1.1 deaaf0548506de20925615eb51a7ea7f.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - 1psEQKErkTlhNZmIVcPBzcaRyyCU_gQeR3DZA4Uo0cUU9IA0X0JmVA== + - HnmvdoBV71sp4j892nVutTAh_48A8NXzyXepgN2MI8OEvPK61eHADw== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69AJ2SU","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -89,9 +89,9 @@ http_interactions: Schuler","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gc6d02aa49cf","image_24":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/c6d02aa49cf9d47142e8cfcb7e897b98.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071410,"has_2fa":false},{"id":"UN69C37BJ","team_id":"TN69AJ2SU","name":"tiffanycee123","deleted":false,"color":"4bbe2e","real_name":"Tiffany Chio","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Tiffany Chio","real_name_normalized":"Tiffany Chio","display_name":"Tiffany Chio","display_name_normalized":"Tiffany - Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568332114,"response_metadata":{"next_cursor":""}}' + Chio","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"ge49485fcc1e","image_24":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/e49485fcc1e6f86f199952b8108015e0.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0015-512.png","status_text_canonical":"","team":"TN69AJ2SU"},"is_admin":false,"is_owner":false,"is_primary_owner":false,"is_restricted":false,"is_ultra_restricted":false,"is_bot":false,"is_app_user":false,"updated":1568071504,"has_2fa":false}],"cache_ts":1568413436,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:34 GMT + recorded_at: Fri, 13 Sep 2019 22:23:56 GMT - request: method: get uri: https://slack.com/api/channels.list?token= @@ -117,13 +117,13 @@ http_interactions: Connection: - keep-alive Date: - - Thu, 12 Sep 2019 23:48:34 GMT + - Fri, 13 Sep 2019 22:23:56 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - c09f721e-9e1d-4b84-a5a1-e81cba343f18 + - 7ceb6a14-d571-451a-8ea5-da83778b9d4b X-Oauth-Scopes: - identify,channels:history,im:history,channels:read,im:read,search:read,users:read,chat:write:bot Expires: @@ -149,15 +149,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-lwkq + - haproxy-www-odun X-Cache: - Miss from cloudfront Via: - - 1.1 61bc723adb3b1884ed759711e84e13a9.cloudfront.net (CloudFront) + - 1.1 82ee5868f58a60e97a683c1fda270de3.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C2 + - SEA19-C1 X-Amz-Cf-Id: - - b50_cScswHlmZo4tm4sTf-ybJH9aQkt04Dw0wuTUDKZnq77-eZRiEw== + - cwAt_HqJwWFQSomJemhkI2eZhO33u_VJLaF8D5arb4BPGgYwpNXySA== body: encoding: ASCII-8BIT string: '{"ok":true,"channels":[{"id":"CMUR2JTNX","name":"random","is_channel":true,"created":1568071183,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN5R273J8","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG0S5D0","UMUR43REX","UMZSUVBED","UN5R273J8","UN5R3N6P6","UN5R3NYUU","UN69C37BJ"],"topic":{"value":"Non-work @@ -172,5 +172,5 @@ http_interactions: channel is for workspace-wide communication and announcements. All members are in this channel.","creator":"UN5R273J8","last_set":1568071183},"previous_names":[],"num_members":7}],"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 23:48:34 GMT + recorded_at: Fri, 13 Sep 2019 22:23:56 GMT recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 8e508722..6638ea9e 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -65,18 +65,6 @@ expect(user).must_be_nil end - - it "Changes selected to the chosen user" do - user = @workspace.find_user("slackbot") - - expect(@workspace.selected).must_equal user - end - - it "Changes selected to nil if no user found" do - @workspace.find_user("garbage") - - expect(@workspace.selected).must_be_nil - end end describe "find_channel method" do @@ -101,24 +89,28 @@ expect(channel).must_be_nil end - - it "Changes selected to the chosen channel" do - channel = @workspace.find_channel("random") + end + + describe "select_user method" do + it "changes the value of selected for the workspace" do + @workspace.select_user("slackbot") - expect(@workspace.selected).must_equal channel + expect(@workspace.selected.name).must_equal "slackbot" end - - it "Changes selected to nil if no user found" do - @workspace.find_channel("garbage") + end + + describe "select_channel method" do + it "changes the value of selected for the workspace" do + @workspace.select_channel("random") - expect(@workspace.selected).must_be_nil + expect(@workspace.selected.name).must_equal "random" end - end + end describe "send_message method" do it "sends a message to a user" do VCR.use_cassette("send_message") do - @workspace.find_user("sabrina") + @workspace.select_user("sabrina") message_text = "I'm a message to a user" response = @workspace.send_message(message_text) @@ -130,7 +122,7 @@ it "sends a message to a channel" do VCR.use_cassette("send_message") do - @workspace.find_channel("random") + @workspace.select_channel("random") message_text = "I'm a message to a channel" response = @workspace.send_message(message_text) @@ -142,7 +134,7 @@ it "Raises an error if code is not 200 or ok is false" do VCR.use_cassette("bad_send_message") do - @workspace.find_channel("random") + @workspace.select_channel("random") message_text = "I'm a message to a channel" expect{@workspace.send_message(message_text)}.must_raise SlackCLI::SlackAPIError @@ -151,7 +143,7 @@ it "returns nil for a nonexistent user" do VCR.use_cassette("send_message") do - @workspace.find_user("goblin") + @workspace.select_user("goblin") message_text = "I won't get sent to a user" response = @workspace.send_message(message_text) @@ -162,7 +154,7 @@ it "returns nil for a nonexistent channel" do VCR.use_cassette("send_message") do - @workspace.find_user("goblin") + @workspace.select_user("goblin") message_text = "I won't get sent to a channel" response = @workspace.send_message(message_text)