From b119be4e7c68e593669b77d7ccdd4014c37f0c66 Mon Sep 17 00:00:00 2001 From: "m.dove@live.com" <“m.dove@live.com”> Date: Tue, 10 Sep 2019 16:30:17 -0700 Subject: [PATCH 1/9] Added class files. Modified slack.rb to contain user interface --- lib/channel.rb | 0 lib/factory.rb | 0 lib/recipient.rb | 12 ++++++++++++ lib/slack.rb | 27 +++++++++++++++++++++++---- lib/user.rb | 0 lib/workspace.rb | 0 test/channel_test.rb | 0 test/factory_test.rb | 0 test/recipient_test.rb | 0 test/user_test.rb | 0 test/workspace_test.rb | 0 11 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 lib/channel.rb create mode 100644 lib/factory.rb create mode 100644 lib/recipient.rb create mode 100644 lib/user.rb create mode 100644 lib/workspace.rb create mode 100644 test/channel_test.rb create mode 100644 test/factory_test.rb create mode 100644 test/recipient_test.rb create mode 100644 test/user_test.rb create mode 100644 test/workspace_test.rb diff --git a/lib/channel.rb b/lib/channel.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/factory.rb b/lib/factory.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/recipient.rb b/lib/recipient.rb new file mode 100644 index 00000000..348a0802 --- /dev/null +++ b/lib/recipient.rb @@ -0,0 +1,12 @@ +require "dotenv" + +Dotenv.load + +class Recipient + attr_reader :id, :name + + def initialize(id, name) + @id = id + @name = name + end +end diff --git a/lib/slack.rb b/lib/slack.rb index 960cf2f7..fea8a642 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,11 +1,30 @@ #!/usr/bin/env ruby +require "dotenv" +require "httparty" +require "awesome_print" -def main - puts "Welcome to the Ada Slack CLI!" +Dotenv.load - # TODO project +def main + puts "Hello. Welcome, friend. Please enjoy our Slack CLI." + puts "What would you like to do? Please select an option" + puts "1. List Channels\n2. List Users\n3. Quit" + user_selection = gets.chomp.downcase + while user_selection + case user_selection + when "1" || "list channels" + puts "list_channels" + when "2" || "list users" + puts "list_users" + when "3" || "quit" + exit + end + puts "What would you like to do? Please select an option" + puts "1.List Channels\n 2. List Users\n 3.Quit" + user_selection = gets.chomp.downcase + end 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..e69de29b diff --git a/lib/workspace.rb b/lib/workspace.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/channel_test.rb b/test/channel_test.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/factory_test.rb b/test/factory_test.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/recipient_test.rb b/test/recipient_test.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/user_test.rb b/test/user_test.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/workspace_test.rb b/test/workspace_test.rb new file mode 100644 index 00000000..e69de29b From 70b8b4a31104f29187c00b5eac06f6f8805000b3 Mon Sep 17 00:00:00 2001 From: "m.dove@live.com" <“m.dove@live.com”> Date: Tue, 10 Sep 2019 16:57:36 -0700 Subject: [PATCH 2/9] Wrote list users method --- lib/factory.rb | 21 +++++++++++++++++++++ lib/slack.rb | 9 +++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/factory.rb b/lib/factory.rb index e69de29b..a198f3de 100644 --- a/lib/factory.rb +++ b/lib/factory.rb @@ -0,0 +1,21 @@ +require "dotenv" +require "httparty" +Dotenv.load + +class Factory + TOKEN = ENV["SLACK_TOKEN"] + + def initialize + @channel_url = "https://slack.com/api/conversations.list" + @user_url = "https://slack.com/api/users.list" + @message_url = "https://slack.com/api/chat.postMessage" + @channel_member_url = "https://slack.com/api/conversations.members" + end + + def list_users + user_list = HTTParty.get(@user_url, query: { token: TOKEN }) + user_list["members"].map do |user| + "ID: #{id = user["id"]} Username: #{username = user["name"]} Name: #{real_name = user["real_name"]}" + end + end +end diff --git a/lib/slack.rb b/lib/slack.rb index fea8a642..c41bcb1d 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -2,7 +2,7 @@ require "dotenv" require "httparty" require "awesome_print" - +require_relative "factory" Dotenv.load def main @@ -16,15 +16,16 @@ def main puts "list_channels" when "2" || "list users" puts "list_users" + factory = Factory.new + puts factory.list_users when "3" || "quit" + puts "Thank you for using the Ada Slack CLI" exit end puts "What would you like to do? Please select an option" - puts "1.List Channels\n 2. List Users\n 3.Quit" + puts "1. List Channels\n2. List Users\n3. Quit" user_selection = gets.chomp.downcase end - - puts "Thank you for using the Ada Slack CLI" end main if __FILE__ == $PROGRAM_NAME From 461ce4a780d1ab91a96d5739b316677776df1b21 Mon Sep 17 00:00:00 2001 From: "m.dove@live.com" <“m.dove@live.com”> Date: Thu, 12 Sep 2019 10:30:17 -0700 Subject: [PATCH 3/9] added Workspace tests and removed factory as a class --- lib/channel.rb | 20 ++++++++ lib/factory.rb | 21 -------- lib/recipient.rb | 8 +++ lib/slack.rb | 11 +++-- lib/user.rb | 19 +++++++ lib/workspace.rb | 50 +++++++++++++++++++ test/cassettes/user.yml | 80 ++++++++++++++++++++++++++++++ test/channel_test.rb | 9 ++++ test/factory_test.rb | 0 test/test_helper.rb | 30 +++++++++--- test/workspace_test.rb | 106 ++++++++++++++++++++++++++++++++++++++++ 11 files changed, 322 insertions(+), 32 deletions(-) delete mode 100644 lib/factory.rb create mode 100644 test/cassettes/user.yml delete mode 100644 test/factory_test.rb diff --git a/lib/channel.rb b/lib/channel.rb index e69de29b..bb8f61d5 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -0,0 +1,20 @@ +require_relative "recipient" + +class Channel < Recipient + attr_reader :id, :name, :details, :topic, :member_count + + def initialize(id, name, details = "", topic = "", member_count = "") + super(id, name) + @details = details + @topic = topic + @member_count = member_count + end + + def self.load_all(url, token) + recipients = HTTParty.get(url, query: { token: token }) + all_recipients = recipients["channels"].map do |recipient| + recipient = new(recipient["id"], recipient["name"], recipient["info"], topic = recipient["topic"]["value"], member_count = recipient["num_members"]) + end + return all_recipients + end +end diff --git a/lib/factory.rb b/lib/factory.rb deleted file mode 100644 index a198f3de..00000000 --- a/lib/factory.rb +++ /dev/null @@ -1,21 +0,0 @@ -require "dotenv" -require "httparty" -Dotenv.load - -class Factory - TOKEN = ENV["SLACK_TOKEN"] - - def initialize - @channel_url = "https://slack.com/api/conversations.list" - @user_url = "https://slack.com/api/users.list" - @message_url = "https://slack.com/api/chat.postMessage" - @channel_member_url = "https://slack.com/api/conversations.members" - end - - def list_users - user_list = HTTParty.get(@user_url, query: { token: TOKEN }) - user_list["members"].map do |user| - "ID: #{id = user["id"]} Username: #{username = user["name"]} Name: #{real_name = user["real_name"]}" - end - end -end diff --git a/lib/recipient.rb b/lib/recipient.rb index 348a0802..0b02c81c 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -9,4 +9,12 @@ def initialize(id, name) @id = id @name = name end + + def self.load_all(url, token) + recipients = HTTParty.get(url, query: { token: token }) + all_recipients = recipients.map do |recipient| + recipient = new(recipient["id"], recipient["name"]) + end + return all_recipients + end end diff --git a/lib/slack.rb b/lib/slack.rb index c41bcb1d..bd71b714 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,11 +1,14 @@ #!/usr/bin/env ruby require "dotenv" require "httparty" +require "vcr" require "awesome_print" -require_relative "factory" +require_relative "workspace" Dotenv.load def main + workspace = Workspace.new + puts workspace.get_channels puts "Hello. Welcome, friend. Please enjoy our Slack CLI." puts "What would you like to do? Please select an option" puts "1. List Channels\n2. List Users\n3. Quit" @@ -14,10 +17,12 @@ def main case user_selection when "1" || "list channels" puts "list_channels" + workspace = Workspace.new + puts workspace.list_channels when "2" || "list users" puts "list_users" - factory = Factory.new - puts factory.list_users + workspace = Workspace.new + puts workspace.list_users when "3" || "quit" puts "Thank you for using the Ada Slack CLI" exit diff --git a/lib/user.rb b/lib/user.rb index e69de29b..46804cd4 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -0,0 +1,19 @@ +require_relative "recipient" + +class User < Recipient + attr_reader :id, :name, :details, :username + + def initialize(id, name, details = "", username = "") + super(id, name) + @details = details + @username = username + end + + def self.load_all(url, token) + recipients = HTTParty.get(url, query: { token: token }) + all_recipients = recipients["members"].map do |recipient| + recipient = new(recipient["id"], recipient["real_name"], details = recipient["info"], username = recipient["name"]) + end + return all_recipients + end +end diff --git a/lib/workspace.rb b/lib/workspace.rb index e69de29b..1fb804b8 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -0,0 +1,50 @@ +require "dotenv" +require "httparty" +Dotenv.load + +require_relative "recipient" +require_relative "channel" +require_relative "user" + +class Workspace + TOKEN = ENV["SLACK_TOKEN"] + + def initialize + @channel_url = "https://slack.com/api/conversations.list" + @user_url = "https://slack.com/api/users.list" + @message_url = "https://slack.com/api/chat.postMessage" + @channel_member_url = "https://slack.com/api/conversations.members" + @users = get_users + @channels = get_channels + end + + def get_users + User.load_all(@user_url, TOKEN) + end + + def get_channels + Channel.load_all(@channel_url, TOKEN) + end + + def find_by_id(id) + end + + def list_users + user_list = HTTParty.get(@user_url, query: { token: TOKEN }) + user_list["members"].map do |user| + "ID: #{id = user["id"]} + Username: #{username = user["name"]} + Name: #{real_name = user["real_name"]}" + end + end + + def list_channels + channel_list = HTTParty.get(@channel_url, query: { token: TOKEN }) + channel_list["channels"].map do |channel| + "ID: #{id = channel["id"]} + Name: #{name = channel["name"]} + Topic: #{topic = channel["topic"]["value"]} + Member Count: #{member_count = channel["num_members"]}" + end + end +end diff --git a/test/cassettes/user.yml b/test/cassettes/user.yml new file mode 100644 index 00000000..a747e43d --- /dev/null +++ b/test/cassettes/user.yml @@ -0,0 +1,80 @@ +--- +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: + - '915' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 03:26:54 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 16e086a8-d822-4aea-9073-572dfeabf180 + 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-0t0n + X-Cache: + - Miss from cloudfront + Via: + - 1.1 49cdeca097624936e070b73619df7da9.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - 68soQjLfOt6duYh9ApRQ2LHgksG1S4Hin1h29TvBqZLk6KJJR_h23g== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568258814,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 03:26:54 GMT +recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index e69de29b..65b1b00c 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -0,0 +1,9 @@ +require_relative "test_helper" +describe "channel" do + describe "instantiate a channel" do + before do + @channel = Channel.new("https://slack.com/api/conversations.list", ENV["SLACK_TOKEN"]) + Channel.load_all + end + end +end diff --git a/test/factory_test.rb b/test/factory_test.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/test/test_helper.rb b/test/test_helper.rb index 90aeb408..9952a3b6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,17 +1,31 @@ -require 'simplecov' +require "simplecov" SimpleCov.start do - add_filter 'test/' + add_filter "test/" end -require 'minitest' -require 'minitest/autorun' -require 'minitest/reporters' -require 'minitest/skip_dsl' -require 'vcr' +require "minitest" +require "minitest/autorun" +# require "minitest/reporters" +require "minitest/skip_dsl" +require "minitest/pride" +require "vcr" -Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new +# Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new VCR.configure do |config| 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_TOKEN"] + end end + +require_relative "../lib/workspace" +require_relative "../lib/slack" +require_relative "../lib/user" +require_relative "../lib/channel" +require_relative "../lib/recipient" diff --git a/test/workspace_test.rb b/test/workspace_test.rb index e69de29b..b54287e7 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -0,0 +1,106 @@ +require_relative "test_helper" + +describe "workspace" do + describe "list_users" do + before do + VCR.use_cassette("workspace_get_users_test") do + @workspace = Workspace.new + + @users = @workspace.get_users + end + end + it "retrieves the correct number of users in a workspace" do + expect(@users.length).must_equal 3 + end + it "gets the usernames of all the users" do + expect(@users[0].username).must_equal "slackbot" + expect(@users[1].username).must_equal "m.dove" + expect(@users[2].username).must_equal "kelseykripp" + end + it "gets the real names of all the users" do + expect(@users[0].name).must_equal "Slackbot" + expect(@users[1].name).must_equal "Mackie Dove" + expect(@users[2].name).must_equal "Kelsey Kripp" + end + end + describe "list_channels" do + before do + VCR.use_cassette("workspace_list_channels_test") do + @workspace = Workspace.new + + @channels = @workspace.list_channels + end + end + + it "retrieves the correct number of channels in a workspace" do + expect(@channels.length).must_equal 3 + end + end + describe "list_users" do + before do + VCR.use_cassette("workspace_list_users_test") do + @workspace = Workspace.new + + @users = @workspace.list_users + end + end + + it "retrieves the correct number of users in the workspace" do + expect(@users.length).must_equal 3 + end + end + + describe "find_by_id" do + before do + VCR.use_cassette("workspace_find_by_id") do + @workspace = Workspace.new + end + end + + it "retrieves the correct recipie t matching the id" do + user = nil + + user = @workspace.find_by_id("UMURH3TBM") + + expect(user).must_be_instance_of User + expect(user.username).must_equal "m.dove" + end + end + + # describe "find_channel_by_id" do + # before do + # VCR.use_cassette("workspace_find_channel_by_id") do + # @workspace = Workspace.new + # end + # end + + # it "retrieves the correct channel matching the id" do + # channel = nil + + # channel = @workspace.find_channel_by_id("CN85SCME3") + + # expect(channel).must_be_instance_of Channel + # expect(channel.name).must_equal "slack-cli" + # end + # end + + describe "error cases" do + before do + VCR.use_cassette("workspace_find_channel_by_id_error") do + @workspace = Workspace.new + end + + it "tries to instantiate a recipient object" do + expect { Recipient.load_all("url", "token") }.must_raise ArgumentError + end + + it "attempts to find a channel whose id does not exist" do + expect { @workspace.find_channel_by_id("IDONTEXIST") }.must_raise ArgumentError + end + end + + it "attempts to find a user whose id does not exist" do + expect { @workspace.find_user_by_id("IDONTEXIST") }.must_raise ArgumentError + end + end +end From 861f30189ec21485dfe7b9a6a44c1af20f6496b6 Mon Sep 17 00:00:00 2001 From: Kelsey Krippaehne Date: Thu, 12 Sep 2019 14:16:41 -0700 Subject: [PATCH 4/9] Added method to find recipient by id or name; updated CLI to include wave 2 selection options --- lib/slack.rb | 20 +++++++++++++++++--- lib/workspace.rb | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index bd71b714..ac444cbd 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -11,7 +11,7 @@ def main puts workspace.get_channels puts "Hello. Welcome, friend. Please enjoy our Slack CLI." puts "What would you like to do? Please select an option" - puts "1. List Channels\n2. List Users\n3. Quit" + puts "1. List Channels\n2. List Users\n3. Select Channel\n4. Select User\n5. List Details\n6. Quit" user_selection = gets.chomp.downcase while user_selection case user_selection @@ -23,12 +23,26 @@ def main puts "list_users" workspace = Workspace.new puts workspace.list_users - when "3" || "quit" + when "3" || "select channel" + puts "select_channel" + workspace = Workspace.new + selection = gets.chomp + puts workspace.find_by_id_or_name(workspace.channels, selection) + when "4" || "select user" + puts "select_user" + workspace = Workspace.new + selection = gets.chomp + puts workspace.find_by_id_or_name(workspace.users, selection) + when "5" || "details" + puts "list_details_on_current_recipient" + workspace = Workspace.new + workspace.list_details_on_current_recipient + when "6" || "quit" puts "Thank you for using the Ada Slack CLI" exit end puts "What would you like to do? Please select an option" - puts "1. List Channels\n2. List Users\n3. Quit" + puts "1. List Channels\n2. List Users\n3. Select Channel\n4. Select User\n5. List Details\n6. Quit" user_selection = gets.chomp.downcase end end diff --git a/lib/workspace.rb b/lib/workspace.rb index 1fb804b8..90f2f743 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -8,7 +8,9 @@ class Workspace TOKEN = ENV["SLACK_TOKEN"] - + + attr_accessor :users, :channels #added these in order to access/update them + def initialize @channel_url = "https://slack.com/api/conversations.list" @user_url = "https://slack.com/api/users.list" @@ -17,27 +19,52 @@ def initialize @users = get_users @channels = get_channels end - + def get_users User.load_all(@user_url, TOKEN) end - + def get_channels Channel.load_all(@channel_url, TOKEN) end - - def find_by_id(id) + + def find_by_id_or_name(recipient_type, search_arg) + # verifies that the Recipient is either a User or a Channel + # might want to move this validation into the slack.rb file + if recipient_type != @users && recipient_type != @channels + raise ArgumentError, "Recipient must be either a user or a channel." + end + + # finds the recipient using the search_arg + # search_arg could be a name or an id, either way works! + recipient = recipient_type.find do |recipient| + recipient.id == search_arg || recipient.name == search_arg + end + + # raises arg error if the recipient isn't found by either name or id + if recipient == nil + raise ArgumentError, "Recipient not found." + end + + return recipient end - + + def select_user(id) + User.set_as_recipient(id) + end + def select_channel(id) + Channel.set_as_recipient(id) + end + def list_users user_list = HTTParty.get(@user_url, query: { token: TOKEN }) user_list["members"].map do |user| "ID: #{id = user["id"]} Username: #{username = user["name"]} - Name: #{real_name = user["real_name"]}" + Name: #{real_name = user["real_name"]}" end end - + def list_channels channel_list = HTTParty.get(@channel_url, query: { token: TOKEN }) channel_list["channels"].map do |channel| From 66734aecc3186981b7ae8f05fed20178eb23a782 Mon Sep 17 00:00:00 2001 From: Kelsey Krippaehne Date: Thu, 12 Sep 2019 14:32:36 -0700 Subject: [PATCH 5/9] Made one main instance of Workspace --- lib/workspace.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/workspace.rb b/lib/workspace.rb index 90f2f743..21855884 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,5 +1,6 @@ require "dotenv" require "httparty" +require "awesome_print" Dotenv.load require_relative "recipient" @@ -9,7 +10,7 @@ class Workspace TOKEN = ENV["SLACK_TOKEN"] - attr_accessor :users, :channels #added these in order to access/update them + attr_accessor :users, :channels, :current_recipient #added these in order to access/update them; added current_recipient to hold the currently selected user or channel def initialize @channel_url = "https://slack.com/api/conversations.list" @@ -18,6 +19,7 @@ def initialize @channel_member_url = "https://slack.com/api/conversations.members" @users = get_users @channels = get_channels + @current_recipient = "" end def get_users @@ -44,9 +46,13 @@ def find_by_id_or_name(recipient_type, search_arg) # raises arg error if the recipient isn't found by either name or id if recipient == nil raise ArgumentError, "Recipient not found." + else + @current_recipient = recipient end - - return recipient + end + + def list_details_on_current_recipient + ap @current_recipient end def select_user(id) From ac5ab7efe13d1a9205cea91b6e5cec251aec4e46 Mon Sep 17 00:00:00 2001 From: Kelsey Krippaehne Date: Thu, 12 Sep 2019 14:45:37 -0700 Subject: [PATCH 6/9] Added method to load details of the current recipient --- lib/channel.rb | 11 +++++++++-- lib/recipient.rb | 12 ++++++++++-- lib/slack.rb | 5 ----- lib/user.rb | 11 +++++++++-- lib/workspace.rb | 21 ++++++++++++--------- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/lib/channel.rb b/lib/channel.rb index bb8f61d5..cbec822c 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -2,14 +2,14 @@ class Channel < Recipient attr_reader :id, :name, :details, :topic, :member_count - + def initialize(id, name, details = "", topic = "", member_count = "") super(id, name) @details = details @topic = topic @member_count = member_count end - + def self.load_all(url, token) recipients = HTTParty.get(url, query: { token: token }) all_recipients = recipients["channels"].map do |recipient| @@ -17,4 +17,11 @@ def self.load_all(url, token) end return all_recipients end + + def load_details + # inherits ID & Name from Recipient + super + puts "Topic: #{@topic}" + puts "Member Count: #{@member_count}" + end end diff --git a/lib/recipient.rb b/lib/recipient.rb index 0b02c81c..4e487e80 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -4,12 +4,12 @@ class Recipient attr_reader :id, :name - + def initialize(id, name) @id = id @name = name end - + def self.load_all(url, token) recipients = HTTParty.get(url, query: { token: token }) all_recipients = recipients.map do |recipient| @@ -17,4 +17,12 @@ def self.load_all(url, token) end return all_recipients end + + def load_details + # inherited by Channel & User + puts "#{self.class} Details" + puts "ID: #{self.id}" + puts "Name: #{self.name}" + end + end diff --git a/lib/slack.rb b/lib/slack.rb index ac444cbd..4e386e1a 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -17,25 +17,20 @@ def main case user_selection when "1" || "list channels" puts "list_channels" - workspace = Workspace.new puts workspace.list_channels when "2" || "list users" puts "list_users" - workspace = Workspace.new puts workspace.list_users when "3" || "select channel" puts "select_channel" - workspace = Workspace.new selection = gets.chomp puts workspace.find_by_id_or_name(workspace.channels, selection) when "4" || "select user" puts "select_user" - workspace = Workspace.new selection = gets.chomp puts workspace.find_by_id_or_name(workspace.users, selection) when "5" || "details" puts "list_details_on_current_recipient" - workspace = Workspace.new workspace.list_details_on_current_recipient when "6" || "quit" puts "Thank you for using the Ada Slack CLI" diff --git a/lib/user.rb b/lib/user.rb index 46804cd4..04910f14 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -2,13 +2,13 @@ class User < Recipient attr_reader :id, :name, :details, :username - + def initialize(id, name, details = "", username = "") super(id, name) @details = details @username = username end - + def self.load_all(url, token) recipients = HTTParty.get(url, query: { token: token }) all_recipients = recipients["members"].map do |recipient| @@ -16,4 +16,11 @@ def self.load_all(url, token) end return all_recipients end + + def load_details + # inherits ID & Name from Recipient + super + puts "Username: #{@username}" + end + end diff --git a/lib/workspace.rb b/lib/workspace.rb index 21855884..618c439b 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,6 +1,5 @@ require "dotenv" require "httparty" -require "awesome_print" Dotenv.load require_relative "recipient" @@ -19,7 +18,7 @@ def initialize @channel_member_url = "https://slack.com/api/conversations.members" @users = get_users @channels = get_channels - @current_recipient = "" + @current_recipient = nil end def get_users @@ -51,16 +50,20 @@ def find_by_id_or_name(recipient_type, search_arg) end end + # 'load_details' is a method in Recipient def list_details_on_current_recipient - ap @current_recipient + if @current_recipient == nil + raise ArgumentError, "No recipient is currently selected." + end + @current_recipient.load_details end - def select_user(id) - User.set_as_recipient(id) - end - def select_channel(id) - Channel.set_as_recipient(id) - end + # def select_user(id) + # User.set_as_recipient(id) + # end + # def select_channel(id) + # Channel.set_as_recipient(id) + # end def list_users user_list = HTTParty.get(@user_url, query: { token: TOKEN }) From 9ab14a74478f152eeccc3aca20d8d4cf60eb5be4 Mon Sep 17 00:00:00 2001 From: Kelsey Krippaehne Date: Thu, 12 Sep 2019 16:17:25 -0700 Subject: [PATCH 7/9] Created initial method for sending a message --- lib/slack.rb | 17 ++++++++++++++--- lib/workspace.rb | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 4e386e1a..9e64e2eb 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -11,7 +11,7 @@ def main puts workspace.get_channels puts "Hello. Welcome, friend. Please enjoy our Slack CLI." puts "What would you like to do? Please select an option" - puts "1. List Channels\n2. List Users\n3. Select Channel\n4. Select User\n5. List Details\n6. Quit" + puts "1. List Channels\n2. List Users\n3. Select Channel\n4. Select User\n5. List Details\n6. Send Message\n7. Quit" user_selection = gets.chomp.downcase while user_selection case user_selection @@ -24,20 +24,31 @@ def main when "3" || "select channel" puts "select_channel" selection = gets.chomp + # make a method to validate that the input is a channel? + puts workspace.find_by_id_or_name(workspace.channels, selection) when "4" || "select user" puts "select_user" selection = gets.chomp + # make a method to validate that the input is a user? + puts workspace.find_by_id_or_name(workspace.users, selection) when "5" || "details" puts "list_details_on_current_recipient" workspace.list_details_on_current_recipient - when "6" || "quit" + when "6" || "send message" + puts "send_message" + puts "Do you want cats with that? (yes/no)" + cats = gets.chomp.downcase + puts "Please enter your message:" + message = gets.chomp + puts workspace.send_message(message, cats) + when "7" || "quit" puts "Thank you for using the Ada Slack CLI" exit end puts "What would you like to do? Please select an option" - puts "1. List Channels\n2. List Users\n3. Select Channel\n4. Select User\n5. List Details\n6. Quit" + puts "1. List Channels\n2. List Users\n3. Select Channel\n4. Select User\n5. List Details\n6. Send Message\n7. Quit" user_selection = gets.chomp.downcase end end diff --git a/lib/workspace.rb b/lib/workspace.rb index 618c439b..11e569c8 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,5 +1,6 @@ require "dotenv" require "httparty" +require "uri" Dotenv.load require_relative "recipient" @@ -56,8 +57,40 @@ def list_details_on_current_recipient raise ArgumentError, "No recipient is currently selected." end @current_recipient.load_details + ap @current_recipient end + def send_message(message, cats) + id = @current_recipient.id + # this whole method probably needs gentle refactoring + # this one prints cats with the text! + if cats == "yes" + cat_block = '[{"type": "image", "alt_text": "cat", "image_url": "https://cataas.com/cat/says/' + URI.encode(message) + '"}]' + new_message = HTTParty.post(@message_url, + headers: { "Content-Type" => "application/x-www-form-urlencoded" }, + body: { + "token" => TOKEN, + "channel" => id, + "text" => message, + "blocks" => cat_block + } + ) + # this one prints regular text! + else + new_message = HTTParty.post(@message_url, + headers: { "Content-Type" => "application/x-www-form-urlencoded" }, + body: { + "token" => TOKEN, + "channel" => id, + "text" => message + } + ) + end + + new_message + end + + # maaaaaaaaaybe we don't need these methods? we'll see!! # def select_user(id) # User.set_as_recipient(id) # end From 062a3fae28f2af1a2c82e2d6b795a536854bc06a Mon Sep 17 00:00:00 2001 From: "m.dove@live.com" <“m.dove@live.com”> Date: Fri, 13 Sep 2019 13:27:55 -0700 Subject: [PATCH 8/9] Added working tests. Increasing coverage --- lib/recipient.rb | 9 ++-- lib/slack.rb | 10 ++-- lib/workspace.rb | 79 ++++++++++++++++-------------- test/channel_test.rb | 13 +++-- test/recipient_test.rb | 15 ++++++ test/user_test.rb | 15 ++++++ test/workspace_test.rb | 107 +++++++++++++++++++++++++++++------------ 7 files changed, 167 insertions(+), 81 deletions(-) diff --git a/lib/recipient.rb b/lib/recipient.rb index 4e487e80..03d3b072 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -4,25 +4,24 @@ class Recipient attr_reader :id, :name - + def initialize(id, name) @id = id @name = name end - + def self.load_all(url, token) recipients = HTTParty.get(url, query: { token: token }) - all_recipients = recipients.map do |recipient| + all_recipients = recipients["members"].map do |recipient| recipient = new(recipient["id"], recipient["name"]) end return all_recipients end - + def load_details # inherited by Channel & User puts "#{self.class} Details" puts "ID: #{self.id}" puts "Name: #{self.name}" end - end diff --git a/lib/slack.rb b/lib/slack.rb index 9e64e2eb..88a8f26f 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -25,14 +25,14 @@ def main puts "select_channel" selection = gets.chomp # make a method to validate that the input is a channel? - - puts workspace.find_by_id_or_name(workspace.channels, selection) + + puts workspace.find_by_id_or_name("channel", selection) when "4" || "select user" puts "select_user" selection = gets.chomp # make a method to validate that the input is a user? - - puts workspace.find_by_id_or_name(workspace.users, selection) + + puts workspace.find_by_id_or_name("user", selection) when "5" || "details" puts "list_details_on_current_recipient" workspace.list_details_on_current_recipient @@ -42,7 +42,7 @@ def main cats = gets.chomp.downcase puts "Please enter your message:" message = gets.chomp - puts workspace.send_message(message, cats) + puts workspace.send_message(message, cats) when "7" || "quit" puts "Thank you for using the Ada Slack CLI" exit diff --git a/lib/workspace.rb b/lib/workspace.rb index 11e569c8..abd85fac 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -9,9 +9,9 @@ class Workspace TOKEN = ENV["SLACK_TOKEN"] - - attr_accessor :users, :channels, :current_recipient #added these in order to access/update them; added current_recipient to hold the currently selected user or channel - + + attr_accessor :users, :channels, :current_recipient, :user_url, :channel_url, :message_url #added these in order to access/update them; added current_recipient to hold the currently selected user or channel + def initialize @channel_url = "https://slack.com/api/conversations.list" @user_url = "https://slack.com/api/users.list" @@ -21,28 +21,37 @@ def initialize @channels = get_channels @current_recipient = nil end - + def get_users User.load_all(@user_url, TOKEN) end - + def get_channels Channel.load_all(@channel_url, TOKEN) end - + def find_by_id_or_name(recipient_type, search_arg) # verifies that the Recipient is either a User or a Channel # might want to move this validation into the slack.rb file - if recipient_type != @users && recipient_type != @channels + if recipient_type.downcase != "user" && recipient_type.downcase != "channel" raise ArgumentError, "Recipient must be either a user or a channel." end - + + # If the recipient_type is a user, we will look in the users list + # Otherwise we'll look in the channels list + recipient_list = [] + if (recipient_type.downcase == "user") + recipient_list = @users + else + recipient_list = @channels + end + # finds the recipient using the search_arg # search_arg could be a name or an id, either way works! - recipient = recipient_type.find do |recipient| + recipient = recipient_list.find do |recipient| recipient.id == search_arg || recipient.name == search_arg end - + # raises arg error if the recipient isn't found by either name or id if recipient == nil raise ArgumentError, "Recipient not found." @@ -50,46 +59,44 @@ def find_by_id_or_name(recipient_type, search_arg) @current_recipient = recipient end end - + # 'load_details' is a method in Recipient def list_details_on_current_recipient if @current_recipient == nil raise ArgumentError, "No recipient is currently selected." end @current_recipient.load_details - ap @current_recipient + p @current_recipient end - + def send_message(message, cats) id = @current_recipient.id - # this whole method probably needs gentle refactoring + # this whole method probably needs gentle refactoring # this one prints cats with the text! if cats == "yes" cat_block = '[{"type": "image", "alt_text": "cat", "image_url": "https://cataas.com/cat/says/' + URI.encode(message) + '"}]' - new_message = HTTParty.post(@message_url, - headers: { "Content-Type" => "application/x-www-form-urlencoded" }, - body: { - "token" => TOKEN, - "channel" => id, - "text" => message, - "blocks" => cat_block - } - ) - # this one prints regular text! + new_message = HTTParty.post(@message_url, + headers: { "Content-Type" => "application/x-www-form-urlencoded" }, + body: { + "token" => TOKEN, + "channel" => id, + "text" => message, + "blocks" => cat_block, + }) + # this one prints regular text! else - new_message = HTTParty.post(@message_url, - headers: { "Content-Type" => "application/x-www-form-urlencoded" }, - body: { - "token" => TOKEN, - "channel" => id, - "text" => message - } - ) + new_message = HTTParty.post(@message_url, + headers: { "Content-Type" => "application/x-www-form-urlencoded" }, + body: { + "token" => TOKEN, + "channel" => id, + "text" => message, + }) end - + new_message end - + # maaaaaaaaaybe we don't need these methods? we'll see!! # def select_user(id) # User.set_as_recipient(id) @@ -97,7 +104,7 @@ def send_message(message, cats) # def select_channel(id) # Channel.set_as_recipient(id) # end - + def list_users user_list = HTTParty.get(@user_url, query: { token: TOKEN }) user_list["members"].map do |user| @@ -106,7 +113,7 @@ def list_users Name: #{real_name = user["real_name"]}" end end - + def list_channels channel_list = HTTParty.get(@channel_url, query: { token: TOKEN }) channel_list["channels"].map do |channel| diff --git a/test/channel_test.rb b/test/channel_test.rb index 65b1b00c..9c9add93 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -1,9 +1,14 @@ require_relative "test_helper" describe "channel" do - describe "instantiate a channel" do - before do - @channel = Channel.new("https://slack.com/api/conversations.list", ENV["SLACK_TOKEN"]) - Channel.load_all + before do + VCR.use_cassette("recipient_test") do + @workspace = Workspace.new + @channels = Channel.load_all(@workspace.channel_url, ENV["SLACK_TOKEN"]) + end + end + describe "self.load_all" do + it "loads ids and names of all channels into an array" do + expect @channels.must_be_instance_of Array end end end diff --git a/test/recipient_test.rb b/test/recipient_test.rb index e69de29b..0ac46c61 100644 --- a/test/recipient_test.rb +++ b/test/recipient_test.rb @@ -0,0 +1,15 @@ +require_relative "test_helper" + +describe "recipient" do + before do + VCR.use_cassette("recipient_test") do + @workspace = Workspace.new + @recipients = Recipient.load_all(@workspace.user_url, ENV["SLACK_TOKEN"]) + end + end + describe "self.load_all" do + it "loads ids and names of all recipients into an array" do + expect @recipients.must_be_instance_of Array + end + end +end diff --git a/test/user_test.rb b/test/user_test.rb index e69de29b..3483cf10 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -0,0 +1,15 @@ +require_relative "test_helper" + +describe "user" do + before do + VCR.use_cassette("recipient_test") do + @workspace = Workspace.new + @user = @workspace.users[1] + end + end + describe "load_details" do + it "returns an accurate username" do + expect @user.load_details.must_equal nil + end + end +end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index b54287e7..d1270bb8 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -50,57 +50,102 @@ end end - describe "find_by_id" do + describe "error cases" do before do - VCR.use_cassette("workspace_find_by_id") do + VCR.use_cassette("workspace_find_channel_by_id_error") do @workspace = Workspace.new end end - it "retrieves the correct recipie t matching the id" do - user = nil - - user = @workspace.find_by_id("UMURH3TBM") + it "attempts to find a channel whose id does not exist" do + expect { @workspace.find_by_id_or_name("channel", "IDONTEXIST") }.must_raise ArgumentError + end - expect(user).must_be_instance_of User - expect(user.username).must_equal "m.dove" + it "attempts to find a user whose id does not exist" do + expect { @workspace.find_by_id_or_name("user", "IDONTEXIST") }.must_raise ArgumentError end end + describe "instantiate a channel" do + before do + @channel = Channel.new("https://slack.com/api/conversations.list", ENV["SLACK_TOKEN"]) + Channel.load_all + end + end + describe "find_by_id_or_name" do + before do + VCR.use_cassette("channel_find_by_id_or_name") do + @workspace = Workspace.new + end + end - # describe "find_channel_by_id" do - # before do - # VCR.use_cassette("workspace_find_channel_by_id") do - # @workspace = Workspace.new - # end - # end - - # it "retrieves the correct channel matching the id" do - # channel = nil + it "retrieves the correct channel matching the id" do + channel = nil - # channel = @workspace.find_channel_by_id("CN85SCME3") + channel = @workspace.find_by_id_or_name("channel", "CN85SCME3") - # expect(channel).must_be_instance_of Channel - # expect(channel.name).must_equal "slack-cli" - # end - # end + expect(channel).must_be_instance_of Channel + expect(channel.name).must_equal "slack-cli" + end + end - describe "error cases" do + describe "list_details_on_current_recipient" do before do - VCR.use_cassette("workspace_find_channel_by_id_error") do + VCR.use_cassette("list_details_on_current_recipient") do @workspace = Workspace.new end + end + it "raises an argument error when no receipient is selected" do + expect { @workspace.list_details_on_current_recipient }.must_raise ArgumentError + end + it "gets details on a selected recipient" do + channel = @workspace.find_by_id_or_name("channel", "CN85SCME3") + expect(@workspace.list_details_on_current_recipient).must_be_instance_of Channel + end + end - it "tries to instantiate a recipient object" do - expect { Recipient.load_all("url", "token") }.must_raise ArgumentError + describe "find_by_id_or_name" do + before do + VCR.use_cassette("user_find_by_id_or_name") do + @workspace = Workspace.new end + end + + it "retrieves the correct user matching the id" do + user = nil - it "attempts to find a channel whose id does not exist" do - expect { @workspace.find_channel_by_id("IDONTEXIST") }.must_raise ArgumentError + user = @workspace.find_by_id_or_name("user", "UMURH3TBM") + + expect(user).must_be_instance_of User + expect(user.username).must_equal "m.dove" + end + it "raises an agument error if either a channel or user is not selected" do + expect { @workspace.find_by_id_or_name("otter", "UMURH3TBM") }.must_raise ArgumentError + end + end + describe "send_message" do + before do + VCR.use_cassette("send_message") do + @workspace = Workspace.new + @message_url = @workspace.message_url + @test_message = HTTParty.post(@message_url, + headers: { "Content-Type" => "application/x-www-form-urlencoded" }, + body: { + "token" => ENV["SLACK_TOKEN"], + "channel" => "random", + "text" => "POTTYMOUTH", + }) end end - - it "attempts to find a user whose id does not exist" do - expect { @workspace.find_user_by_id("IDONTEXIST") }.must_raise ArgumentError + it "can send a message with given text" do + expect @test_message["message"]["text"].must_equal "POTTYMOUTH" + end + it "allows for inclusion of a cat_block" do + VCR.use_cassette("send_message") do + @workspace.find_by_id_or_name("channel", "random") + @sent_message = @workspace.send_message("MEOWMEOW", "yes") + end + expect @sent_message["message"]["blocks"][0]["image_url"].must_include "MEOWMEOW" + expect @workspace.current_recipient.name.must_equal "random" end end end From 074a60f35c2a3e0a942794ebc7e59150fcdd8634 Mon Sep 17 00:00:00 2001 From: "m.dove@live.com" <“m.dove@live.com”> Date: Fri, 13 Sep 2019 16:30:56 -0700 Subject: [PATCH 9/9] Added cassettes, added more complete coverage. Edited slack. --- lib/channel.rb | 9 +- lib/recipient.rb | 4 +- lib/slack.rb | 15 +- lib/user.rb | 10 +- lib/workspace.rb | 50 ++- ...ser.yml => channel_find_by_id_or_name.yml} | 95 +++++- .../list_details_on_current_recipient.yml | 157 +++++++++ test/cassettes/recipient_test.yml | 311 ++++++++++++++++++ test/cassettes/send_message.yml | 294 +++++++++++++++++ test/cassettes/user_find_by_id_or_name.yml | 157 +++++++++ .../workspace_find_channel_by_id_error.yml | 157 +++++++++ test/cassettes/workspace_get_users_test.yml | 234 +++++++++++++ .../workspace_list_channels_test.yml | 234 +++++++++++++ test/cassettes/workspace_list_users_test.yml | 234 +++++++++++++ test/channel_test.rb | 13 + test/test_helper.rb | 1 - test/user_test.rb | 16 +- test/workspace_test.rb | 18 +- 18 files changed, 1949 insertions(+), 60 deletions(-) rename test/cassettes/{user.yml => channel_find_by_id_or_name.yml} (56%) create mode 100644 test/cassettes/list_details_on_current_recipient.yml create mode 100644 test/cassettes/recipient_test.yml create mode 100644 test/cassettes/send_message.yml create mode 100644 test/cassettes/user_find_by_id_or_name.yml create mode 100644 test/cassettes/workspace_find_channel_by_id_error.yml create mode 100644 test/cassettes/workspace_get_users_test.yml create mode 100644 test/cassettes/workspace_list_channels_test.yml create mode 100644 test/cassettes/workspace_list_users_test.yml diff --git a/lib/channel.rb b/lib/channel.rb index cbec822c..5148ee04 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -2,14 +2,14 @@ class Channel < Recipient attr_reader :id, :name, :details, :topic, :member_count - + def initialize(id, name, details = "", topic = "", member_count = "") super(id, name) @details = details @topic = topic @member_count = member_count end - + def self.load_all(url, token) recipients = HTTParty.get(url, query: { token: token }) all_recipients = recipients["channels"].map do |recipient| @@ -17,11 +17,10 @@ def self.load_all(url, token) end return all_recipients end - + def load_details # inherits ID & Name from Recipient super - puts "Topic: #{@topic}" - puts "Member Count: #{@member_count}" + return super + "\nTopic: #{@topic}" + "\nMember Count: #{@member_count}" end end diff --git a/lib/recipient.rb b/lib/recipient.rb index 03d3b072..b7c68c4a 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -20,8 +20,6 @@ def self.load_all(url, token) def load_details # inherited by Channel & User - puts "#{self.class} Details" - puts "ID: #{self.id}" - puts "Name: #{self.name}" + return "#{self.class} Details\nID: #{self.id}\nName: #{self.name}" end end diff --git a/lib/slack.rb b/lib/slack.rb index 88a8f26f..09ac7b9e 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -24,14 +24,18 @@ def main when "3" || "select channel" puts "select_channel" selection = gets.chomp - # make a method to validate that the input is a channel? - + while workspace.valid_selection?("channel", selection) == false + puts "Please enter a channel name or id." + selection = gets.chomp + end puts workspace.find_by_id_or_name("channel", selection) when "4" || "select user" puts "select_user" selection = gets.chomp - # make a method to validate that the input is a user? - + while workspace.valid_selection?("user", selection) == false + puts "Please enter a user name or id." + selection = gets.chomp + end puts workspace.find_by_id_or_name("user", selection) when "5" || "details" puts "list_details_on_current_recipient" @@ -46,6 +50,9 @@ def main when "7" || "quit" puts "Thank you for using the Ada Slack CLI" exit + else + puts "Please select a valid input." + user_selection = gets.chomp end puts "What would you like to do? Please select an option" puts "1. List Channels\n2. List Users\n3. Select Channel\n4. Select User\n5. List Details\n6. Send Message\n7. Quit" diff --git a/lib/user.rb b/lib/user.rb index 04910f14..13f03e9e 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -2,13 +2,13 @@ class User < Recipient attr_reader :id, :name, :details, :username - + def initialize(id, name, details = "", username = "") super(id, name) @details = details @username = username end - + def self.load_all(url, token) recipients = HTTParty.get(url, query: { token: token }) all_recipients = recipients["members"].map do |recipient| @@ -16,11 +16,9 @@ def self.load_all(url, token) end return all_recipients end - + def load_details # inherits ID & Name from Recipient - super - puts "Username: #{@username}" + return super + "\nUsername: #{@username}" end - end diff --git a/lib/workspace.rb b/lib/workspace.rb index abd85fac..182251b5 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -10,7 +10,7 @@ class Workspace TOKEN = ENV["SLACK_TOKEN"] - attr_accessor :users, :channels, :current_recipient, :user_url, :channel_url, :message_url #added these in order to access/update them; added current_recipient to hold the currently selected user or channel + attr_accessor :users, :channels, :current_recipient, :user_url, :channel_url, :message_url def initialize @channel_url = "https://slack.com/api/conversations.list" @@ -30,15 +30,20 @@ def get_channels Channel.load_all(@channel_url, TOKEN) end + def valid_selection?(selection_type, selection) + case selection_type + when "channel" + @channels.find { |channel| channel.id == selection || channel.name == selection } ? true : false + when "user" + @users.find { |user| user.id == selection || user.name == selection } ? true : false + end + end + def find_by_id_or_name(recipient_type, search_arg) - # verifies that the Recipient is either a User or a Channel - # might want to move this validation into the slack.rb file if recipient_type.downcase != "user" && recipient_type.downcase != "channel" raise ArgumentError, "Recipient must be either a user or a channel." end - # If the recipient_type is a user, we will look in the users list - # Otherwise we'll look in the channels list recipient_list = [] if (recipient_type.downcase == "user") recipient_list = @users @@ -46,13 +51,10 @@ def find_by_id_or_name(recipient_type, search_arg) recipient_list = @channels end - # finds the recipient using the search_arg - # search_arg could be a name or an id, either way works! recipient = recipient_list.find do |recipient| recipient.id == search_arg || recipient.name == search_arg end - # raises arg error if the recipient isn't found by either name or id if recipient == nil raise ArgumentError, "Recipient not found." else @@ -60,19 +62,17 @@ def find_by_id_or_name(recipient_type, search_arg) end end - # 'load_details' is a method in Recipient def list_details_on_current_recipient if @current_recipient == nil raise ArgumentError, "No recipient is currently selected." + else + @current_recipient.load_details end - @current_recipient.load_details - p @current_recipient + return @current_recipient end def send_message(message, cats) id = @current_recipient.id - # this whole method probably needs gentle refactoring - # this one prints cats with the text! if cats == "yes" cat_block = '[{"type": "image", "alt_text": "cat", "image_url": "https://cataas.com/cat/says/' + URI.encode(message) + '"}]' new_message = HTTParty.post(@message_url, @@ -83,7 +83,6 @@ def send_message(message, cats) "text" => message, "blocks" => cat_block, }) - # this one prints regular text! else new_message = HTTParty.post(@message_url, headers: { "Content-Type" => "application/x-www-form-urlencoded" }, @@ -93,34 +92,25 @@ def send_message(message, cats) "text" => message, }) end - new_message end - # maaaaaaaaaybe we don't need these methods? we'll see!! - # def select_user(id) - # User.set_as_recipient(id) - # end - # def select_channel(id) - # Channel.set_as_recipient(id) - # end - def list_users user_list = HTTParty.get(@user_url, query: { token: TOKEN }) user_list["members"].map do |user| - "ID: #{id = user["id"]} - Username: #{username = user["name"]} - Name: #{real_name = user["real_name"]}" + "ID: #{user["id"]} + Username: #{user["name"]} + Name: #{user["real_name"]}" end end def list_channels channel_list = HTTParty.get(@channel_url, query: { token: TOKEN }) channel_list["channels"].map do |channel| - "ID: #{id = channel["id"]} - Name: #{name = channel["name"]} - Topic: #{topic = channel["topic"]["value"]} - Member Count: #{member_count = channel["num_members"]}" + "ID: #{channel["id"]} + Name: #{channel["name"]} + Topic: #{channel["topic"]["value"]} + Member Count: #{channel["num_members"]}" end end end diff --git a/test/cassettes/user.yml b/test/cassettes/channel_find_by_id_or_name.yml similarity index 56% rename from test/cassettes/user.yml rename to test/cassettes/channel_find_by_id_or_name.yml index a747e43d..62c47011 100644 --- a/test/cassettes/user.yml +++ b/test/cassettes/channel_find_by_id_or_name.yml @@ -21,17 +21,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '915' + - '914' Connection: - keep-alive Date: - - Thu, 12 Sep 2019 03:26:54 GMT + - Fri, 13 Sep 2019 21:53:26 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 16e086a8-d822-4aea-9073-572dfeabf180 + - 06dbd9e2-1cb7-4ed9-8876-c9c98190eda5 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-0t0n + - haproxy-www-o27m X-Cache: - Miss from cloudfront Via: - - 1.1 49cdeca097624936e070b73619df7da9.cloudfront.net (CloudFront) + - 1.1 3a5c7b53ec8bee631ff6043996ffc1ce.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - - SEA19-C1 + - HIO51-C1 X-Amz-Cf-Id: - - 68soQjLfOt6duYh9ApRQ2LHgksG1S4Hin1h29TvBqZLk6KJJR_h23g== + - 6z7Tjvkj0rCoXaJ9PZ7a1XDx86xizO-8q2aJaq2FapX7Beyj6sKGEQ== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -74,7 +74,84 @@ http_interactions: Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey - Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568258814,"response_metadata":{"next_cursor":""}}' + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411606,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Thu, 12 Sep 2019 03:26:54 GMT + recorded_at: Fri, 13 Sep 2019 21:53:26 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:27 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - e16493be-531f-420f-8639-2ec83ae37e7f + 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,groups:read,mpim:read,im:read,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-og2s + X-Cache: + - Miss from cloudfront + Via: + - 1.1 bf3ec4bcb6f4f29d898c3c4e0f95a185.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - kghIH4Tu_IE1xaSeJtnE_UVWZIzg64rB0JUlCr78ewO3_vpxEvoZ2w== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:27 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/list_details_on_current_recipient.yml b/test/cassettes/list_details_on_current_recipient.yml new file mode 100644 index 00000000..49558c58 --- /dev/null +++ b/test/cassettes/list_details_on_current_recipient.yml @@ -0,0 +1,157 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:26 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 0a2e225f-c1ff-4143-8456-fcf3b115153b + 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-sk4y + X-Cache: + - Miss from cloudfront + Via: + - 1.1 b3e015b6529fa35dca94f1f2661af384.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - dViWyG5kqpHxvHBnQL9b9xjocueprumYW_eQC-yENzp3Hyqja0UAPQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411606,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:26 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:26 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 034ce3b9-83c9-4aec-8f97-37e153647b2e + 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,groups:read,mpim:read,im:read,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-xtep + X-Cache: + - Miss from cloudfront + Via: + - 1.1 686ace1321107362da87839adf526fc6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - wkl9XBrCNIzPGslbdNgFy4EZkSbijm4gOl-c9c65hyiNRRjqmsaDdQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:26 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/recipient_test.yml b/test/cassettes/recipient_test.yml new file mode 100644 index 00000000..8803e333 --- /dev/null +++ b/test/cassettes/recipient_test.yml @@ -0,0 +1,311 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:25 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - a16fc0d2-9102-4e93-9b99-fc55c86437a6 + 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-lqa3 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 e8276e704fe9ab202d1f5aa2709d2f93.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - DYHhy_2tTw8BZcuRJ_x7keRRoa0IBcGxPLmMRYbLNKKSeWi9R4pGXQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411605,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:25 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:25 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 40e5c660-70c6-43fb-a92d-27479e85576e + 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,groups:read,mpim:read,im:read,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-sk4y + X-Cache: + - Miss from cloudfront + Via: + - 1.1 43fc53332a866a4c9b5c72cec114706b.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - LHfzZbTS4-qa762XVGhJ9CV6A8_u_6Zb_xWTVboYuI28UYOQ_L4kVA== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:25 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:56:21 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - efa3087b-02a5-412b-972c-799082c54c2e + 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,groups:read,mpim:read,im:read,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-cviw + X-Cache: + - Miss from cloudfront + Via: + - 1.1 05c281b7186067b6c66ca266cdeda2f8.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - sIydc2c6tQGAlPe0-w854vG0mwOx_D6Qh9Jf8YjaGxXeeizNa35j0A== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:56: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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:56:21 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 8811c393-2d94-4d73-9b1b-8de1a426e304 + 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-9agp + X-Cache: + - Miss from cloudfront + Via: + - 1.1 73bd23077f64204bc8f5efea09d16ebd.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - UniKqf62CJlkTs8humGGfkjYIRDHeWXX_QzNbU4EyIIjGH6_-g8ohw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411781,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:56:21 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..a9c58cdb --- /dev/null +++ b/test/cassettes/send_message.yml @@ -0,0 +1,294 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:24 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 0e85e890-fdc2-46a5-87cb-e4611d9c4880 + 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-d0g2 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 48324d3b69a5418ddcbd1f772305eff1.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - I3ueT8yVR3vyfs8gDAxxgBRYHR1EGkin06Dvnoow-JJ8cojeLnwCqw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411604,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:24 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:25 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 4261a6cc-bdf7-4173-be53-0a2a58901273 + 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,groups:read,mpim:read,im:read,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-uw19 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 c3d327d7fba3cf3679ba86e6faf3a795.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - yDPsmwCWA1HkK5IIkUy1pQghWJ5WhU0t9B4RfgENrKgfhog15pXKHQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:25 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=random&text=POTTYMOUTH + 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: + - Fri, 13 Sep 2019 21:56:22 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 8f772d86-e409-49cd-95a8-f1fcb8f430ed + 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-nxmy + X-Cache: + - Miss from cloudfront + Via: + - 1.1 bb14b7a4f45e3e0b1ae5065c59f7826f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - 0VdMA9WaS1gKKAtGiL9r0OW37Zat1iAnv5gjQC1AgUkhaJPctRsekA== + body: + encoding: UTF-8 + string: '{"ok":true,"channel":"CMTGDS4LA","ts":"1568411782.000200","message":{"type":"message","subtype":"bot_message","text":"POTTYMOUTH","ts":"1568411782.000200","username":"Branches + - Macaria - API Project","bot_id":"BN6A90GTS"}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:56:22 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=CMTGDS4LA&text=MEOWMEOW&blocks=%5B%7B%22type%22%3A%20%22image%22%2C%20%22alt_text%22%3A%20%22cat%22%2C%20%22image_url%22%3A%20%22https%3A%2F%2Fcataas.com%2Fcat%2Fsays%2FMEOWMEOW%22%7D%5D + 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: + - Fri, 13 Sep 2019 21:59:11 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 4bad57db-2595-4b12-b30c-667ae017ad56 + 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-dzl1 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 92c8c11d2a0d1554296f15adc76d2e64.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - NvqNG0ymI1CC8wC2LMWb3z_pVo_8bcmoHolQmLNK9xAbtE2brHcnUg== + body: + encoding: UTF-8 + string: '{"ok":true,"channel":"CMTGDS4LA","ts":"1568411952.000300","message":{"type":"message","subtype":"bot_message","text":"MEOWMEOW","ts":"1568411952.000300","username":"Branches + - Macaria - API Project","bot_id":"BN6A90GTS","blocks":[{"type":"image","block_id":"bbj","image_url":"https:\/\/cataas.com\/cat\/says\/MEOWMEOW","alt_text":"cat","fallback":"600x592px + image","image_width":600,"image_height":592,"image_bytes":31597}]}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:59:12 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/user_find_by_id_or_name.yml b/test/cassettes/user_find_by_id_or_name.yml new file mode 100644 index 00000000..f9b2d4be --- /dev/null +++ b/test/cassettes/user_find_by_id_or_name.yml @@ -0,0 +1,157 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:26 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 457117c7-4679-48b5-a786-b981da7eb8f1 + 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-64vz + X-Cache: + - Miss from cloudfront + Via: + - 1.1 c9175050329bc171442756cc6f0e0d88.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - pPK5Qwno1Oz7gNko4uCVD9t-RdbJBV2voErRHGlkhNWydDnRf8likQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411606,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:26 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:26 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - ffeb9a39-0230-4c5b-897d-0c943b4a3917 + 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,groups:read,mpim:read,im:read,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-eluc + X-Cache: + - Miss from cloudfront + Via: + - 1.1 73bd23077f64204bc8f5efea09d16ebd.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - FU5qIMu9eDZXzMTIdQArGRXpLawEor8Hig8vxZxLSfGgWXoka-E5qA== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:26 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace_find_channel_by_id_error.yml b/test/cassettes/workspace_find_channel_by_id_error.yml new file mode 100644 index 00000000..db2b07b9 --- /dev/null +++ b/test/cassettes/workspace_find_channel_by_id_error.yml @@ -0,0 +1,157 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:26 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 15ed9dcc-8407-4955-a650-2120a60e544b + 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-g1op + X-Cache: + - Miss from cloudfront + Via: + - 1.1 6af340edf5d0c2e1a2d1773e9c7a6ecc.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - jXDME1Wl57x52F2TRRrOTe2Oo9cy6u7kml14-boeUWgipC4JdoGInQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411606,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:26 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:26 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 740815b4-1657-408c-b495-f3c364344dfe + 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,groups:read,mpim:read,im:read,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-og2s + X-Cache: + - Miss from cloudfront + Via: + - 1.1 ddc77da3ee14d939006f8adaf09d8aa5.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - q_DWEL6duZ0I3BqWFF9ZUuAgJXIayYFd7lIT1cHZ-gD7G3a26I96lw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:26 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace_get_users_test.yml b/test/cassettes/workspace_get_users_test.yml new file mode 100644 index 00000000..b951543e --- /dev/null +++ b/test/cassettes/workspace_get_users_test.yml @@ -0,0 +1,234 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:27 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 6408aedb-3c0f-44cb-a44e-c379cf8f75d4 + 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-j6j4 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 ceb7b8c925a9435b9b08b23014561fbb.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - srlXJXKAe0Mz7O87UZf_FIkFwYaqsOxTi2VBSnMupXFc2_aFNo6WOw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411607,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:27 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:27 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - d9253797-d1af-4680-a42f-81fb2412127b + 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,groups:read,mpim:read,im:read,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 48b1d9f5c5a47a0b424a9637eb513cee.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - 0EfJcfJAWshE1eplH_SR4w78HbzsGUuXRJHUbnTsbO_Dy6xpiis8gw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:27 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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:56:22 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - d9650336-82c6-4f62-af20-14c822f3e23c + 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-fdpw + X-Cache: + - Miss from cloudfront + Via: + - 1.1 bf747dc419d7840e37c22083d04ecd8e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - WkqnCEQ5gzxpc04OPFqYN9HW6VbKNjcEUkaQPKH33A2p9JEPouLl1A== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411782,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:56:22 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace_list_channels_test.yml b/test/cassettes/workspace_list_channels_test.yml new file mode 100644 index 00000000..965c9a77 --- /dev/null +++ b/test/cassettes/workspace_list_channels_test.yml @@ -0,0 +1,234 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:27 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 66d93f1c-7b79-41f8-822d-5510850d9d7e + 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-sk4y + X-Cache: + - Miss from cloudfront + Via: + - 1.1 c3d327d7fba3cf3679ba86e6faf3a795.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - OolFurlq7D68ifTK0EycGqFPWglzV0Phi2gFv0jn30GkzWoiKGLEdQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411607,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:27 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:27 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 8e134ada-13f1-4d88-bb9a-587045893b66 + 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,groups:read,mpim:read,im:read,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-u9rp + X-Cache: + - Miss from cloudfront + Via: + - 1.1 05c281b7186067b6c66ca266cdeda2f8.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - npNdqSk1f2IJ0cdxrYeEKVNDtyeKERL9IwLmSs42dZHpG-5WnX9wdQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:27 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:56:22 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 610094c4-69ea-42e5-a782-4fb50c1532a0 + 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,groups:read,mpim:read,im:read,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-nvih + X-Cache: + - Miss from cloudfront + Via: + - 1.1 5970fc402458c01688529eb3dab967de.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - zYrgdoQzSEHJm3lkpbuoDPzZC9vPumky5bI1H6WKFlcwQhZb_00K7g== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:56:22 GMT +recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace_list_users_test.yml b/test/cassettes/workspace_list_users_test.yml new file mode 100644 index 00000000..cd7b6c45 --- /dev/null +++ b/test/cassettes/workspace_list_users_test.yml @@ -0,0 +1,234 @@ +--- +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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:25 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 741b3a68-1a1f-4ae8-b914-7be8f91f96f3 + 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-aaa1 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 79f18dd6382f7347397cfbd42c438a75.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - _AHoMPC_e2leZG8dQD1_FtJz3iET6t4CKxFhoGUS4XslvWzx4bt22w== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411605,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:25 GMT +- request: + method: get + uri: https://slack.com/api/conversations.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: + - '607' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:53:25 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - ae063494-c98a-4f42-bed2-944f6f88d04f + 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,groups:read,mpim:read,im:read,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-8m7g + X-Cache: + - Miss from cloudfront + Via: + - 1.1 490c6b39f412c738a30c226f07db749c.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - FnAtNb0AdYUHpu3O8oUjQyK1_HguXIy5acqGkhEPaar9rqP2cM4qpQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTGDS4LA","name":"random","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"random","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMURH3TBM","last_set":1568072432},"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":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CMURH40JX","name":"general","is_channel":true,"is_group":false,"is_im":false,"created":1568072432,"is_archived":false,"is_general":true,"unlinked":0,"name_normalized":"general","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMURH3TBM","last_set":1568072432},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMURH3TBM","last_set":1568072432},"previous_names":[],"num_members":2},{"id":"CN85SCME3","name":"slack-cli","is_channel":true,"is_group":false,"is_im":false,"created":1568072433,"is_archived":false,"is_general":false,"unlinked":0,"name_normalized":"slack-cli","is_shared":false,"parent_conversation":null,"creator":"UMURH3TBM","is_ext_shared":false,"is_org_shared":false,"shared_team_ids":["TN69R3XAL"],"pending_shared":[],"pending_connected_team_ids":[],"is_pending_ext_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":2}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:53:25 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: + - '914' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 21:56:21 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 0a1913da-0bcc-4443-8dd2-828e993e6eeb + 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-g1op + X-Cache: + - Miss from cloudfront + Via: + - 1.1 6bd725b6233f3b787d5f5373be153d66.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - HIO51-C1 + X-Amz-Cf-Id: + - o2JXAwUoUVlGRRB0DtmCCLIIGf1xkp4jz672m2HjYG9M6U_EPwxXZw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN69R3XAL","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":"TN69R3XAL"},"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":"UMURH3TBM","team_id":"TN69R3XAL","name":"m.dove","deleted":false,"color":"9f69e7","real_name":"Mackie + Dove","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Mackie + Dove","real_name_normalized":"Mackie Dove","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"5c5f13b47d78","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_original.jpg","first_name":"Mackie","last_name":"Dove","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754354966469_5c5f13b47d78f68d62aa_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568141455,"has_2fa":false},{"id":"UN5RH5EP6","team_id":"TN69R3XAL","name":"kelseykripp","deleted":false,"color":"e7392d","real_name":"Kelsey + Kripp","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kelsey + Kripp","real_name_normalized":"Kelsey Kripp","display_name":"Kelsey Kripp","display_name_normalized":"Kelsey + Kripp","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"f8aa0156bcd0","image_original":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_original.jpg","image_24":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_24.jpg","image_32":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_32.jpg","image_48":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_48.jpg","image_72":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_72.jpg","image_192":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_192.jpg","image_512":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_512.jpg","image_1024":"https:\/\/avatars.slack-edge.com\/2019-09-09\/754351894768_f8aa0156bcd0e1281338_1024.jpg","status_text_canonical":"","team":"TN69R3XAL","is_custom_image":true},"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":1568074237,"has_2fa":false}],"cache_ts":1568411781,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Fri, 13 Sep 2019 21:56:21 GMT +recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index 9c9add93..5d8655ed 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -6,6 +6,19 @@ @channels = Channel.load_all(@workspace.channel_url, ENV["SLACK_TOKEN"]) end end + describe "initialize" do + before do + @test_channel = Channel.new(id, name, details = "", topic = "", member_count = "") + it "creates an instance of channel" do + expect @test_channel.must_be_instance_of Channel + end + it "responds to variable names" do #we got this idea from Amal & Julia + [:id, :name, :details, :topic, :member_count].each do |variable| + expect(@test_channel).must_respond_to variable + end + end + end + end describe "self.load_all" do it "loads ids and names of all channels into an array" do expect @channels.must_be_instance_of Array diff --git a/test/test_helper.rb b/test/test_helper.rb index 9952a3b6..d1efe387 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -25,7 +25,6 @@ end require_relative "../lib/workspace" -require_relative "../lib/slack" require_relative "../lib/user" require_relative "../lib/channel" require_relative "../lib/recipient" diff --git a/test/user_test.rb b/test/user_test.rb index 3483cf10..bbb74562 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -7,9 +7,23 @@ @user = @workspace.users[1] end end + describe "initialize" do + before do + @test_user = User.new(id, name, details = "", username = "") + it "creates an instance of user" do + expect @test_user.must_be_instance_of User + end + it "responds to variable names" do #we got this idea from Amal & Julia + [:id, :name, :details, :username].each do |variable| + expect(@test_user).must_respond_to variable + end + end + end + end describe "load_details" do it "returns an accurate username" do - expect @user.load_details.must_equal nil + expect @user.load_details.must_be_instance_of String + expect @user.load_details.must_include "ID:" end end end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index d1270bb8..6adffe17 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -88,6 +88,22 @@ end end + describe "valid_selection" do + before do + VCR.use_cassette("list_details_on_current_recipient") do + @workspace = Workspace.new + end + end + it "returns true if input is valid" do + expect(@workspace.valid_selection?("channel", "random")).must_equal true + expect(@workspace.valid_selection?("user", "Slackbot")).must_equal true + end + it "returns false if input is invalid" do + expect(@workspace.valid_selection?("channel", "nothing")).must_equal false + expect(@workspace.valid_selection?("user", "nobody")).must_equal false + end + end + describe "list_details_on_current_recipient" do before do VCR.use_cassette("list_details_on_current_recipient") do @@ -98,7 +114,7 @@ expect { @workspace.list_details_on_current_recipient }.must_raise ArgumentError end it "gets details on a selected recipient" do - channel = @workspace.find_by_id_or_name("channel", "CN85SCME3") + @workspace.find_by_id_or_name("channel", "CN85SCME3") expect(@workspace.list_details_on_current_recipient).must_be_instance_of Channel end end