From 3ef7e84d18f5f98d54f3567873887291f888e655 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 13:50:38 -0700 Subject: [PATCH 01/23] verified auth setup --- lib/slack.rb | 5 ++++- lib/verification.rb | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 lib/verification.rb diff --git a/lib/slack.rb b/lib/slack.rb index 960cf2f7..dee09ed9 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,4 +1,7 @@ #!/usr/bin/env ruby +require "httparty" +require "dotenv" +require "awesome_print" def main puts "Welcome to the Ada Slack CLI!" @@ -8,4 +11,4 @@ def main 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/verification.rb b/lib/verification.rb new file mode 100644 index 00000000..0bee7a29 --- /dev/null +++ b/lib/verification.rb @@ -0,0 +1,20 @@ +require "httparty" +require "dotenv" +require "awesome_print" + +Dotenv.load + +url = "https://slack.com/api/channels.list" +query_parameters = { + token: ENV["SLACK_TOKEN"], +} + +# channel_names = +# puts query_parameters +response = HTTParty.get(url, query: query_parameters) + +# Loops through the results and prints name of each channel +response["channels"].each do |channel| + ap channel["name"] +end +# ap response["channels"][1]["name"] From 90a85d1018296ab8fcff62927a4be8ac4541d238 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 14:15:53 -0700 Subject: [PATCH 02/23] created classes & started building channels class --- lib/channel.rb | 38 ++++++++++++++++++++++++++++++++++++++ lib/recipient.rb | 28 ++++++++++++++++++++++++++++ lib/user.rb | 16 ++++++++++++++++ lib/workspace.rb | 23 +++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 lib/channel.rb create mode 100644 lib/recipient.rb create mode 100644 lib/user.rb create mode 100644 lib/workspace.rb diff --git a/lib/channel.rb b/lib/channel.rb new file mode 100644 index 00000000..f1dd2e4c --- /dev/null +++ b/lib/channel.rb @@ -0,0 +1,38 @@ +require "httparty" +require "dotenv" +require "awesome_print" + +Dotenv.load + +require_relative "recipient" + +module Slack + class Channel < Recipient + attr_reader :topic, :member_count + + def initialize + super(name, slack_id) + @topic = topic + @member_count = member_count + end + + def self.list + url = "https://slack.com/api/channels.list" + query_parameters = { + token: ENV["SLACK_TOKEN"], + } + response = Channel.get(url, query_parameters) + channels = [] + + response["channels"].each do |channel| + name = channel["name"] + slack_id = channel["id"] + topic = channel["topic"]["value"] + member_count = channel["members"].length + end + end + + def details + end + end +end diff --git a/lib/recipient.rb b/lib/recipient.rb new file mode 100644 index 00000000..973f3805 --- /dev/null +++ b/lib/recipient.rb @@ -0,0 +1,28 @@ +require "httparty" +require "dotenv" + +module Slack + class Recipient + attr_reader :name, :slack_id + + def initialize + @name = name + @slack_id = slack_id + end + + def self.get(url, params) + return HTTParty.get(url, params) + end + + def send_message(message) + end + + private + + def self.list + end + + def details + end + end +end diff --git a/lib/user.rb b/lib/user.rb new file mode 100644 index 00000000..27dec4a2 --- /dev/null +++ b/lib/user.rb @@ -0,0 +1,16 @@ +require_relative "recipient" + +module Slack + class User < Recipient + def initialize + super(name, slack_id) + @real_name = real_name + end + + def self.list + end + + def details + end + end +end diff --git a/lib/workspace.rb b/lib/workspace.rb new file mode 100644 index 00000000..15676eb1 --- /dev/null +++ b/lib/workspace.rb @@ -0,0 +1,23 @@ +module Slack + class Workspace + attr_reader :users, :channels, :selected + + def initialize + @users = users + @channels = channels + @selected = selected + end + + def select_channel + end + + def select_user + end + + def show_details + end + + def send_message + end + end +end From 0431360447f0ba34977c903a13d2deb335063cea Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 15:42:49 -0700 Subject: [PATCH 03/23] we created our Channels.list method & created a test that passes --- lib/channel.rb | 13 ++- lib/recipient.rb | 2 +- lib/slack.rb | 15 ++++ lib/verification.rb | 12 ++- test/cassettes/channels_list.yml | 148 +++++++++++++++++++++++++++++++ test/channel_test.rb | 16 ++++ test/test_helper.rb | 29 ++++-- 7 files changed, 218 insertions(+), 17 deletions(-) create mode 100644 test/cassettes/channels_list.yml create mode 100644 test/channel_test.rb diff --git a/lib/channel.rb b/lib/channel.rb index f1dd2e4c..5ff23b01 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -21,15 +21,14 @@ def self.list query_parameters = { token: ENV["SLACK_TOKEN"], } - response = Channel.get(url, query_parameters) - channels = [] - + response = Channel.get(url, query: query_parameters) + channels_array = [] + puts response.code response["channels"].each do |channel| - name = channel["name"] - slack_id = channel["id"] - topic = channel["topic"]["value"] - member_count = channel["members"].length + channel_hash = { "name" => channel["name"], "slack id" => channel["id"], "topic" => channel["topic"]["value"], "member count" => channel["members"].length } + channels_array << channel_hash end + return channels_array end def details diff --git a/lib/recipient.rb b/lib/recipient.rb index 973f3805..bb62e5b8 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -5,7 +5,7 @@ module Slack class Recipient attr_reader :name, :slack_id - def initialize + def initialize(name:, slack_id:) @name = name @slack_id = slack_id end diff --git a/lib/slack.rb b/lib/slack.rb index dee09ed9..290f4dc9 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -2,10 +2,25 @@ require "httparty" require "dotenv" require "awesome_print" +require "table_print" def main puts "Welcome to the Ada Slack CLI!" + puts "Please select an option: + -list users + -list channels + -quit" + + input = gets.chomp.downcase + + case input + when "list users" + when "list channels" + Slack::Channel.list + when "quit" + break + end # TODO project puts "Thank you for using the Ada Slack CLI" diff --git a/lib/verification.rb b/lib/verification.rb index 0bee7a29..051779f5 100644 --- a/lib/verification.rb +++ b/lib/verification.rb @@ -14,7 +14,15 @@ response = HTTParty.get(url, query: query_parameters) # Loops through the results and prints name of each channel +# response["channels"].each do |channel| +# ap channel["name"] +# end +# ap response["channels"][1]["name"] + +# response["channels"].each do |channel| +# ap channel["members"].length +# end + response["channels"].each do |channel| - ap channel["name"] + ap channel end -# ap response["channels"][1]["name"] diff --git a/test/cassettes/channels_list.yml b/test/cassettes/channels_list.yml new file mode 100644 index 00000000..c7e930e1 --- /dev/null +++ b/test/cassettes/channels_list.yml @@ -0,0 +1,148 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/channels.list + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '53' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:22:35 GMT + Server: + - Apache + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + X-Slack-Req-Id: + - 748c7e78-f5b6-4210-ae06-17fd88b526be + X-Xss-Protection: + - '0' + X-Content-Type-Options: + - nosniff + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-4bmp + X-Cache: + - Miss from cloudfront + Via: + - 1.1 995664ee945c06fc706b5cb8e0e650dc.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - daH44ao5BgHMunAMatP-yBDwCGHuD1OahvjCT-FS0V9ljo8Wzvihiw== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"not_authed"}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:22:35 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '809' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:28:51 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 6300526b-693b-4988-89aa-7efb7ff0cad6 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-nvih + X-Cache: + - Miss from cloudfront + Via: + - 1.1 4d8620b80ebe37d366388e117039aa8e.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - u3aQwaOkBbi2f2kEV2hjDGfWtIB6RqHvc0kfel2N0jS0uLPCWIy7pg== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTG8GHKL","name":"apis","is_channel":true,"created":1568071960,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"apis","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69TR3N1","UN85KFVNK"],"topic":{"value":"Testing + location for APIs.","creator":"UN69TR3N1","last_set":1568151873},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CMURA7JFM","name":"random","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN85KFVNK","last_set":1568071832},"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":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN03170U9","name":"memes","is_channel":true,"created":1568090675,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"memes","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"all + the memes","creator":"UN69TR3N1","last_set":1568151900},"purpose":{"value":"we + need them","creator":"UN85KFVNK","last_set":1568090676},"previous_names":[],"num_members":5},{"id":"CN69J7LQG","name":"general","is_channel":true,"created":1568071832,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN85KFVNK","last_set":1568071832},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN759T0MA","name":"fuzzy_bunnies","is_channel":true,"created":1568147657,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"fuzzy_bunnies","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Adorable + rabbits","creator":"UN69TR3N1","last_set":1568151886},"purpose":{"value":"For + photos and conversation about fuzzy bunnies.","creator":"UN69SEW21","last_set":1568147658},"previous_names":[],"num_members":6},{"id":"CN85KGEJ3","name":"slack-cli","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"CLI","creator":"UN69TR3N1","last_set":1568151925},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:28:51 GMT +recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb new file mode 100644 index 00000000..c819f48a --- /dev/null +++ b/test/channel_test.rb @@ -0,0 +1,16 @@ +require_relative "test_helper" + +describe "Channel" do + describe "Channel.list method" do + it "will return a list of channels" do + VCR.use_cassette("channels_list") do + @channel_array = Slack::Channel.list + end + + expect(@channel_array[0]["name"]).must_be_instance_of String + expect(@channel_array[0]["slack id"]).must_be_instance_of String + expect(@channel_array[0]["topic"]).must_be_instance_of String + expect(@channel_array[0]["member count"]).must_be_instance_of Integer + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 90aeb408..71907cdf 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,17 +1,32 @@ -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 "vcr" +require "dotenv" +require "webmock/minitest" Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new +require_relative "../lib/channel.rb" +require_relative "../lib/user.rb" +require_relative "../lib/recipient.rb" +require_relative "../lib/workspace.rb" + VCR.configure do |config| config.cassette_library_dir = "test/cassettes" config.hook_into :webmock + config.default_cassette_options = { + :record => :new_episodes, # record new data when we don't have it yet + :match_requests_on => [:method, :uri, :body], # The http method, URI and body of a request all need to match + } + # Don't leave our token lying around in a cassette file. + config.filter_sensitive_data("") do + ENV["SLACK_TOKEN"] + end end From dc18ee0e9e722b5eca01fb1a71442374651af46c Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 16:26:08 -0700 Subject: [PATCH 04/23] created User.list method and added tests --- lib/channel.rb | 2 +- lib/slack.rb | 33 ++++++++----- lib/user.rb | 17 +++++++ test/cassettes/users_list.yml | 88 +++++++++++++++++++++++++++++++++++ test/user_test.rb | 15 ++++++ 5 files changed, 142 insertions(+), 13 deletions(-) create mode 100644 test/cassettes/users_list.yml create mode 100644 test/user_test.rb diff --git a/lib/channel.rb b/lib/channel.rb index 5ff23b01..3f675c2f 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -23,7 +23,7 @@ def self.list } response = Channel.get(url, query: query_parameters) channels_array = [] - puts response.code + response["channels"].each do |channel| channel_hash = { "name" => channel["name"], "slack id" => channel["id"], "topic" => channel["topic"]["value"], "member count" => channel["members"].length } channels_array << channel_hash diff --git a/lib/slack.rb b/lib/slack.rb index 290f4dc9..38d53a35 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -3,23 +3,32 @@ require "dotenv" require "awesome_print" require "table_print" +require_relative "channel" +require_relative "user" +require_relative "workspace" +require_relative "recipient" def main puts "Welcome to the Ada Slack CLI!" - puts "Please select an option: - -list users - -list channels - -quit" + input = "" + until input == "quit" + puts "Please select an option: + -list users + -list channels + -quit" + input = gets.chomp.downcase - input = gets.chomp.downcase - - case input - when "list users" - when "list channels" - Slack::Channel.list - when "quit" - break + case input + when "list users" + user_array = Slack::User.list + tp user_array + when "list channels" + channel_array = Slack::Channel.list + tp channel_array + when "quit" + exit + end end # TODO project diff --git a/lib/user.rb b/lib/user.rb index 27dec4a2..7de59d1f 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -1,3 +1,9 @@ +require "httparty" +require "dotenv" +require "awesome_print" + +Dotenv.load + require_relative "recipient" module Slack @@ -8,6 +14,17 @@ def initialize end def self.list + url = "https://slack.com/api/users.list" + query_parameters = { + token: ENV["SLACK_TOKEN"], + } + response = User.get(url, query: query_parameters) + users_array = [] + response["members"].each do |member| + user_hash = { "real name" => member["real_name"], "user name" => member["name"], "slack id" => member["id"] } + users_array << user_hash + end + return users_array end def details diff --git a/test/cassettes/users_list.yml b/test/cassettes/users_list.yml new file mode 100644 index 00000000..3b94875c --- /dev/null +++ b/test/cassettes/users_list.yml @@ -0,0 +1,88 @@ +--- +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: + - '1587' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 23:18:51 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 56349c03-26e7-456c-9252-f2e443aebe59 + 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-ft0z + X-Cache: + - Miss from cloudfront + Via: + - 1.1 ef6538ee7be7b17c84d06edb0f4c0a1a.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - Z5yt3akdffyJzwY_X9ECurOagOefjtANj3ZK10uAOCy5XRBUv7bNiA== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMTG7023U","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":"TMTG7023U"},"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":"UMTG87PC2","team_id":"TMTG7023U","name":"nickyjinchoi","deleted":false,"color":"674b1b","real_name":"Nicky + Choi","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Nicky + Choi","real_name_normalized":"Nicky Choi","display_name":"Nicky Choi","display_name_normalized":"Nicky + Choi","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g6e33044e4c8","image_24":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071993,"has_2fa":false},{"id":"UN69SEW21","team_id":"TMTG7023U","name":"idhallie","deleted":false,"color":"e7392d","real_name":"Hallie + Johnson","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Hallie + Johnson","real_name_normalized":"Hallie Johnson","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23bc7b83db4","image_24":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072412},{"id":"UN69SF69K","team_id":"TMTG7023U","name":"yitgop.yyhxox","deleted":false,"color":"3c989f","real_name":"Yitgop + Y.","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Yitgop + Y.","real_name_normalized":"Yitgop Y.","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb749eeae508","image_24":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072069},{"id":"UN69TR3N1","team_id":"TMTG7023U","name":"elizabethjnorthrop","deleted":false,"color":"e0a729","real_name":"Elizabeth + Northrop","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Elizabeth + Northrop","real_name_normalized":"Elizabeth Northrop","display_name":"Elizabeth + Northrop","display_name_normalized":"Elizabeth Northrop","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g555bff2ee78","image_24":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072090},{"id":"UN85KFVNK","team_id":"TMTG7023U","name":"emilyvomacka","deleted":false,"color":"9f69e7","real_name":"Emily + V","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Emily + V","real_name_normalized":"Emily V","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g319432559c3","first_name":"Emily","last_name":"V","image_24":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568090599},{"id":"UN85LNJMV","team_id":"TMTG7023U","name":"janicehuang","deleted":false,"color":"4bbe2e","real_name":"janice","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"janice","real_name_normalized":"janice","display_name":"janice","display_name_normalized":"janice","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g73010028c3d","image_24":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071984},{"id":"UN85LQ0HM","team_id":"TMTG7023U","name":"elizabethjnorthrup","deleted":true,"profile":{"title":"","phone":"","skype":"","real_name":"elizabethjnorthrup","real_name_normalized":"elizabethjnorthrup","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g0b2f1d21275","first_name":"","last_name":"","image_24":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-512.png","status_text_canonical":"","team":"TMTG7023U"},"is_bot":false,"is_app_user":false,"updated":1568072109,"is_invited_user":true}],"cache_ts":1568157531,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 23:18:51 GMT +recorded_with: VCR 5.0.0 diff --git a/test/user_test.rb b/test/user_test.rb new file mode 100644 index 00000000..806249b8 --- /dev/null +++ b/test/user_test.rb @@ -0,0 +1,15 @@ +require_relative "test_helper" + +describe "User" do + describe "User.list method" do + it "will return a list of users" do + VCR.use_cassette("users_list") do + @user_array = Slack::User.list + end + + expect(@user_array[0]["real name"]).must_be_instance_of String + expect(@user_array[0]["user name"]).must_be_instance_of String + expect(@user_array[0]["slack id"]).must_be_instance_of String + end + end +end From 2729dff68ce79f0a93853cbd703608d1500575b7 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 18:00:53 -0700 Subject: [PATCH 05/23] started on creating 3 methods for Workspace class --- lib/channel.rb | 2 +- lib/recipient.rb | 2 ++ lib/user.rb | 2 +- lib/workspace.rb | 7 +++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/channel.rb b/lib/channel.rb index 3f675c2f..b98f38b5 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -10,7 +10,7 @@ module Slack class Channel < Recipient attr_reader :topic, :member_count - def initialize + def initialize(name:, slack_id:) super(name, slack_id) @topic = topic @member_count = member_count diff --git a/lib/recipient.rb b/lib/recipient.rb index bb62e5b8..2a5c5b14 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -20,9 +20,11 @@ def send_message(message) private def self.list + raise NotImplementedError, "Implement me in a child class!" end def details + raise NotImplementedError, "Implement me in a child class!" end end end diff --git a/lib/user.rb b/lib/user.rb index 7de59d1f..9e276ef1 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -8,7 +8,7 @@ module Slack class User < Recipient - def initialize + def initialize(name:, slack_id:) super(name, slack_id) @real_name = real_name end diff --git a/lib/workspace.rb b/lib/workspace.rb index 15676eb1..d3d02c8c 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,3 +1,7 @@ +require_relative "user" +require_relative "channel" +require_relative "recipient" + module Slack class Workspace attr_reader :users, :channels, :selected @@ -12,6 +16,9 @@ def select_channel end def select_user + user_list = Slack::User.list + user_list.each do |user| + end end def show_details From 917078434cb45efa0501bd69f439f5f9519ff1ad Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 18:01:18 -0700 Subject: [PATCH 06/23] added DS_Store --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8d6a243f..cdf7f804 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,5 @@ build-iPhoneSimulator/ # Ignore cassette files /specs/cassettes/ + +.DS_Store From 9fed5d3caaf5ca944e1dfe3507df4b388b0b5629 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 18:01:35 -0700 Subject: [PATCH 07/23] Created User objects in Workspace initialize --- lib/slack.rb | 3 +++ lib/user.rb | 6 ++++-- lib/workspace.rb | 8 +++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 38d53a35..caebbbaf 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -11,6 +11,8 @@ def main puts "Welcome to the Ada Slack CLI!" + workspace = Slack::Workspace.new + input = "" until input == "quit" puts "Please select an option: @@ -26,6 +28,7 @@ def main when "list channels" channel_array = Slack::Channel.list tp channel_array + when "select user" when "quit" exit end diff --git a/lib/user.rb b/lib/user.rb index 9e276ef1..1606e406 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -8,8 +8,10 @@ module Slack class User < Recipient - def initialize(name:, slack_id:) - super(name, slack_id) + attr_reader :name, :real_name, :slack_id + + def initialize(name:, slack_id:, real_name:) + super(name: name, slack_id: slack_id) @real_name = real_name end diff --git a/lib/workspace.rb b/lib/workspace.rb index d3d02c8c..dab826de 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -7,9 +7,11 @@ class Workspace attr_reader :users, :channels, :selected def initialize - @users = users - @channels = channels - @selected = selected + @users = Slack::User.list.map do |user_obj| + Slack::User.new(name: user_obj["user name"], slack_id: user_obj["slack id"], real_name: user_obj["real name"]) + end + @channels = nil + @selected = nil end def select_channel From 6cc23559f14ed4ddd0c2d6688c231e600f0da6a2 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 21:42:53 -0700 Subject: [PATCH 08/23] created select_user method --- lib/slack.rb | 8 ++++++++ lib/workspace.rb | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index caebbbaf..1add4e87 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -18,6 +18,7 @@ def main puts "Please select an option: -list users -list channels + -select user -quit" input = gets.chomp.downcase @@ -29,6 +30,13 @@ def main channel_array = Slack::Channel.list tp channel_array when "select user" + puts "Enter a username or slack id: " + identifier = gets.chomp + begin + workspace.select_user(identifier) + rescue + puts "We couldn't find this user!" + end when "quit" exit end diff --git a/lib/workspace.rb b/lib/workspace.rb index dab826de..de2087fc 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -17,10 +17,20 @@ def initialize def select_channel end - def select_user - user_list = Slack::User.list - user_list.each do |user| + def select_user(identifier) + @users.each do |user| + # if user.name == identifier || + # @selected = user + # return + # elsif user.slack_id == identifier + # @selected = user + # return + if [user.name, user.slack_id].include?(identifier) + @selected = user + return + end end + raise StandardError, "This user does not exist" end def show_details From 00b51ceb9c3d7c9f3727891cf3bbae492b2c5936 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 21:43:41 -0700 Subject: [PATCH 09/23] added additional params for Channel init method --- lib/channel.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/channel.rb b/lib/channel.rb index b98f38b5..9e664fbd 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -10,7 +10,7 @@ module Slack class Channel < Recipient attr_reader :topic, :member_count - def initialize(name:, slack_id:) + def initialize(name:, slack_id:, topic:, member_count:) super(name, slack_id) @topic = topic @member_count = member_count From 0122cc4abf6062fe5e2d6d44807548f968b01b0c Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Tue, 10 Sep 2019 21:43:58 -0700 Subject: [PATCH 10/23] added user & workspace tests --- test/cassettes/users_list.yml | 85 +++++++++++++++++++++++++++++++++++ test/user_test.rb | 13 ++++++ test/workspace_test.rb | 24 ++++++++++ 3 files changed, 122 insertions(+) create mode 100644 test/workspace_test.rb diff --git a/test/cassettes/users_list.yml b/test/cassettes/users_list.yml index 3b94875c..fdb0b01b 100644 --- a/test/cassettes/users_list.yml +++ b/test/cassettes/users_list.yml @@ -85,4 +85,89 @@ http_interactions: Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"janice","real_name_normalized":"janice","display_name":"janice","display_name_normalized":"janice","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g73010028c3d","image_24":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071984},{"id":"UN85LQ0HM","team_id":"TMTG7023U","name":"elizabethjnorthrup","deleted":true,"profile":{"title":"","phone":"","skype":"","real_name":"elizabethjnorthrup","real_name_normalized":"elizabethjnorthrup","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g0b2f1d21275","first_name":"","last_name":"","image_24":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-512.png","status_text_canonical":"","team":"TMTG7023U"},"is_bot":false,"is_app_user":false,"updated":1568072109,"is_invited_user":true}],"cache_ts":1568157531,"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Tue, 10 Sep 2019 23:18:51 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: + - '1587' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 01:56:05 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 2dc6ec55-f170-4d8e-915b-86e7be3f9603 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - users:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-bd9x + X-Cache: + - Miss from cloudfront + Via: + - 1.1 174acb08636ac7d9e9a778bbf1bcbc53.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - hKEOc_TYJh4nbJmWdbcXnmfUQ-Zz9FsWkaKXoKstPR7-Sn0Uz8PWkg== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMTG7023U","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":"TMTG7023U"},"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":"UMTG87PC2","team_id":"TMTG7023U","name":"nickyjinchoi","deleted":false,"color":"674b1b","real_name":"Nicky + Choi","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Nicky + Choi","real_name_normalized":"Nicky Choi","display_name":"Nicky Choi","display_name_normalized":"Nicky + Choi","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g6e33044e4c8","image_24":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071993,"has_2fa":false},{"id":"UN69SEW21","team_id":"TMTG7023U","name":"idhallie","deleted":false,"color":"e7392d","real_name":"Hallie + Johnson","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Hallie + Johnson","real_name_normalized":"Hallie Johnson","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23bc7b83db4","image_24":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072412},{"id":"UN69SF69K","team_id":"TMTG7023U","name":"yitgop.yyhxox","deleted":false,"color":"3c989f","real_name":"Yitgop + Y.","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Yitgop + Y.","real_name_normalized":"Yitgop Y.","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb749eeae508","image_24":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072069},{"id":"UN69TR3N1","team_id":"TMTG7023U","name":"elizabethjnorthrop","deleted":false,"color":"e0a729","real_name":"Elizabeth + Northrop","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Elizabeth + Northrop","real_name_normalized":"Elizabeth Northrop","display_name":"Elizabeth + Northrop","display_name_normalized":"Elizabeth Northrop","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g555bff2ee78","image_24":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072090},{"id":"UN85KFVNK","team_id":"TMTG7023U","name":"emilyvomacka","deleted":false,"color":"9f69e7","real_name":"Emily + V","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Emily + V","real_name_normalized":"Emily V","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g319432559c3","first_name":"Emily","last_name":"V","image_24":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568090599},{"id":"UN85LNJMV","team_id":"TMTG7023U","name":"janicehuang","deleted":false,"color":"4bbe2e","real_name":"janice","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"janice","real_name_normalized":"janice","display_name":"janice","display_name_normalized":"janice","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g73010028c3d","image_24":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071984},{"id":"UN85LQ0HM","team_id":"TMTG7023U","name":"elizabethjnorthrup","deleted":true,"profile":{"title":"","phone":"","skype":"","real_name":"elizabethjnorthrup","real_name_normalized":"elizabethjnorthrup","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g0b2f1d21275","first_name":"","last_name":"","image_24":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-512.png","status_text_canonical":"","team":"TMTG7023U"},"is_bot":false,"is_app_user":false,"updated":1568072109,"is_invited_user":true}],"cache_ts":1568166965,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 01:56:05 GMT recorded_with: VCR 5.0.0 diff --git a/test/user_test.rb b/test/user_test.rb index 806249b8..2cd16191 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -1,6 +1,19 @@ require_relative "test_helper" describe "User" do + describe "#initialize" do + before do + @test_user = Slack::User.new(name: "johnk", slack_id: "UB39ALK", real_name: "John") + end + + it "will return the attributes and its data type" do + expect(@test_user.name).must_equal "johnk" + expect(@test_user.slack_id).must_equal "UB39ALK" + expect(@test_user.real_name).must_equal "John" + + expect(@test_user).must_be_instance_of Slack::User + end + end describe "User.list method" do it "will return a list of users" do VCR.use_cassette("users_list") do diff --git a/test/workspace_test.rb b/test/workspace_test.rb new file mode 100644 index 00000000..018846a2 --- /dev/null +++ b/test/workspace_test.rb @@ -0,0 +1,24 @@ +require_relative "test_helper" + +describe "User.list method" do + before do + VCR.use_cassette("users_list") do + @user_array = Slack::User.list + @workspace = Slack::Workspace.new + end + end + + it "users is list of type User" do + expect(@workspace.users.all? { |user| user.is_a?(Slack::User) }).must_equal true + end + + it "will select a user by name" do + @workspace.select_user("slackbot") + expect(@workspace.selected.is_a?(Slack::User)).must_equal true + end + + it "will select a user by slack_id" do + @workspace.select_user("USLACKBOT") + expect(@workspace.selected.is_a?(Slack::User)).must_equal true + end +end From dde4c3a905741540a8bc7181ff28f1ec0b025ea8 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Wed, 11 Sep 2019 13:57:16 -0700 Subject: [PATCH 11/23] added details methods, created select_channel method, and also created SlackApiError class --- lib/channel.rb | 3 +- lib/recipient.rb | 11 +++++ lib/slack.rb | 21 ++++++--- lib/user.rb | 1 + lib/workspace.rb | 25 +++++++++-- test/cassettes/users_list.yml | 85 +++++++++++++++++++++++++++++++++++ 6 files changed, 137 insertions(+), 9 deletions(-) diff --git a/lib/channel.rb b/lib/channel.rb index 9e664fbd..8755e4cf 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -11,7 +11,7 @@ class Channel < Recipient attr_reader :topic, :member_count def initialize(name:, slack_id:, topic:, member_count:) - super(name, slack_id) + super(name: name, slack_id: slack_id) @topic = topic @member_count = member_count end @@ -32,6 +32,7 @@ def self.list end def details + return "\nname: #{name}, slack_id: #{slack_id}, topic: #{topic}, member count: #{member_count}" end end end diff --git a/lib/recipient.rb b/lib/recipient.rb index 2a5c5b14..065da0e7 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -15,6 +15,17 @@ def self.get(url, params) end def send_message(message) + body = { + token: key, + channel: slack_id, + text: message, + } + + response = HTTParty.post(MESSAGE_URL, body: body) + + if response["ok"] != true + raise StandardError, "Invalid request. Error is #{response.code}: #{response.message}" + end end private diff --git a/lib/slack.rb b/lib/slack.rb index 1add4e87..531d0c05 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -15,10 +15,12 @@ def main input = "" until input == "quit" - puts "Please select an option: + puts "\nPlease select an option: -list users -list channels -select user + -select channel + -show details -quit" input = gets.chomp.downcase @@ -30,18 +32,27 @@ def main channel_array = Slack::Channel.list tp channel_array when "select user" - puts "Enter a username or slack id: " + puts "\nEnter a username or slack id: " identifier = gets.chomp begin workspace.select_user(identifier) - rescue - puts "We couldn't find this user!" + rescue SlackApiError + puts "\nWe couldn't find this user!" end + when "select channel" + puts "\nEnter a username or slack id: " + identifier = gets.chomp + begin + workspace.select_channel(identifier) + rescue SlackApiError + puts "\nWe couldn't find the channel!" + end + when "show details" + puts "#{workspace.show_details}" when "quit" exit end end - # TODO project puts "Thank you for using the Ada Slack CLI" end diff --git a/lib/user.rb b/lib/user.rb index 1606e406..f26b5008 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -30,6 +30,7 @@ def self.list end def details + return "\nreal name: #{real_name}, user name: #{name}, slack_id: #{slack_id}" end end end diff --git a/lib/workspace.rb b/lib/workspace.rb index de2087fc..c5e84964 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -2,6 +2,8 @@ require_relative "channel" require_relative "recipient" +class SlackApiError < StandardError; end + module Slack class Workspace attr_reader :users, :channels, :selected @@ -10,11 +12,20 @@ def initialize @users = Slack::User.list.map do |user_obj| Slack::User.new(name: user_obj["user name"], slack_id: user_obj["slack id"], real_name: user_obj["real name"]) end - @channels = nil + @channels = Slack::Channel.list.map do |chan_obj| + Slack::Channel.new(name: chan_obj["name"], slack_id: chan_obj["slack id"], topic: chan_obj["topic"], member_count: chan_obj["member count"]) + end @selected = nil end - def select_channel + def select_channel(identifier) + @channels.each do |channel| + if [channel.name, channel.slack_id].include?(identifier) + @selected = channel + return + end + end + raise SlackApiError, "This channel does not exist" end def select_user(identifier) @@ -30,13 +41,21 @@ def select_user(identifier) return end end - raise StandardError, "This user does not exist" + raise SlackApiError, "This user does not exist" end def show_details + if @selected + @selected.details + end end def send_message + if @selected + @selected.send_message(send_message) + else + return nil + end end end end diff --git a/test/cassettes/users_list.yml b/test/cassettes/users_list.yml index fdb0b01b..c1fa3331 100644 --- a/test/cassettes/users_list.yml +++ b/test/cassettes/users_list.yml @@ -170,4 +170,89 @@ http_interactions: Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"janice","real_name_normalized":"janice","display_name":"janice","display_name_normalized":"janice","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g73010028c3d","image_24":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071984},{"id":"UN85LQ0HM","team_id":"TMTG7023U","name":"elizabethjnorthrup","deleted":true,"profile":{"title":"","phone":"","skype":"","real_name":"elizabethjnorthrup","real_name_normalized":"elizabethjnorthrup","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g0b2f1d21275","first_name":"","last_name":"","image_24":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-512.png","status_text_canonical":"","team":"TMTG7023U"},"is_bot":false,"is_app_user":false,"updated":1568072109,"is_invited_user":true}],"cache_ts":1568166965,"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Wed, 11 Sep 2019 01:56:05 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '963' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 20:54:38 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - a7ce45bb-5fb9-4bd9-af2e-0fa9482d0140 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-vdna + X-Cache: + - Miss from cloudfront + Via: + - 1.1 e5147bed59b539c23be4f2e01cf6f6f5.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - e5g56rV_XV8tSqvvknC8stm6UGdyLgMQT45kf8HpVr4d2p8G0G_xYg== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTG8GHKL","name":"apis","is_channel":true,"created":1568071960,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"apis","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69TR3N1","UN85KFVNK"],"topic":{"value":"Testing + location for APIs.","creator":"UN69TR3N1","last_set":1568151873},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CMURA7JFM","name":"random","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN85KFVNK","last_set":1568071832},"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":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN03170U9","name":"memes","is_channel":true,"created":1568090675,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"memes","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"all + the memes","creator":"UN69TR3N1","last_set":1568151900},"purpose":{"value":"we + need them","creator":"UN85KFVNK","last_set":1568090676},"previous_names":[],"num_members":6},{"id":"CN1GC7WAD","name":"hallies_secret","is_channel":true,"created":1568172409,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"hallies_secret","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UN69SEW21","UN85KFVNK"],"topic":{"value":"To + see who reads their API JSON carefully and joins this channel.","creator":"UN69SEW21","last_set":1568172444},"purpose":{"value":"To + see who reads their API JSON carefully and joins this channel.","creator":"UN69SEW21","last_set":1568172409},"previous_names":[],"num_members":2},{"id":"CN69J7LQG","name":"general","is_channel":true,"created":1568071832,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN85KFVNK","last_set":1568071832},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN759T0MA","name":"fuzzy_bunnies","is_channel":true,"created":1568147657,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"fuzzy_bunnies","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Adorable + rabbits","creator":"UN69TR3N1","last_set":1568151886},"purpose":{"value":"For + photos and conversation about fuzzy bunnies.","creator":"UN69SEW21","last_set":1568147658},"previous_names":[],"num_members":6},{"id":"CN7UD5D8Q","name":"dont_fight_bears","is_channel":true,"created":1568172797,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"dont_fight_bears","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UN69SEW21","UN69SF69K","UN85KFVNK"],"topic":{"value":"A + place for bear safety and tips.","creator":"UN69SEW21","last_set":1568172825},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CN85KGEJ3","name":"slack-cli","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"CLI","creator":"UN69TR3N1","last_set":1568151925},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 20:54:38 GMT recorded_with: VCR 5.0.0 From f48cc00b9732a53cfe27e4096cee6cfab964d945 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Wed, 11 Sep 2019 14:32:45 -0700 Subject: [PATCH 12/23] added tests for User.details & Channel.details --- lib/workspace.rb | 4 +- test/cassettes/channels_list.yml | 170 +++++++++++++++++++++++++++++++ test/channel_test.rb | 21 ++++ test/user_test.rb | 7 ++ test/workspace_test.rb | 26 +++++ 5 files changed, 226 insertions(+), 2 deletions(-) diff --git a/lib/workspace.rb b/lib/workspace.rb index c5e84964..f72a0ff8 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -25,7 +25,7 @@ def select_channel(identifier) return end end - raise SlackApiError, "This channel does not exist" + raise SlackApiError end def select_user(identifier) @@ -41,7 +41,7 @@ def select_user(identifier) return end end - raise SlackApiError, "This user does not exist" + raise SlackApiError end def show_details diff --git a/test/cassettes/channels_list.yml b/test/cassettes/channels_list.yml index c7e930e1..87f04aff 100644 --- a/test/cassettes/channels_list.yml +++ b/test/cassettes/channels_list.yml @@ -145,4 +145,174 @@ http_interactions: photos and conversation about fuzzy bunnies.","creator":"UN69SEW21","last_set":1568147658},"previous_names":[],"num_members":6},{"id":"CN85KGEJ3","name":"slack-cli","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"CLI","creator":"UN69TR3N1","last_set":1568151925},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Tue, 10 Sep 2019 22:28:51 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: + - '1587' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:02:51 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - bcb333b4-e151-4c8f-8075-122d2c337551 + 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-wycu + X-Cache: + - Miss from cloudfront + Via: + - 1.1 44cd593d82a2d200a94217033c614c6a.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - yY5X54HGk0lT7PvD0ZzGu8qR_OnjPKBEMFP3aD7F9CeQyLWx1u_P2w== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMTG7023U","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":"TMTG7023U"},"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":"UMTG87PC2","team_id":"TMTG7023U","name":"nickyjinchoi","deleted":false,"color":"674b1b","real_name":"Nicky + Choi","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Nicky + Choi","real_name_normalized":"Nicky Choi","display_name":"Nicky Choi","display_name_normalized":"Nicky + Choi","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g6e33044e4c8","image_24":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071993,"has_2fa":false},{"id":"UN69SEW21","team_id":"TMTG7023U","name":"idhallie","deleted":false,"color":"e7392d","real_name":"Hallie + Johnson","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Hallie + Johnson","real_name_normalized":"Hallie Johnson","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23bc7b83db4","image_24":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072412},{"id":"UN69SF69K","team_id":"TMTG7023U","name":"yitgop.yyhxox","deleted":false,"color":"3c989f","real_name":"Yitgop + Y.","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Yitgop + Y.","real_name_normalized":"Yitgop Y.","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb749eeae508","image_24":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072069},{"id":"UN69TR3N1","team_id":"TMTG7023U","name":"elizabethjnorthrop","deleted":false,"color":"e0a729","real_name":"Elizabeth + Northrop","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Elizabeth + Northrop","real_name_normalized":"Elizabeth Northrop","display_name":"Elizabeth + Northrop","display_name_normalized":"Elizabeth Northrop","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g555bff2ee78","image_24":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072090},{"id":"UN85KFVNK","team_id":"TMTG7023U","name":"emilyvomacka","deleted":false,"color":"9f69e7","real_name":"Emily + V","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Emily + V","real_name_normalized":"Emily V","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g319432559c3","first_name":"Emily","last_name":"V","image_24":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568090599},{"id":"UN85LNJMV","team_id":"TMTG7023U","name":"janicehuang","deleted":false,"color":"4bbe2e","real_name":"janice","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"janice","real_name_normalized":"janice","display_name":"janice","display_name_normalized":"janice","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g73010028c3d","image_24":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071984},{"id":"UN85LQ0HM","team_id":"TMTG7023U","name":"elizabethjnorthrup","deleted":true,"profile":{"title":"","phone":"","skype":"","real_name":"elizabethjnorthrup","real_name_normalized":"elizabethjnorthrup","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g0b2f1d21275","first_name":"","last_name":"","image_24":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-512.png","status_text_canonical":"","team":"TMTG7023U"},"is_bot":false,"is_app_user":false,"updated":1568072109,"is_invited_user":true}],"cache_ts":1568235771,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:02:51 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '963' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:02:51 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 01cb1a60-691b-4e25-acf8-53c258c6577d + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-wzn6 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 34f8ef0e4c880df0650a814412a26ea6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - f0Q9PJb95pjnXGulL3vohOaYLD6FwPv2fAuxy6SCuzTSMDNJ-wlmow== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTG8GHKL","name":"apis","is_channel":true,"created":1568071960,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"apis","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69TR3N1","UN85KFVNK"],"topic":{"value":"Testing + location for APIs.","creator":"UN69TR3N1","last_set":1568151873},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CMURA7JFM","name":"random","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN85KFVNK","last_set":1568071832},"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":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN03170U9","name":"memes","is_channel":true,"created":1568090675,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"memes","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"all + the memes","creator":"UN69TR3N1","last_set":1568151900},"purpose":{"value":"we + need them","creator":"UN85KFVNK","last_set":1568090676},"previous_names":[],"num_members":6},{"id":"CN1GC7WAD","name":"hallies_secret","is_channel":true,"created":1568172409,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"hallies_secret","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UN69SEW21","UN85KFVNK"],"topic":{"value":"To + see who reads their API JSON carefully and joins this channel.","creator":"UN69SEW21","last_set":1568172444},"purpose":{"value":"To + see who reads their API JSON carefully and joins this channel.","creator":"UN69SEW21","last_set":1568172409},"previous_names":[],"num_members":2},{"id":"CN69J7LQG","name":"general","is_channel":true,"created":1568071832,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN85KFVNK","last_set":1568071832},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN759T0MA","name":"fuzzy_bunnies","is_channel":true,"created":1568147657,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"fuzzy_bunnies","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Adorable + rabbits","creator":"UN69TR3N1","last_set":1568151886},"purpose":{"value":"For + photos and conversation about fuzzy bunnies.","creator":"UN69SEW21","last_set":1568147658},"previous_names":[],"num_members":6},{"id":"CN7UD5D8Q","name":"dont_fight_bears","is_channel":true,"created":1568172797,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"dont_fight_bears","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UN69SEW21","UN69SF69K","UN85KFVNK"],"topic":{"value":"A + place for bear safety and tips.","creator":"UN69SEW21","last_set":1568172825},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CN85KGEJ3","name":"slack-cli","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"CLI","creator":"UN69TR3N1","last_set":1568151925},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:02:51 GMT recorded_with: VCR 5.0.0 diff --git a/test/channel_test.rb b/test/channel_test.rb index c819f48a..8ab8ea47 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -1,6 +1,20 @@ require_relative "test_helper" describe "Channel" do + describe "#initialize" do + before do + @test_channel = Slack::Channel.new(name: "rubber duck", slack_id: "RUBADUBDUB", topic: "duck things", member_count: 138) + end + + it "will return the attributes and its data type" do + expect(@test_channel.name).must_equal "rubber duck" + expect(@test_channel.slack_id).must_equal "RUBADUBDUB" + expect(@test_channel.topic).must_equal "duck things" + expect(@test_channel.member_count).must_equal 138 + + expect(@test_channel).must_be_instance_of Slack::Channel + end + end describe "Channel.list method" do it "will return a list of channels" do VCR.use_cassette("channels_list") do @@ -13,4 +27,11 @@ expect(@channel_array[0]["member count"]).must_be_instance_of Integer end end + + describe "Channel details method" do + it "will return details about the selected channel" do + test_channel = Slack::Channel.new(name: "Gossip", slack_id: "FULLOFSECRETS", topic: "Everything true or false", member_count: 100) + expect(test_channel.details).must_equal "\nname: Gossip, slack_id: FULLOFSECRETS, topic: Everything true or false, member count: 100" + end + end end diff --git a/test/user_test.rb b/test/user_test.rb index 2cd16191..9e7abfb5 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -25,4 +25,11 @@ expect(@user_array[0]["slack id"]).must_be_instance_of String end end + + describe "User details method" do + it "will return details about the selected user" do + test_user = Slack::User.new(name: "Franky", slack_id: "FRANKRUS", real_name: "Frankenstein") + expect(test_user.details).must_equal "\nreal name: Frankenstein, user name: Franky, slack_id: FRANKRUS" + end + end end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 018846a2..17400600 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -22,3 +22,29 @@ expect(@workspace.selected.is_a?(Slack::User)).must_equal true end end + +describe "Channel.list method" do + before do + VCR.use_cassette("channels_list") do + @channel_array = Slack::Channel.list + @workspace = Slack::Workspace.new + end + end + + it "channels is a list of type Channel" do + expect(@workspace.channels.all? { |channel| channel.is_a?(Slack::Channel) }).must_equal true + end + + it "will select a channel by name" do + @workspace.select_channel("fuzzy_bunnies") + expect(@workspace.selected.is_a?(Slack::Channel)).must_equal true + end + + it "will select a channel by slack_id" do + @workspace.select_channel("CN759T0MA") + expect(@workspace.selected.is_a?(Slack::Channel)).must_equal true + end +end + +describe "show_details method" do +end From 323fbd8833c3822dff32ee8bfbe32c9281f81b89 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Wed, 11 Sep 2019 14:58:32 -0700 Subject: [PATCH 13/23] added tests for show_details in Workspace class --- lib/workspace.rb | 4 ++-- test/workspace_test.rb | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/workspace.rb b/lib/workspace.rb index f72a0ff8..a692ab2f 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -22,7 +22,7 @@ def select_channel(identifier) @channels.each do |channel| if [channel.name, channel.slack_id].include?(identifier) @selected = channel - return + return @selected end end raise SlackApiError @@ -38,7 +38,7 @@ def select_user(identifier) # return if [user.name, user.slack_id].include?(identifier) @selected = user - return + return @selected end end raise SlackApiError diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 17400600..0a03ef2f 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -47,4 +47,21 @@ end describe "show_details method" do + before do + VCR.use_cassette("channels_list") do + @channel_array = Slack::Channel.list + @workspace = Slack::Workspace.new + end + end + + it "returns the selected channel's details" do + # p @workspace.select_channel("fuzzy_bunnies").inspect + @workspace.select_channel("fuzzy_bunnies") + expect(@workspace.show_details).must_be_kind_of String + end + + it "returns the selected user's details" do + @workspace.select_user("idhallie") + expect(@workspace.show_details).must_be_kind_of String + end end From eabeadad74893c93a57b99f3dc7a8f7e9add9ef5 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Wed, 11 Sep 2019 20:51:03 -0700 Subject: [PATCH 14/23] started on send_message methods --- lib/recipient.rb | 33 ++++++++++++++++++++++----------- lib/slack.rb | 5 +++++ lib/workspace.rb | 4 ++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/lib/recipient.rb b/lib/recipient.rb index 065da0e7..8fa34b64 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -1,5 +1,6 @@ require "httparty" require "dotenv" +MESSAGE_URL = "https://slack.com/api/chat.postMessage" module Slack class Recipient @@ -14,17 +15,27 @@ def self.get(url, params) return HTTParty.get(url, params) end - def send_message(message) - body = { - token: key, - channel: slack_id, - text: message, - } - - response = HTTParty.post(MESSAGE_URL, body: body) - - if response["ok"] != true - raise StandardError, "Invalid request. Error is #{response.code}: #{response.message}" + MESSAGE_URL = "https://slack.com/api/chat.postMessage" + + def post_message(message) + if @selected.is_a?(Slack::Channel) + body = { + token: ENV["SLACK_TOKEN"], + channel: slack_id, + text: message, + } + + response = HTTParty.post(MESSAGE_URL, body: body) + + if response["ok"] != true + raise StandardError, "Invalid request. Error is #{response.code}: #{response.message}" + end + # else + # body = { + # token: ENV["SLACK_TOKEN"], + # channel: slack_id, + # text: message, + # } end end diff --git a/lib/slack.rb b/lib/slack.rb index 531d0c05..bf8e04d3 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -21,6 +21,7 @@ def main -select user -select channel -show details + -send message -quit" input = gets.chomp.downcase @@ -49,6 +50,10 @@ def main end when "show details" puts "#{workspace.show_details}" + when "send message" + puts "What do you want to send?" + message = gets.chomp + workspace.send_message(message) when "quit" exit end diff --git a/lib/workspace.rb b/lib/workspace.rb index a692ab2f..c0b02f85 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -50,9 +50,9 @@ def show_details end end - def send_message + def send_message(message) if @selected - @selected.send_message(send_message) + @selected.post_message(message) else return nil end From 723089af78143f8ffbab1e3f01846f7456ce2755 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Wed, 11 Sep 2019 21:15:29 -0700 Subject: [PATCH 15/23] fixed send_message method --- lib/recipient.rb | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/lib/recipient.rb b/lib/recipient.rb index 8fa34b64..48ffb084 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -15,28 +15,19 @@ def self.get(url, params) return HTTParty.get(url, params) end - MESSAGE_URL = "https://slack.com/api/chat.postMessage" - - def post_message(message) - if @selected.is_a?(Slack::Channel) - body = { - token: ENV["SLACK_TOKEN"], - channel: slack_id, - text: message, - } - - response = HTTParty.post(MESSAGE_URL, body: body) - - if response["ok"] != true - raise StandardError, "Invalid request. Error is #{response.code}: #{response.message}" - end - # else - # body = { - # token: ENV["SLACK_TOKEN"], - # channel: slack_id, - # text: message, - # } + def send_message(message) + body = { + token: ENV["SLACK_TOKEN"], + channel: slack_id, + text: message, + } + + response = HTTParty.post(MESSAGE_URL, body: body) + + if response["ok"] != true + raise StandardError, "Invalid request. Error is #{response.code}: #{response.message}" end + return response end private From 3ad2e3946318b8f416f6ded5f999ae484647e082 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Wed, 11 Sep 2019 21:16:05 -0700 Subject: [PATCH 16/23] added conditional statements in main command loop --- lib/slack.rb | 23 ++++++++++++++++------- lib/workspace.rb | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index bf8e04d3..9ce047aa 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -16,13 +16,14 @@ def main input = "" until input == "quit" puts "\nPlease select an option: + -list users -list channels -select user -select channel -show details -send message - -quit" + -quit\n" input = gets.chomp.downcase case input @@ -38,7 +39,7 @@ def main begin workspace.select_user(identifier) rescue SlackApiError - puts "\nWe couldn't find this user!" + puts "\n**We couldn't find this user!**" end when "select channel" puts "\nEnter a username or slack id: " @@ -46,14 +47,22 @@ def main begin workspace.select_channel(identifier) rescue SlackApiError - puts "\nWe couldn't find the channel!" + puts "\n**We couldn't find the channel!**" end when "show details" - puts "#{workspace.show_details}" + if workspace.show_details == nil + puts "\nNo user or channel has been selected" + else + puts "#{workspace.show_details}" + end when "send message" - puts "What do you want to send?" - message = gets.chomp - workspace.send_message(message) + if workspace.selected == nil + puts "\nNo user or channel has been selected" + else + puts "What do you want to send?" + message = gets.chomp + workspace.send_message(message) + end when "quit" exit end diff --git a/lib/workspace.rb b/lib/workspace.rb index c0b02f85..b56a87ed 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -52,7 +52,7 @@ def show_details def send_message(message) if @selected - @selected.post_message(message) + @selected.send_message(message) else return nil end From 86b047e3d89498cf5e0b556185302aacb93f384a Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Thu, 12 Sep 2019 13:54:55 -0700 Subject: [PATCH 17/23] started on tests for send message --- test/cassettes/channels_list.yml | 73 ++++++++++++++++++++++++++++++++ test/cassettes/users_list.yml | 73 ++++++++++++++++++++++++++++++++ test/workspace_test.rb | 51 ++++++++++++++++++++++ 3 files changed, 197 insertions(+) diff --git a/test/cassettes/channels_list.yml b/test/cassettes/channels_list.yml index 87f04aff..5b97b43a 100644 --- a/test/cassettes/channels_list.yml +++ b/test/cassettes/channels_list.yml @@ -315,4 +315,77 @@ http_interactions: place for bear safety and tips.","creator":"UN69SEW21","last_set":1568172825},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CN85KGEJ3","name":"slack-cli","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"CLI","creator":"UN69TR3N1","last_set":1568151925},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Wed, 11 Sep 2019 21:02:51 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=fuzzy_bunnies&text=hello%20from%20the%20other%20side + 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: + - '184' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 20:00:50 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - a0387d87-956e-4039-ae1e-ce4e01cf305d + 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-5he4 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 a2a7227d0a99f50bffb8ba79de64ab0f.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19 + X-Amz-Cf-Id: + - ho5z9Eav8yzPNRlU--ZSTelrMW8oJeSv4w6kLmZS97i_hWhyW47TXQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channel":"CN759T0MA","ts":"1568318450.000200","message":{"type":"message","subtype":"bot_message","text":"hello + from the other side","ts":"1568318450.000200","username":"Leaves - Nicky - + API Project","bot_id":"BN85QTQ8P"}}' + http_version: + recorded_at: Thu, 12 Sep 2019 20:00:50 GMT recorded_with: VCR 5.0.0 diff --git a/test/cassettes/users_list.yml b/test/cassettes/users_list.yml index c1fa3331..7c8a2ef2 100644 --- a/test/cassettes/users_list.yml +++ b/test/cassettes/users_list.yml @@ -255,4 +255,77 @@ http_interactions: place for bear safety and tips.","creator":"UN69SEW21","last_set":1568172825},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CN85KGEJ3","name":"slack-cli","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"CLI","creator":"UN69TR3N1","last_set":1568151925},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Wed, 11 Sep 2019 20:54:38 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=UN69TR3N1&text=hello%20from%20the%20other%20side + 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: + - '185' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 20:14:15 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - ac8518df-9ff6-4639-be09-2874ae9c4eae + 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-j2wg + X-Cache: + - Miss from cloudfront + Via: + - 1.1 786d821259e050ebca76b8e357819f78.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - qE88MQ6mQQukLO-0TdD3gJMAIS5vi4ZzR7oWG2RvfHilpO5KXjJB4Q== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channel":"DN8FXLB8E","ts":"1568319255.000100","message":{"type":"message","subtype":"bot_message","text":"hello + from the other side","ts":"1568319255.000100","username":"Leaves - Nicky - + API Project","bot_id":"BN85QTQ8P"}}' + http_version: + recorded_at: Thu, 12 Sep 2019 20:14:15 GMT recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 0a03ef2f..d0fad8e3 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -65,3 +65,54 @@ expect(@workspace.show_details).must_be_kind_of String end end + +describe "send_message method" do + it "sends a message to the chosen channel" do + VCR.use_cassette("channels_list") do + @channel_array = Slack::Channel.list + @workspace = Slack::Workspace.new + body = { + token: ENV["SLACK_TOKEN"], + channel: "fuzzy_bunnies", + text: "hello from the other side", + } + + @response = HTTParty.post(MESSAGE_URL, body: body) + end + + expect(@response).must_be_kind_of HTTParty::Response + end + + it "sends a message to the chosen user" do + VCR.use_cassette("users_list") do + @user_array = Slack::User.list + @workspace = Slack::Workspace.new + body = { + token: ENV["SLACK_TOKEN"], + channel: "UN69TR3N1", + text: "hello from the other side", + } + + @response = HTTParty.post(MESSAGE_URL, body: body) + end + + expect(@response).must_be_kind_of HTTParty::Response + end + + it "returns the selected channel" do + VCR.use_cassette("message_post") do + body = { + token: ENV["SLACK_TOKEN"], + channel: "apis", + text: "hello from the other side", + } + @workspace = Slack::Workspace.new + @selected_channel = @workspace.select_channel("apis") + response = @workspace.send_message("APIs! Amiright?") + + expect(response["ok"]).must_equal true + end + + expect(@response).must_equal true + end +end From e76db3cedfb58de821e3bb5c27f30efdd7b16e9e Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Thu, 12 Sep 2019 14:54:54 -0700 Subject: [PATCH 18/23] created custom exception class --- lib/slack.rb | 8 +- lib/workspace.rb | 4 +- test/cassettes/message_post.yml | 246 ++++++++++++++++++++++++++++++++ test/workspace_test.rb | 17 +-- 4 files changed, 257 insertions(+), 18 deletions(-) create mode 100644 test/cassettes/message_post.yml diff --git a/lib/slack.rb b/lib/slack.rb index 9ce047aa..18c685ac 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -38,16 +38,16 @@ def main identifier = gets.chomp begin workspace.select_user(identifier) - rescue SlackApiError - puts "\n**We couldn't find this user!**" + rescue SlackApiError => e + puts "#{e.message}" end when "select channel" puts "\nEnter a username or slack id: " identifier = gets.chomp begin workspace.select_channel(identifier) - rescue SlackApiError - puts "\n**We couldn't find the channel!**" + rescue SlackApiError => f + puts "#{f.message}" end when "show details" if workspace.show_details == nil diff --git a/lib/workspace.rb b/lib/workspace.rb index b56a87ed..2941a0a6 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -25,7 +25,7 @@ def select_channel(identifier) return @selected end end - raise SlackApiError + raise SlackApiError.new("We couldn't find this channel!") end def select_user(identifier) @@ -41,7 +41,7 @@ def select_user(identifier) return @selected end end - raise SlackApiError + raise SlackApiError.new("We couldn't find this user!") end def show_details diff --git a/test/cassettes/message_post.yml b/test/cassettes/message_post.yml new file mode 100644 index 00000000..3cc7a6d8 --- /dev/null +++ b/test/cassettes/message_post.yml @@ -0,0 +1,246 @@ +--- +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: + - '1632' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 21:07:56 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 9d5520e2-d264-4838-9339-25b89b0489e4 + 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-cfdl + X-Cache: + - Miss from cloudfront + Via: + - 1.1 324a68a6c25ee50d774953f3e15a611d.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - sq0im1rlFIAomu_05oxQqtBvTiAJX7yhmiaNzkDvFzE-NYxbUmdbyw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TMTG7023U","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":"TMTG7023U"},"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":"UMTG87PC2","team_id":"TMTG7023U","name":"nickyjinchoi","deleted":false,"color":"674b1b","real_name":"Nicky + Choi","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Nicky + Choi","real_name_normalized":"Nicky Choi","display_name":"Nicky Choi","display_name_normalized":"Nicky + Choi","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g6e33044e4c8","image_24":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/6e33044e4c8b33fd0f9c91d1336ba76e.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0023-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071993,"has_2fa":false},{"id":"UN69SEW21","team_id":"TMTG7023U","name":"idhallie","deleted":false,"color":"e7392d","real_name":"Hallie + Johnson","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Hallie + Johnson","real_name_normalized":"Hallie Johnson","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g23bc7b83db4","image_24":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/23bc7b83db4e9e1b8078233de714be6c.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0008-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072412},{"id":"UN69SF69K","team_id":"TMTG7023U","name":"yitgop.yyhxox","deleted":false,"color":"3c989f","real_name":"Yitgop + Y.","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Yitgop + Y.","real_name_normalized":"Yitgop Y.","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb749eeae508","image_24":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b749eeae50850c3cdee8b13970b317bf.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0004-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072069},{"id":"UN69TR3N1","team_id":"TMTG7023U","name":"elizabethjnorthrop","deleted":false,"color":"e0a729","real_name":"Elizabeth + Northrop","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Elizabeth + Northrop","real_name_normalized":"Elizabeth Northrop","display_name":"Elizabeth + Northrop","display_name_normalized":"Elizabeth Northrop","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g555bff2ee78","image_24":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/555bff2ee78501c207120cb173f73606.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568072090},{"id":"UN85KFVNK","team_id":"TMTG7023U","name":"emilyvomacka","deleted":false,"color":"9f69e7","real_name":"Emily + Vomacka","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Emily + Vomacka","real_name_normalized":"Emily Vomacka","display_name":"Emily V","display_name_normalized":"Emily + V","status_text":"Vacationing indefinitely","status_emoji":":sunglasses:","status_expiration":0,"avatar_hash":"g319432559c3","first_name":"Emily","last_name":"Vomacka","image_24":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/319432559c3a057a8391e5e08c4dd308.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0010-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568242889},{"id":"UN85LNJMV","team_id":"TMTG7023U","name":"janicehuang","deleted":false,"color":"4bbe2e","real_name":"janice","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"janice","real_name_normalized":"janice","display_name":"janice","display_name_normalized":"janice","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g73010028c3d","image_24":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/73010028c3d67aa8022066545539f519.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0024-512.png","status_text_canonical":"","team":"TMTG7023U"},"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":1568071984},{"id":"UN85LQ0HM","team_id":"TMTG7023U","name":"elizabethjnorthrup","deleted":true,"profile":{"title":"","phone":"","skype":"","real_name":"elizabethjnorthrup","real_name_normalized":"elizabethjnorthrup","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g0b2f1d21275","first_name":"","last_name":"","image_24":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/0b2f1d21275ee333b76dd3a485688452.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0011-512.png","status_text_canonical":"","team":"TMTG7023U"},"is_bot":false,"is_app_user":false,"updated":1568072109,"is_invited_user":true}],"cache_ts":1568322476,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 21:07:56 GMT +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '963' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 21:07:56 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - d5e7c271-3b10-47d9-bbba-5be462b6731a + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:bot + Expires: + - Mon, 26 Jul 1997 05:00:00 GMT + Cache-Control: + - private, no-cache, no-store, must-revalidate + Access-Control-Expose-Headers: + - x-slack-req-id, retry-after + X-Xss-Protection: + - '0' + X-Accepted-Oauth-Scopes: + - channels:read + Vary: + - Accept-Encoding + Pragma: + - no-cache + Access-Control-Allow-Headers: + - slack-route, x-slack-version-ts + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Referrer-Policy: + - no-referrer + Access-Control-Allow-Origin: + - "*" + X-Via: + - haproxy-www-an04 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 0732be5515ffeda639cfe5f22fb04df6.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - 9dinmSaCuOoC0y95MyuQ9xr_njUNzwSFiC5Qd-JiWC5EDjrY9fL7Ng== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMTG8GHKL","name":"apis","is_channel":true,"created":1568071960,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"apis","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69TR3N1","UN85KFVNK"],"topic":{"value":"Testing + location for APIs.","creator":"UN69TR3N1","last_set":1568151873},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CMURA7JFM","name":"random","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UN85KFVNK","last_set":1568071832},"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":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN03170U9","name":"memes","is_channel":true,"created":1568090675,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"memes","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"all + the memes","creator":"UN69TR3N1","last_set":1568151900},"purpose":{"value":"we + need them","creator":"UN85KFVNK","last_set":1568090676},"previous_names":[],"num_members":6},{"id":"CN1GC7WAD","name":"hallies_secret","is_channel":true,"created":1568172409,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"hallies_secret","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UN69SEW21","UN85KFVNK"],"topic":{"value":"To + see who reads their API JSON carefully and joins this channel.","creator":"UN69SEW21","last_set":1568172444},"purpose":{"value":"To + see who reads their API JSON carefully and joins this channel.","creator":"UN69SEW21","last_set":1568172409},"previous_names":[],"num_members":2},{"id":"CN69J7LQG","name":"general","is_channel":true,"created":1568071832,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UN85KFVNK","last_set":1568071832},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UN85KFVNK","last_set":1568071832},"previous_names":[],"num_members":6},{"id":"CN759T0MA","name":"fuzzy_bunnies","is_channel":true,"created":1568147657,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"fuzzy_bunnies","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"Adorable + rabbits","creator":"UN69TR3N1","last_set":1568151886},"purpose":{"value":"For + photos and conversation about fuzzy bunnies.","creator":"UN69SEW21","last_set":1568147658},"previous_names":[],"num_members":6},{"id":"CN7UD5D8Q","name":"dont_fight_bears","is_channel":true,"created":1568172797,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69SEW21","name_normalized":"dont_fight_bears","is_shared":false,"is_org_shared":false,"is_member":false,"is_private":false,"is_mpim":false,"members":["UN69SEW21","UN69SF69K","UN85KFVNK"],"topic":{"value":"A + place for bear safety and tips.","creator":"UN69SEW21","last_set":1568172825},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":3},{"id":"CN85KGEJ3","name":"slack-cli","is_channel":true,"created":1568071832,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN85KFVNK","name_normalized":"slack-cli","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTG87PC2","UN69SEW21","UN69SF69K","UN69TR3N1","UN85KFVNK","UN85LNJMV"],"topic":{"value":"CLI","creator":"UN69TR3N1","last_set":1568151925},"purpose":{"value":"","creator":"","last_set":0},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Thu, 12 Sep 2019 21:07:56 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=CMTG8GHKL&text=Helllooo + 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: + - '174' + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 21:07:56 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 509184cf-e6ff-47f4-8bf6-396ca862169f + 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-wycu + X-Cache: + - Miss from cloudfront + Via: + - 1.1 f9d716a351f14a0ac1fac2449734849b.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - 1kbQa22FBZz-kD-V1cOBbYFWY2oXOMbjPyBQtetfWrB1JL7fkufd7g== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channel":"CMTG8GHKL","ts":"1568322476.000400","message":{"type":"message","subtype":"bot_message","text":"Helllooo","ts":"1568322476.000400","username":"Leaves + - Nicky - API Project","bot_id":"BN85QTQ8P"}}' + http_version: + recorded_at: Thu, 12 Sep 2019 21:07:56 GMT +recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index d0fad8e3..2b411eb5 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -1,6 +1,6 @@ require_relative "test_helper" -describe "User.list method" do +describe "User methods" do before do VCR.use_cassette("users_list") do @user_array = Slack::User.list @@ -23,7 +23,7 @@ end end -describe "Channel.list method" do +describe "Channel methods" do before do VCR.use_cassette("channels_list") do @channel_array = Slack::Channel.list @@ -101,18 +101,11 @@ it "returns the selected channel" do VCR.use_cassette("message_post") do - body = { - token: ENV["SLACK_TOKEN"], - channel: "apis", - text: "hello from the other side", - } @workspace = Slack::Workspace.new - @selected_channel = @workspace.select_channel("apis") - response = @workspace.send_message("APIs! Amiright?") - - expect(response["ok"]).must_equal true + @selected = @workspace.select_channel("apis") + @response = @workspace.send_message("Helllooo") end - expect(@response).must_equal true + expect(@response["ok"]).must_equal true end end From 79ae3ebf200a9ec2979099db9777a41097190529 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Thu, 12 Sep 2019 16:58:32 -0700 Subject: [PATCH 19/23] refactored command line for SlackApiError & added tests for Workspace class --- lib/recipient.rb | 4 +--- lib/slack.rb | 8 ++++---- lib/workspace.rb | 2 +- test/channel_test.rb | 14 ++++++++++---- test/workspace_test.rb | 42 +++++++++++++++++++++++++++++++++++++++++- 5 files changed, 57 insertions(+), 13 deletions(-) diff --git a/lib/recipient.rb b/lib/recipient.rb index 48ffb084..0b0a1849 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -25,13 +25,11 @@ def send_message(message) response = HTTParty.post(MESSAGE_URL, body: body) if response["ok"] != true - raise StandardError, "Invalid request. Error is #{response.code}: #{response.message}" + raise SlackApiError.new("Invalid request. Error is #{response.code}: #{response.message}") end return response end - private - def self.list raise NotImplementedError, "Implement me in a child class!" end diff --git a/lib/slack.rb b/lib/slack.rb index 18c685ac..46b21e15 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -39,15 +39,15 @@ def main begin workspace.select_user(identifier) rescue SlackApiError => e - puts "#{e.message}" + puts "\n#{e.message}" end when "select channel" - puts "\nEnter a username or slack id: " + puts "\nEnter a name or slack id: " identifier = gets.chomp begin workspace.select_channel(identifier) - rescue SlackApiError => f - puts "#{f.message}" + rescue SlackApiError => e + puts "\n#{e.message}" end when "show details" if workspace.show_details == nil diff --git a/lib/workspace.rb b/lib/workspace.rb index 2941a0a6..40a00591 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -30,7 +30,7 @@ def select_channel(identifier) def select_user(identifier) @users.each do |user| - # if user.name == identifier || + # if user.name == identifier # @selected = user # return # elsif user.slack_id == identifier diff --git a/test/channel_test.rb b/test/channel_test.rb index 8ab8ea47..910dcd75 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -3,12 +3,12 @@ describe "Channel" do describe "#initialize" do before do - @test_channel = Slack::Channel.new(name: "rubber duck", slack_id: "RUBADUBDUB", topic: "duck things", member_count: 138) + @test_channel = Slack::Channel.new(name: "rubber duck", slack_id: "Ducks8", topic: "duck things", member_count: 138) end it "will return the attributes and its data type" do expect(@test_channel.name).must_equal "rubber duck" - expect(@test_channel.slack_id).must_equal "RUBADUBDUB" + expect(@test_channel.slack_id).must_equal "Ducks8" expect(@test_channel.topic).must_equal "duck things" expect(@test_channel.member_count).must_equal 138 @@ -29,9 +29,15 @@ end describe "Channel details method" do + before do + @test_channel = Slack::Channel.new(name: "Gossip", slack_id: "FULLOFSECRETS", topic: "Everything true or false", member_count: 100) + end it "will return details about the selected channel" do - test_channel = Slack::Channel.new(name: "Gossip", slack_id: "FULLOFSECRETS", topic: "Everything true or false", member_count: 100) - expect(test_channel.details).must_equal "\nname: Gossip, slack_id: FULLOFSECRETS, topic: Everything true or false, member count: 100" + expect(@test_channel.details).must_equal "\nname: Gossip, slack_id: FULLOFSECRETS, topic: Everything true or false, member count: 100" + end + + it "returns a string type for details" do + expect(@test_channel.details).must_be_instance_of String end end end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 2b411eb5..f51833b0 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -21,6 +21,12 @@ @workspace.select_user("USLACKBOT") expect(@workspace.selected.is_a?(Slack::User)).must_equal true end + + it "raises an error if a valid user is not found" do + expect do + @selected = @workspace.select_user("asjdakwjrer") + end.must_raise SlackApiError + end end describe "Channel methods" do @@ -44,6 +50,12 @@ @workspace.select_channel("CN759T0MA") expect(@workspace.selected.is_a?(Slack::Channel)).must_equal true end + + it "raises an error if a valid channel is not found" do + expect do + @selected = @workspace.select_channel("cute dogs") + end.must_raise SlackApiError + end end describe "show_details method" do @@ -99,7 +111,7 @@ expect(@response).must_be_kind_of HTTParty::Response end - it "returns the selected channel" do + it "returns true if the selected channel is valid" do VCR.use_cassette("message_post") do @workspace = Slack::Workspace.new @selected = @workspace.select_channel("apis") @@ -108,4 +120,32 @@ expect(@response["ok"]).must_equal true end + + # Want to raise a SlackApiError for an invalid request. + it "returns false if the selected channel is not valid" do + VCR.use_cassette("message_post") do + @workspace = Slack::Workspace.new + @selected = @workspace.select_channel("dogs") + @response = @workspace.send_message("Adorable doggos!") + end + + expect do + (@response["ok"]) + end.must_raise SlackApiError + end +end + +describe "Recipient class - NotImplementedError for Template methods" do + it "returns NotImplementedError for Recipient.list method" do + @recipient = Slack::Recipient.new(name: "BotBot", slack_id: "UWSJKE") + expect do + @recipient.details + end.must_raise NotImplementedError + end + + it "returns NotImplementedError for Recipient.list method" do + expect do + Slack::Recipient.list + end.must_raise NotImplementedError + end end From 9ee31a61f144343691475fb5d8f7a64995cbf182 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Thu, 12 Sep 2019 17:22:53 -0700 Subject: [PATCH 20/23] created more tests! --- lib/recipient.rb | 3 +- lib/{verification.rb => verify_setup.rb} | 0 test/cassettes/message_post.yml | 72 ++++++++++++++++++++++++ test/user_test.rb | 10 +++- test/workspace_test.rb | 27 +++++++-- 5 files changed, 104 insertions(+), 8 deletions(-) rename lib/{verification.rb => verify_setup.rb} (100%) diff --git a/lib/recipient.rb b/lib/recipient.rb index 0b0a1849..41b1885d 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -25,7 +25,8 @@ def send_message(message) response = HTTParty.post(MESSAGE_URL, body: body) if response["ok"] != true - raise SlackApiError.new("Invalid request. Error is #{response.code}: #{response.message}") + # raise SlackApiError.new("Invalid request. Error is #{response.code}: #{response.message}") + puts "Invalid request. Error is #{response.code}: #{response.message}" end return response end diff --git a/lib/verification.rb b/lib/verify_setup.rb similarity index 100% rename from lib/verification.rb rename to lib/verify_setup.rb diff --git a/test/cassettes/message_post.yml b/test/cassettes/message_post.yml index 3cc7a6d8..ac6e1d4e 100644 --- a/test/cassettes/message_post.yml +++ b/test/cassettes/message_post.yml @@ -243,4 +243,76 @@ http_interactions: - Nicky - API Project","bot_id":"BN85QTQ8P"}}' http_version: recorded_at: Thu, 12 Sep 2019 21:07:56 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=UMTG87PC2&text=Helllooo.%20What%27s%20uppp%3F + 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: + - '187' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 00:11:37 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 355acc71-072a-47b9-8b75-f7d3caa7e79f + 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-oawk + X-Cache: + - Miss from cloudfront + Via: + - 1.1 f126db770f21f288439f44d357978a27.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - ug2xX34t-cvUv9oSSXbybS20R_Sv6qfTyvL6Edps4ZXMe6qwFV0qmg== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channel":"DN85LPRJB","ts":"1568333497.000100","message":{"type":"message","subtype":"bot_message","text":"Helllooo. + What''s uppp?","ts":"1568333497.000100","username":"Leaves - Nicky - API Project","bot_id":"BN85QTQ8P"}}' + http_version: + recorded_at: Fri, 13 Sep 2019 00:11:37 GMT recorded_with: VCR 5.0.0 diff --git a/test/user_test.rb b/test/user_test.rb index 9e7abfb5..a1862dc6 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -27,9 +27,15 @@ end describe "User details method" do + before do + @test_user = Slack::User.new(name: "Franky", slack_id: "FRANKRUS", real_name: "Frankenstein") + end it "will return details about the selected user" do - test_user = Slack::User.new(name: "Franky", slack_id: "FRANKRUS", real_name: "Frankenstein") - expect(test_user.details).must_equal "\nreal name: Frankenstein, user name: Franky, slack_id: FRANKRUS" + expect(@test_user.details).must_equal "\nreal name: Frankenstein, user name: Franky, slack_id: FRANKRUS" + end + + it "returns a string type for details" do + expect(@test_user.details).must_be_instance_of String end end end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index f51833b0..7a7183d4 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -67,7 +67,6 @@ end it "returns the selected channel's details" do - # p @workspace.select_channel("fuzzy_bunnies").inspect @workspace.select_channel("fuzzy_bunnies") expect(@workspace.show_details).must_be_kind_of String end @@ -111,7 +110,7 @@ expect(@response).must_be_kind_of HTTParty::Response end - it "returns true if the selected channel is valid" do + it "returns true if the selected channel is valid and sends a message" do VCR.use_cassette("message_post") do @workspace = Slack::Workspace.new @selected = @workspace.select_channel("apis") @@ -121,6 +120,16 @@ expect(@response["ok"]).must_equal true end + it "returns true if the selected user is valid and sends a message" do + VCR.use_cassette("message_post") do + @workspace = Slack::Workspace.new + @selected = @workspace.select_user("nickyjinchoi") + @response = @workspace.send_message("Helllooo. What's uppp?") + end + + expect(@response["ok"]).must_equal true + end + # Want to raise a SlackApiError for an invalid request. it "returns false if the selected channel is not valid" do VCR.use_cassette("message_post") do @@ -128,10 +137,18 @@ @selected = @workspace.select_channel("dogs") @response = @workspace.send_message("Adorable doggos!") end + expect(@selected).must_raise SlackApiError + expect(@response["ok"]).must_equal false + end - expect do - (@response["ok"]) - end.must_raise SlackApiError + it "returns nil if a recipient has not been selected" do + VCR.use_cassette("message_post") do + @workspace = Slack::Workspace.new + @selected = nil + @response = @workspace.send_message("This will go nowhere") + end + + expect(@response).must_be_nil end end From 364b6aafc7bbddd9e8ccf9b41b178e5810a80aaa Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Thu, 12 Sep 2019 20:30:31 -0700 Subject: [PATCH 21/23] editing text for readability --- lib/recipient.rb | 7 +++---- lib/slack.rb | 13 +++++++------ lib/workspace.rb | 4 ++-- test/workspace_test.rb | 20 ++++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/recipient.rb b/lib/recipient.rb index 41b1885d..f9f75f1f 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -24,10 +24,9 @@ def send_message(message) response = HTTParty.post(MESSAGE_URL, body: body) - if response["ok"] != true - # raise SlackApiError.new("Invalid request. Error is #{response.code}: #{response.message}") - puts "Invalid request. Error is #{response.code}: #{response.message}" - end + # if response["ok"] != true + # raise SlackApiError.new("Invalid request. Error is #{response.code}: #{response.message}") + # end return response end diff --git a/lib/slack.rb b/lib/slack.rb index 46b21e15..1eb61310 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -8,6 +8,8 @@ require_relative "workspace" require_relative "recipient" +# For specific SlackApiError messages (https://stackoverflow.com/questions/3382866/rubys-exception-error-classes) + def main puts "Welcome to the Ada Slack CLI!" @@ -34,7 +36,7 @@ def main channel_array = Slack::Channel.list tp channel_array when "select user" - puts "\nEnter a username or slack id: " + puts "\n[Enter a username or slack id]" identifier = gets.chomp begin workspace.select_user(identifier) @@ -42,7 +44,7 @@ def main puts "\n#{e.message}" end when "select channel" - puts "\nEnter a name or slack id: " + puts "\n[Enter a name or slack id]" identifier = gets.chomp begin workspace.select_channel(identifier) @@ -51,24 +53,23 @@ def main end when "show details" if workspace.show_details == nil - puts "\nNo user or channel has been selected" + puts "\n[No user or channel has been selected]" else puts "#{workspace.show_details}" end when "send message" if workspace.selected == nil - puts "\nNo user or channel has been selected" + puts "\n[No user or channel has been selected]" else puts "What do you want to send?" message = gets.chomp workspace.send_message(message) end when "quit" + puts "[Thank you for using the Ada Slack CLI]" exit end end - - puts "Thank you for using the Ada Slack CLI" end main if __FILE__ == $PROGRAM_NAME diff --git a/lib/workspace.rb b/lib/workspace.rb index 40a00591..1d802aef 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -25,7 +25,7 @@ def select_channel(identifier) return @selected end end - raise SlackApiError.new("We couldn't find this channel!") + raise SlackApiError.new("[We couldn't find this channel!]") end def select_user(identifier) @@ -41,7 +41,7 @@ def select_user(identifier) return @selected end end - raise SlackApiError.new("We couldn't find this user!") + raise SlackApiError.new("[We couldn't find this user!]") end def show_details diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 7a7183d4..42e5aa20 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -131,15 +131,15 @@ end # Want to raise a SlackApiError for an invalid request. - it "returns false if the selected channel is not valid" do - VCR.use_cassette("message_post") do - @workspace = Slack::Workspace.new - @selected = @workspace.select_channel("dogs") - @response = @workspace.send_message("Adorable doggos!") - end - expect(@selected).must_raise SlackApiError - expect(@response["ok"]).must_equal false - end + # it "returns false if the selected channel is not valid" do + # VCR.use_cassette("message_post") do + # @workspace = Slack::Workspace.new + # @selected = @workspace.select_channel("doggos") + # @response = @workspace.send_message("Adorable doggos") + # end + + # expect(@response).must_equal false + # end it "returns nil if a recipient has not been selected" do VCR.use_cassette("message_post") do @@ -153,7 +153,7 @@ end describe "Recipient class - NotImplementedError for Template methods" do - it "returns NotImplementedError for Recipient.list method" do + it "returns NotImplementedError for details method" do @recipient = Slack::Recipient.new(name: "BotBot", slack_id: "UWSJKE") expect do @recipient.details From dbcb504f5cfe6df0329a57a16467e50fe14f8fa7 Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Fri, 13 Sep 2019 13:41:28 -0700 Subject: [PATCH 22/23] Created recipient_test.rb and moves recipient focused tests from workspace_test.rb to recipient_test. Wrote test to test that error is raised when invalid input is given to recipient.send_message. --- lib/recipient.rb | 6 +- test/cassettes/message_post.yml | 143 ++++++++++++++++++++++++++++++++ test/recipient_test.rb | 28 +++++++ test/workspace_test.rb | 26 ------ 4 files changed, 174 insertions(+), 29 deletions(-) create mode 100644 test/recipient_test.rb diff --git a/lib/recipient.rb b/lib/recipient.rb index f9f75f1f..0b0a1849 100644 --- a/lib/recipient.rb +++ b/lib/recipient.rb @@ -24,9 +24,9 @@ def send_message(message) response = HTTParty.post(MESSAGE_URL, body: body) - # if response["ok"] != true - # raise SlackApiError.new("Invalid request. Error is #{response.code}: #{response.message}") - # end + if response["ok"] != true + raise SlackApiError.new("Invalid request. Error is #{response.code}: #{response.message}") + end return response end diff --git a/test/cassettes/message_post.yml b/test/cassettes/message_post.yml index ac6e1d4e..95e66927 100644 --- a/test/cassettes/message_post.yml +++ b/test/cassettes/message_post.yml @@ -315,4 +315,147 @@ http_interactions: What''s uppp?","ts":"1568333497.000100","username":"Leaves - Nicky - API Project","bot_id":"BN85QTQ8P"}}' http_version: recorded_at: Fri, 13 Sep 2019 00:11:37 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=UN69TR3N1&text=Adorable%20doggos + 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: + - '179' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 20:22:46 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 34c4853c-ad15-4fd8-9abf-d37deedc4ad1 + 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-5nvv + X-Cache: + - Miss from cloudfront + Via: + - 1.1 fda3b2797d2719576f6b916583a28e52.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - qwa8wqiVZl6bxlMNn7FBt8tZR4rQlgS5DOnarpvJpg7k8tivMD24Xw== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channel":"DN8FXLB8E","ts":"1568406167.000100","message":{"type":"message","subtype":"bot_message","text":"Adorable + doggos","ts":"1568406167.000100","username":"Leaves - Nicky - API Project","bot_id":"BN85QTQ8P"}}' + http_version: + recorded_at: Fri, 13 Sep 2019 20:22:47 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&channel=UN69ewrkjwer&text=Adorable%20doggos + 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: + - '60' + Connection: + - keep-alive + Date: + - Fri, 13 Sep 2019 20:24:00 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 8ecf7411-07a8-41b6-9111-72ccc9b08e9d + 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-u916 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 7eb3b782ab09047ce0d11ee03763894c.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - TD3KCvfPwbBT3rYrKAWUMMVPtOq3JN3S3CBm9lOgi8h7vfPisVST0Q== + body: + encoding: ASCII-8BIT + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Fri, 13 Sep 2019 20:24:00 GMT recorded_with: VCR 5.0.0 diff --git a/test/recipient_test.rb b/test/recipient_test.rb new file mode 100644 index 00000000..cd598fd1 --- /dev/null +++ b/test/recipient_test.rb @@ -0,0 +1,28 @@ +require_relative "test_helper" + +describe "Recipient class - NotImplementedError for Template methods" do + it "returns NotImplementedError for details method" do + @recipient = Slack::Recipient.new(name: "BotBot", slack_id: "UWSJKE") + expect do + @recipient.details + end.must_raise NotImplementedError + end + + it "returns NotImplementedError for Recipient.list method" do + expect do + Slack::Recipient.list + end.must_raise NotImplementedError + end +end + +describe "Recipient send_message method" do + it "returns false if the selected channel is not valid" do + expect do + VCR.use_cassette("message_post") do + @recipient = Slack::Recipient.new(name: "harold", slack_id: "UN69ewrkjwer") + @response = @recipient.send_message("Adorable doggos") + @response["ok"] + end.must_raise SlackApiError, ("Invalid request. Error is 200: OK") + end + end +end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 42e5aa20..15c2ef9f 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -130,17 +130,6 @@ expect(@response["ok"]).must_equal true end - # Want to raise a SlackApiError for an invalid request. - # it "returns false if the selected channel is not valid" do - # VCR.use_cassette("message_post") do - # @workspace = Slack::Workspace.new - # @selected = @workspace.select_channel("doggos") - # @response = @workspace.send_message("Adorable doggos") - # end - - # expect(@response).must_equal false - # end - it "returns nil if a recipient has not been selected" do VCR.use_cassette("message_post") do @workspace = Slack::Workspace.new @@ -151,18 +140,3 @@ expect(@response).must_be_nil end end - -describe "Recipient class - NotImplementedError for Template methods" do - it "returns NotImplementedError for details method" do - @recipient = Slack::Recipient.new(name: "BotBot", slack_id: "UWSJKE") - expect do - @recipient.details - end.must_raise NotImplementedError - end - - it "returns NotImplementedError for Recipient.list method" do - expect do - Slack::Recipient.list - end.must_raise NotImplementedError - end -end From 3d019f44ab8b110c35212067845f37be3a7ee89e Mon Sep 17 00:00:00 2001 From: Nicky Choi Date: Fri, 13 Sep 2019 13:58:27 -0700 Subject: [PATCH 23/23] removed extra comments --- lib/workspace.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/workspace.rb b/lib/workspace.rb index 1d802aef..251d4426 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -30,12 +30,6 @@ def select_channel(identifier) def select_user(identifier) @users.each do |user| - # if user.name == identifier - # @selected = user - # return - # elsif user.slack_id == identifier - # @selected = user - # return if [user.name, user.slack_id].include?(identifier) @selected = user return @selected