From 4349d082fc3ff73700328ccdcbe641dd387ba0e7 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 9 Sep 2019 16:25:01 -0700 Subject: [PATCH 01/32] Started token verification. --- token_verification_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 token_verification_test.rb diff --git a/token_verification_test.rb b/token_verification_test.rb new file mode 100644 index 00000000..f34305cf --- /dev/null +++ b/token_verification_test.rb @@ -0,0 +1,26 @@ +# channels_list documentation: https://api.slack.com/methods/channels.list +# users_list: https://api.slack.com/methods/users.list +# chat.postMessage: https://api.slack.com/methods/chat.postMessage +require 'dotenv' +require 'httparty' + +Dotenv.load + +unless ENV['SLACK_TOKEN'] + puts "Could not load API key, please store in the environment variable 'SLACK_TOKEN'" + exit +end + +URL = "https://slack.com/api/channels.list" + +query_parameters = { + token: ENV['SLACK_TOKEN'] +} + +response = HTTParty.get(URL, query: query_parameters) +p response +# use HTTParty to send a GET request to the channels.list endpoint +# Check that the request completed successfully +# If the request wasn't completed successfully, print relevant info to console +# Loop through results and print out name of each channel +# Both partners should be able to sucessfully run this script From 6bced36f9be60bd8ef0afba2eb0cca487ad3c6bc Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 9 Sep 2019 19:19:02 -0700 Subject: [PATCH 02/32] Completed API token verification script. --- token_verification_test.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/token_verification_test.rb b/token_verification_test.rb index f34305cf..bfa6df12 100644 --- a/token_verification_test.rb +++ b/token_verification_test.rb @@ -1,6 +1,3 @@ -# channels_list documentation: https://api.slack.com/methods/channels.list -# users_list: https://api.slack.com/methods/users.list -# chat.postMessage: https://api.slack.com/methods/chat.postMessage require 'dotenv' require 'httparty' @@ -18,9 +15,11 @@ } response = HTTParty.get(URL, query: query_parameters) -p response -# use HTTParty to send a GET request to the channels.list endpoint -# Check that the request completed successfully -# If the request wasn't completed successfully, print relevant info to console -# Loop through results and print out name of each channel -# Both partners should be able to sucessfully run this script + +if response['ok'] == false + puts "Something went wrong: #{response['error']}" +else + response["channels"].each do |channel| + p channel["name"] + end +end \ No newline at end of file From 0913ab4fd31862788f41dd20f59cc58f5e7ea995 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 9 Sep 2019 19:37:58 -0700 Subject: [PATCH 03/32] Modified token verification loop sytax for readability. --- token_verification_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/token_verification_test.rb b/token_verification_test.rb index bfa6df12..9788ecb1 100644 --- a/token_verification_test.rb +++ b/token_verification_test.rb @@ -20,6 +20,6 @@ puts "Something went wrong: #{response['error']}" else response["channels"].each do |channel| - p channel["name"] + p "Channel: #{channel["name"]}" end end \ No newline at end of file From f9e9110d7cdcfe214f7de13d856e5d5969f2b8c8 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 9 Sep 2019 19:56:23 -0700 Subject: [PATCH 04/32] Added filter for sensitive data to protect Slack token identity. --- test/test_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 90aeb408..8ce457fa 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -14,4 +14,8 @@ VCR.configure do |config| config.cassette_library_dir = "test/cassettes" config.hook_into :webmock -end + + config.filter_sensitive_data("") do + ENV["SLACK_TOKEN"] + end +end \ No newline at end of file From 185bc2a175fa46c3046051f29775e3dd3101a79d Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 10 Sep 2019 13:59:30 -0700 Subject: [PATCH 05/32] Created acceptor, user lib files. --- lib/acceptor.rb | 0 lib/user.rb | 0 test/acceptor_test.rb | 0 test/test_helper.rb | 2 ++ test/user_test.rb | 0 5 files changed, 2 insertions(+) create mode 100644 lib/acceptor.rb create mode 100644 lib/user.rb create mode 100644 test/acceptor_test.rb create mode 100644 test/user_test.rb diff --git a/lib/acceptor.rb b/lib/acceptor.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/user.rb b/lib/user.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/acceptor_test.rb b/test/acceptor_test.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/test_helper.rb b/test/test_helper.rb index 8ce457fa..d292b698 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,6 +11,8 @@ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new +require_relative '../lib/acceptor' + VCR.configure do |config| config.cassette_library_dir = "test/cassettes" config.hook_into :webmock diff --git a/test/user_test.rb b/test/user_test.rb new file mode 100644 index 00000000..e69de29b From 55e1d8a12e1271ec092ea29ca8dce77e7b668b23 Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 10 Sep 2019 14:36:31 -0700 Subject: [PATCH 06/32] Instantiated User class, created first test. Commented out Acceptor for now. --- lib/acceptor.rb | 17 +++++++++++++++++ lib/slack.rb | 19 +++++++++++++++---- lib/user.rb | 20 ++++++++++++++++++++ test/test_helper.rb | 2 ++ test/user_test.rb | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 4 deletions(-) diff --git a/lib/acceptor.rb b/lib/acceptor.rb index e69de29b..5bafd5d2 100644 --- a/lib/acceptor.rb +++ b/lib/acceptor.rb @@ -0,0 +1,17 @@ +# module Slack +# class Acceptor +# attr_reader :slack_id, :name + +# def initialize(slack_id, name) +# @slack_id = slack_id +# @name = name +# end + + # def send_message(message) + # end + + # def self.get(url, query) + # end + +# end +# end \ No newline at end of file diff --git a/lib/slack.rb b/lib/slack.rb index 960cf2f7..d0d70b97 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,11 +1,22 @@ -#!/usr/bin/env ruby - def main + puts "Welcome to the Ada Slack CLI!" + # display info about how many channels & user there are + # provide 3 options for the user + puts "Please select from the following options: + List Users + List Channels + Quit" + + command = gets.chomp.downcase - # TODO project + if command == "quit" + exit + end + puts "Thank you for using the Ada Slack CLI" + end -main if __FILE__ == $PROGRAM_NAME \ No newline at end of file +main if __FILE__ == $PROGRAM_NAME diff --git a/lib/user.rb b/lib/user.rb index e69de29b..516da129 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -0,0 +1,20 @@ +module Slack + class User + attr_reader :name, :real_name, :slack_id + + def initialize(name:, real_name:, slack_id:) + @name = name + @real_name = real_name + @slack_id = slack_id + end + + def get_api + end + + def list + # response = self.get_api + end + + + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index d292b698..bd396d57 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,10 +8,12 @@ require 'minitest/reporters' require 'minitest/skip_dsl' require 'vcr' +require 'httparty' Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new require_relative '../lib/acceptor' +require_relative '../lib/user' VCR.configure do |config| config.cassette_library_dir = "test/cassettes" diff --git a/test/user_test.rb b/test/user_test.rb index e69de29b..2ad793db 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -0,0 +1,34 @@ +require_relative 'test_helper' + +describe "User" do + describe "initialize" do + it "establishes the base attributes when instantiated" do + user = Slack::User.new(name: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") + [:name, :real_name, :slack_id].each do |attribute| + expect(user).must_respond_to attribute + end + # expect(user.name).must_respond + # expect(user.real_name) + # expect(user.slack_id) + end + + end + + + + + + + + + + + + + + + + + + +end \ No newline at end of file From 361380a8fd18c7a24498ef43bc659cd4f74c26cc Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 10 Sep 2019 15:35:44 -0700 Subject: [PATCH 07/32] Added .get_api method to User class. Passed corresponding test. --- lib/user.rb | 31 +++++++++++++-- test/cassettes/user.yml | 85 +++++++++++++++++++++++++++++++++++++++++ test/test_helper.rb | 8 +++- test/user_test.rb | 25 +++++++++--- 4 files changed, 139 insertions(+), 10 deletions(-) create mode 100644 test/cassettes/user.yml diff --git a/lib/user.rb b/lib/user.rb index 516da129..4fe8735e 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -1,20 +1,43 @@ +# require 'dotenv' +# require 'awesome_print' +# require 'httparty' + +# Dotenv.load + module Slack class User - attr_reader :name, :real_name, :slack_id + attr_reader :username, :real_name, :slack_id - def initialize(name:, real_name:, slack_id:) - @name = name + def initialize(username:, real_name:, slack_id:) + @username = username @real_name = real_name @slack_id = slack_id end + URL = "https://slack.com/api/users.list" + def get_api + query_parameters = { + token: ENV['SLACK_TOKEN'] + } + return HTTParty.get(URL, query: query_parameters) end def list - # response = self.get_api + all_users = [] + api_members = self.get_api["members"] + api_members.each do |each_member| + username = each_member["name"] + real_name = each_member["real_name"] + slack_id = each_member["id"] + all_users << self.new(username: username, real_name: real_name, slack_id: slack_id) + end + return all_users end end end + +# user = Slack::User.new(name: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") +# ap user.get_api diff --git a/test/cassettes/user.yml b/test/cassettes/user.yml new file mode 100644 index 00000000..a5bdbf4f --- /dev/null +++ b/test/cassettes/user.yml @@ -0,0 +1,85 @@ +--- +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: + - '1480' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 22:17:24 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 3c9991b8-1f67-4154-84e3-2906c8c0d903 + 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-p70f + X-Cache: + - Miss from cloudfront + Via: + - 1.1 f126db770f21f288439f44d357978a27.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - 5fj0FURxC30oq1qKRoPIR1f9Y4p-s4mOIagHJ-dVfmt5hqVclvxgRQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"kristina.tanya","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"kristina.tanya","real_name_normalized":"kristina.tanya","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568067980,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela + Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela + Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela + Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy + Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy + Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy + Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568153844,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 22:17:24 GMT +recorded_with: VCR 5.0.0 diff --git a/test/test_helper.rb b/test/test_helper.rb index bd396d57..58fe693c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,8 +7,11 @@ require 'minitest/autorun' require 'minitest/reporters' require 'minitest/skip_dsl' +require "webmock/minitest" require 'vcr' +require "dotenv" require 'httparty' +Dotenv.load Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new @@ -18,7 +21,10 @@ 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 + } config.filter_sensitive_data("") do ENV["SLACK_TOKEN"] end diff --git a/test/user_test.rb b/test/user_test.rb index 2ad793db..d38f295c 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -1,19 +1,34 @@ require_relative 'test_helper' +require 'awesome_print' describe "User" do describe "initialize" do it "establishes the base attributes when instantiated" do - user = Slack::User.new(name: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") - [:name, :real_name, :slack_id].each do |attribute| + user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") + [:username, :real_name, :slack_id].each do |attribute| expect(user).must_respond_to attribute end - # expect(user.name).must_respond - # expect(user.real_name) - # expect(user.slack_id) end + end + + describe ".get_api" do + it "returns a instance of HTTParty::Response" do + user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") + VCR.use_cassette("user") do + @response = user.get_api + end + expect(@response).must_be_kind_of HTTParty::Response + expect(@response["members"]).must_be_kind_of Array + expect(@response["members"][0]["name"]).wont_be_nil + expect(@response["members"][0]["real_name"]).wont_be_nil + expect(@response["members"][0]["id"]).wont_be_nil + end + end + + From b41d1da93eca3dde27933c7d4544e75b7378c9e1 Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 10 Sep 2019 16:07:27 -0700 Subject: [PATCH 08/32] Created .list method for User and passed corresponding test. --- lib/user.rb | 7 ++- test/cassettes/user.yml | 98 +++++++++++++++++++++++++++++++++++++---- test/user_test.rb | 29 +++++++++--- 3 files changed, 117 insertions(+), 17 deletions(-) diff --git a/lib/user.rb b/lib/user.rb index 4fe8735e..59ffa863 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -30,14 +30,13 @@ def list username = each_member["name"] real_name = each_member["real_name"] slack_id = each_member["id"] - all_users << self.new(username: username, real_name: real_name, slack_id: slack_id) + all_users << User.new(username: username, real_name: real_name, slack_id: slack_id) end return all_users end - end end -# user = Slack::User.new(name: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") -# ap user.get_api +# user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") +# ap user.list diff --git a/test/cassettes/user.yml b/test/cassettes/user.yml index a5bdbf4f..d35e6971 100644 --- a/test/cassettes/user.yml +++ b/test/cassettes/user.yml @@ -21,17 +21,17 @@ http_interactions: Content-Type: - application/json; charset=utf-8 Content-Length: - - '1480' + - '1479' Connection: - keep-alive Date: - - Tue, 10 Sep 2019 22:17:24 GMT + - Tue, 10 Sep 2019 22:47:08 GMT Server: - Apache X-Content-Type-Options: - nosniff X-Slack-Req-Id: - - 3c9991b8-1f67-4154-84e3-2906c8c0d903 + - db82d1a4-2e06-48d3-9946-408fb78af018 X-Oauth-Scopes: - identify,channels:read,users:read,chat:write:bot Expires: @@ -57,15 +57,15 @@ http_interactions: Access-Control-Allow-Origin: - "*" X-Via: - - haproxy-www-p70f + - haproxy-www-40z3 X-Cache: - Miss from cloudfront Via: - - 1.1 f126db770f21f288439f44d357978a27.cloudfront.net (CloudFront) + - 1.1 f313d3df80c4dab8f5399614116801cd.cloudfront.net (CloudFront) X-Amz-Cf-Pop: - SEA19-C1 X-Amz-Cf-Id: - - 5fj0FURxC30oq1qKRoPIR1f9Y4p-s4mOIagHJ-dVfmt5hqVclvxgRQ== + - o8GrT8bFUIlTdjwtb7HX6rnppWmfYNFV8isNNEgFJ8Xa0PyOlcwVCA== body: encoding: ASCII-8BIT string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","name":"slackbot","deleted":false,"color":"757575","real_name":"Slackbot","tz":null,"tz_label":"Pacific @@ -79,7 +79,89 @@ http_interactions: Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568153844,"response_metadata":{"next_cursor":""}}' + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568155628,"response_metadata":{"next_cursor":""}}' http_version: - recorded_at: Tue, 10 Sep 2019 22:17:24 GMT + recorded_at: Tue, 10 Sep 2019 22:47:08 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: + - '1479' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 23:01:28 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - c00e8ca0-d242-4094-a621-2b469436b57d + 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-mar4 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 6a6653dfb47ccc5082f2a5b9d0d168ce.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - O7NzNqIuHF--XNk_WUoepNmDmvUiN5K2i4cul-dRQnONOtZKqnuIBQ== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"kristina.tanya","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"kristina.tanya","real_name_normalized":"kristina.tanya","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568067980,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela + Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela + Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela + Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy + Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy + Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy + Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568156488,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 23:01:28 GMT recorded_with: VCR 5.0.0 diff --git a/test/user_test.rb b/test/user_test.rb index d38f295c..1d4c3832 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -2,6 +2,14 @@ require 'awesome_print' describe "User" do + before do + @user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") + VCR.use_cassette("user") do + @response = @user.get_api + @list = @user.list + end + end + describe "initialize" do it "establishes the base attributes when instantiated" do user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") @@ -13,20 +21,31 @@ describe ".get_api" do it "returns a instance of HTTParty::Response" do - user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") - VCR.use_cassette("user") do - @response = user.get_api - end + # user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") + # VCR.use_cassette("user") do + # @response = user.get_api + # end expect(@response).must_be_kind_of HTTParty::Response expect(@response["members"]).must_be_kind_of Array expect(@response["members"][0]["name"]).wont_be_nil expect(@response["members"][0]["real_name"]).wont_be_nil expect(@response["members"][0]["id"]).wont_be_nil end + end + describe ".list" do + it "returns an array of User objects" do + expect(@list).must_be_kind_of Array + expect(@list[0]).must_be_instance_of Slack::User + end + it "returns an array with the correct length" do + expect(@list.length).must_equal 7 + end + end - + + From 20bf96d8d7c121e2b1f13e3185c4ec09e7b9ba6b Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 10 Sep 2019 16:33:12 -0700 Subject: [PATCH 09/32] Created a .print_list method for User, to print the username, real name, Slack ID to the console. --- lib/user.rb | 14 ++++++- test/cassettes/user.yml | 82 +++++++++++++++++++++++++++++++++++++++++ test/user_test.rb | 12 +++--- 3 files changed, 102 insertions(+), 6 deletions(-) diff --git a/lib/user.rb b/lib/user.rb index 59ffa863..c3eb3e93 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -32,11 +32,23 @@ def list slack_id = each_member["id"] all_users << User.new(username: username, real_name: real_name, slack_id: slack_id) end - return all_users + return all_users end + def print_list + all_users = self.list + user_counter = 0 + result = nil + all_users.each do |each_user| + user_counter += 1 + result = result + "User #{user_counter} - username: #{each_user.username}, real name: #{each_user.real_name}, Slack ID: #{each_user.slack_id}\n" + print result + end + return result + end end end # user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") # ap user.list + diff --git a/test/cassettes/user.yml b/test/cassettes/user.yml index d35e6971..2947b30b 100644 --- a/test/cassettes/user.yml +++ b/test/cassettes/user.yml @@ -164,4 +164,86 @@ http_interactions: Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568156488,"response_metadata":{"next_cursor":""}}' http_version: recorded_at: Tue, 10 Sep 2019 23:01:28 GMT +- request: + method: get + uri: https://slack.com/api/users.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1480' + Connection: + - keep-alive + Date: + - Tue, 10 Sep 2019 23:19:35 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 190cc3fd-8b80-402d-9bfc-fc37bb5ce735 + 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-ggim + X-Cache: + - Miss from cloudfront + Via: + - 1.1 1002c05e647d0804e83147cdd205d14a.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - xDSzxhHkZhdkyu8vuTaEWwi7-Rzw3MMKo6ND_kpRM3dgQkcJl1bp_g== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"kristina.tanya","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"kristina.tanya","real_name_normalized":"kristina.tanya","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568067980,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela + Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela + Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela + Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy + Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy + Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy + Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568157575,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Tue, 10 Sep 2019 23:19:35 GMT recorded_with: VCR 5.0.0 diff --git a/test/user_test.rb b/test/user_test.rb index 1d4c3832..8ed8242c 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -7,6 +7,7 @@ VCR.use_cassette("user") do @response = @user.get_api @list = @user.list + @print_list = @user.print_list end end @@ -21,10 +22,6 @@ describe ".get_api" do it "returns a instance of HTTParty::Response" do - # user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") - # VCR.use_cassette("user") do - # @response = user.get_api - # end expect(@response).must_be_kind_of HTTParty::Response expect(@response["members"]).must_be_kind_of Array expect(@response["members"][0]["name"]).wont_be_nil @@ -42,7 +39,12 @@ it "returns an array with the correct length" do expect(@list.length).must_equal 7 end - + end + + describe ".print_list" do + it "displays the username, real name, and Slack ID for all users of workspace" do + expect(@print_list).must_be_kind_of String + end end From 14588c4393bbc1d16793746178e93ab0291e1ee4 Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 10 Sep 2019 16:46:26 -0700 Subject: [PATCH 10/32] Added new channel and workspace files. --- lib/channel.rb | 0 lib/slack.rb | 15 ++++++++++++++- lib/workspace.rb | 0 test/channel_test.rb | 0 test/test_helper.rb | 2 ++ test/workspace.rb | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 lib/channel.rb create mode 100644 lib/workspace.rb create mode 100644 test/channel_test.rb create mode 100644 test/workspace.rb diff --git a/lib/channel.rb b/lib/channel.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/slack.rb b/lib/slack.rb index d0d70b97..24e11b83 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,3 +1,7 @@ +require_relative "user" +# require_relative "" +# require_relative "" + def main puts "Welcome to the Ada Slack CLI!" @@ -10,8 +14,17 @@ def main command = gets.chomp.downcase - if command == "quit" + # loop through if user inputs aljdflkasdf + # if command == "quit" + # exit + # elsif command == "list users" + # elseif + case command + when "quit" exit + when "list users" + Slack::User.print_list + when "list channels" end diff --git a/lib/workspace.rb b/lib/workspace.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/channel_test.rb b/test/channel_test.rb new file mode 100644 index 00000000..e69de29b diff --git a/test/test_helper.rb b/test/test_helper.rb index 58fe693c..f2abcbd7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,6 +17,8 @@ require_relative '../lib/acceptor' require_relative '../lib/user' +require_relative '../lib/channel' +require_relative '../lib/workspace' VCR.configure do |config| config.cassette_library_dir = "test/cassettes" diff --git a/test/workspace.rb b/test/workspace.rb new file mode 100644 index 00000000..0519ecba --- /dev/null +++ b/test/workspace.rb @@ -0,0 +1 @@ + \ No newline at end of file From 9ffa927a4ed48049f4aff25863087817025fb2e0 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 08:57:24 -0700 Subject: [PATCH 11/32] Formatted CLI Main to re-print commands when given bad input --- lib/slack.rb | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 24e11b83..af9ea522 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,35 +1,38 @@ +require_relative "workspace" require_relative "user" -# require_relative "" -# require_relative "" +require_relative "channel" +require_relative "acceptor" def main puts "Welcome to the Ada Slack CLI!" - # display info about how many channels & user there are - # provide 3 options for the user - puts "Please select from the following options: + # TO-DO: Display total count of users and channels + + prompt = "Please select from the following options: List Users List Channels Quit" - command = gets.chomp.downcase - - # loop through if user inputs aljdflkasdf - # if command == "quit" - # exit - # elsif command == "list users" - # elseif - case command - when "quit" - exit - when "list users" - Slack::User.print_list - when "list channels" + puts prompt + + while command = gets.chomp.downcase + case command + when "quit" + exit + # when "list users" + # TO-DO: call print_list method for user + # break - to avoid asking for more input + # when "list channels" + # TO-DO: call print_list method for channel + # break - to avoid asking for more input + else + puts "Error: Invalid selection. Returning to main menu...." + puts prompt + end end - - puts "Thank you for using the Ada Slack CLI" end main if __FILE__ == $PROGRAM_NAME + From f5e5b96eb4fd6b917384018579aca7888086a3d5 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 09:44:09 -0700 Subject: [PATCH 12/32] Removed line in .gitignore so that VCR cassettes can be tracked. --- .gitignore | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 8d6a243f..b1d9ae7c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,10 @@ /tmp/ # Used by dotenv library to load environment variables. -# .env +.env + +# Ignore environment variables +.env ## Specific to RubyMotion: .dat* @@ -48,9 +51,3 @@ build-iPhoneSimulator/ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc - -# Ignore environemnt variables -.env - -# Ignore cassette files -/specs/cassettes/ From 1dbdd9f55f3f96cf57855b985a62bafbf8eba4f6 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 09:44:27 -0700 Subject: [PATCH 13/32] Created scaffolding for Workspace --- lib/workspace.rb | 27 +++++++++++++++++++++++++++ test/workspace.rb | 1 - 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/workspace.rb b/lib/workspace.rb index e69de29b..d8799140 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -0,0 +1,27 @@ +module Slack + class Workspace + # attr_reader + def initialize + @users = [] + @channels = [] + @selected = [] + end + + # def select_user + # code + # end + + # def select_channel + # code + # end + + # def show_details + # code + # end + + # def send_message + # code + # end + + end +end \ No newline at end of file diff --git a/test/workspace.rb b/test/workspace.rb index 0519ecba..e69de29b 100644 --- a/test/workspace.rb +++ b/test/workspace.rb @@ -1 +0,0 @@ - \ No newline at end of file From 59afa9682df87fc6c15297b5b795a4d3c4e5c941 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 10:41:47 -0700 Subject: [PATCH 14/32] Scaffolding workspace/user composition. --- lib/user.rb | 2 +- lib/workspace.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/user.rb b/lib/user.rb index c3eb3e93..baf65c3e 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -30,7 +30,7 @@ def list username = each_member["name"] real_name = each_member["real_name"] slack_id = each_member["id"] - all_users << User.new(username: username, real_name: real_name, slack_id: slack_id) + all_users << Slack::User.new(username: username, real_name: real_name, slack_id: slack_id) end return all_users end diff --git a/lib/workspace.rb b/lib/workspace.rb index d8799140..587dd4e8 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,3 +1,7 @@ +require_relative "user" +require_relative "channel" +require_relative "acceptor" + module Slack class Workspace # attr_reader @@ -7,6 +11,15 @@ def initialize @selected = [] end + # call user api method - OR MAYBE NOT B/C LIST CALLS GET_API + # TO-DO: should we make get_api a class method in User? + # TO-DO: decide on how this interacts with the CLI + # call user list method + users = Workspace::User.list #store the return value of .list inside of the users + # iterate through users and call instance variables on user + # for each user in users, puts user.username, user.real_name, user.slack_id + # end + # def select_user # code # end From f4fe7748234080e30347f963807371945aa42228 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 13:28:03 -0700 Subject: [PATCH 15/32] Moved user methods inside of Workspace. Work in progress. --- lib/user.rb | 26 +++++------ lib/workspace.rb | 22 ++++++++- test/cassettes/workspace.yml | 86 ++++++++++++++++++++++++++++++++++++ test/workspace.rb | 0 test/workspace_test.rb | 17 +++++++ 5 files changed, 137 insertions(+), 14 deletions(-) create mode 100644 test/cassettes/workspace.yml delete mode 100644 test/workspace.rb create mode 100644 test/workspace_test.rb diff --git a/lib/user.rb b/lib/user.rb index baf65c3e..6b712a5b 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -16,14 +16,14 @@ def initialize(username:, real_name:, slack_id:) URL = "https://slack.com/api/users.list" - def get_api + def self.get_api query_parameters = { token: ENV['SLACK_TOKEN'] } return HTTParty.get(URL, query: query_parameters) end - def list + def self.list all_users = [] api_members = self.get_api["members"] api_members.each do |each_member| @@ -35,17 +35,17 @@ def list return all_users end - def print_list - all_users = self.list - user_counter = 0 - result = nil - all_users.each do |each_user| - user_counter += 1 - result = result + "User #{user_counter} - username: #{each_user.username}, real name: #{each_user.real_name}, Slack ID: #{each_user.slack_id}\n" - print result - end - return result - end + # def print_list + # all_users = self.list + # user_counter = 0 + # result = nil + # all_users.each do |each_user| + # user_counter += 1 + # result = result + "User #{user_counter} - username: #{each_user.username}, real name: #{each_user.real_name}, Slack ID: #{each_user.slack_id}\n" + # print result + # end + # return result + # end end end diff --git a/lib/workspace.rb b/lib/workspace.rb index 587dd4e8..19e4ab50 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -14,8 +14,28 @@ def initialize # call user api method - OR MAYBE NOT B/C LIST CALLS GET_API # TO-DO: should we make get_api a class method in User? # TO-DO: decide on how this interacts with the CLI + # end + + def get_api + URL = "https://slack.com/api/users.list" + query_parameters = { + token: ENV['SLACK_TOKEN'] + } + return HTTParty.get(URL, query: query_parameters) + end + + def user_list + api_members = self.get_api["members"] + api_members.each do |each_member| + username = each_member["name"] + real_name = each_member["real_name"] + slack_id = each_member["id"] + @users << Slack::User.new(username: username, real_name: real_name, slack_id: slack_id) + end + end + # call user list method - users = Workspace::User.list #store the return value of .list inside of the users + # users = Slack::User.list #store the return value of .list inside of the users # iterate through users and call instance variables on user # for each user in users, puts user.username, user.real_name, user.slack_id # end diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml new file mode 100644 index 00000000..8f93ea19 --- /dev/null +++ b/test/cassettes/workspace.yml @@ -0,0 +1,86 @@ +--- +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: + - '1463' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 20:15:17 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - b4ec2b03-d212-4857-b2d6-04d6949f2d58 + 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-1zz5 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 fec77e486350d1bd33f526a760d8b5a4.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - froaetbkDLuOt3HN5MYUNLP0UsXKky9_VZ4L3Enr0agmIVwoWiGF9A== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"Kristina + M","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kristina + M","real_name_normalized":"Kristina M","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","first_name":"Kristina","last_name":"M","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568159573,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela + Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela + Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela + Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy + Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy + Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy + Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568185310,"has_2fa":false}],"cache_ts":1568232917,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 20:15:17 GMT +recorded_with: VCR 5.0.0 diff --git a/test/workspace.rb b/test/workspace.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/test/workspace_test.rb b/test/workspace_test.rb new file mode 100644 index 00000000..68fce956 --- /dev/null +++ b/test/workspace_test.rb @@ -0,0 +1,17 @@ +require_relative 'test_helper' + +describe "Workspace" do + describe "initialize" do + it "can be initialized" do + workspace = Slack::Workspace.new + # response = Slack::User.get_api + expect(workspace).must_be_kind_of Slack::Workspace + end + + + + + + + end +end \ No newline at end of file From f7a7f4174792c35552369f56a2ef890adfdb8749 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 13:52:44 -0700 Subject: [PATCH 16/32] Successfully instantiated Workspace, creates users within instance variable @users. --- lib/user.rb | 34 ++--- lib/workspace.rb | 14 +- test/cassettes/user.yml | 249 ----------------------------------- test/cassettes/workspace.yml | 86 ------------ test/test_helper.rb | 24 ++-- test/user_test.rb | 98 +++++++------- test/workspace_test.rb | 5 + 7 files changed, 94 insertions(+), 416 deletions(-) diff --git a/lib/user.rb b/lib/user.rb index 6b712a5b..34c6df9a 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -16,24 +16,24 @@ def initialize(username:, real_name:, slack_id:) URL = "https://slack.com/api/users.list" - def self.get_api - query_parameters = { - token: ENV['SLACK_TOKEN'] - } - return HTTParty.get(URL, query: query_parameters) - end + # def self.get_api + # query_parameters = { + # token: ENV['SLACK_TOKEN'] + # } + # return HTTParty.get(URL, query: query_parameters) + # end - def self.list - all_users = [] - api_members = self.get_api["members"] - api_members.each do |each_member| - username = each_member["name"] - real_name = each_member["real_name"] - slack_id = each_member["id"] - all_users << Slack::User.new(username: username, real_name: real_name, slack_id: slack_id) - end - return all_users - end + # def self.list + # all_users = [] + # api_members = self.get_api["members"] + # api_members.each do |each_member| + # username = each_member["name"] + # real_name = each_member["real_name"] + # slack_id = each_member["id"] + # all_users << Slack::User.new(username: username, real_name: real_name, slack_id: slack_id) + # end + # return all_users + # end # def print_list # all_users = self.list diff --git a/lib/workspace.rb b/lib/workspace.rb index 19e4ab50..7d2b5bfc 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -2,9 +2,14 @@ require_relative "channel" require_relative "acceptor" +require 'awesome_print' + module Slack class Workspace - # attr_reader + URL = "https://slack.com/api/users.list" + + attr_reader :users, :channels, :selected + def initialize @users = [] @channels = [] @@ -17,7 +22,6 @@ def initialize # end def get_api - URL = "https://slack.com/api/users.list" query_parameters = { token: ENV['SLACK_TOKEN'] } @@ -57,4 +61,8 @@ def user_list # end end -end \ No newline at end of file +end + +hello = Slack::Workspace.new +hello.user_list +ap hello.users diff --git a/test/cassettes/user.yml b/test/cassettes/user.yml index 2947b30b..e69de29b 100644 --- a/test/cassettes/user.yml +++ b/test/cassettes/user.yml @@ -1,249 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://slack.com/api/users.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '1479' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 22:47:08 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - db82d1a4-2e06-48d3-9946-408fb78af018 - 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-40z3 - X-Cache: - - Miss from cloudfront - Via: - - 1.1 f313d3df80c4dab8f5399614116801cd.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - o8GrT8bFUIlTdjwtb7HX6rnppWmfYNFV8isNNEgFJ8Xa0PyOlcwVCA== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"kristina.tanya","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"kristina.tanya","real_name_normalized":"kristina.tanya","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568067980,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela - Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela - Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela - Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy - Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy - Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy - Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568155628,"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 22:47:08 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: - - '1479' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 23:01:28 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - c00e8ca0-d242-4094-a621-2b469436b57d - 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-mar4 - X-Cache: - - Miss from cloudfront - Via: - - 1.1 6a6653dfb47ccc5082f2a5b9d0d168ce.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - O7NzNqIuHF--XNk_WUoepNmDmvUiN5K2i4cul-dRQnONOtZKqnuIBQ== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"kristina.tanya","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"kristina.tanya","real_name_normalized":"kristina.tanya","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568067980,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela - Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela - Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela - Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy - Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy - Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy - Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568156488,"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 23:01:28 GMT -- request: - method: get - uri: https://slack.com/api/users.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '1480' - Connection: - - keep-alive - Date: - - Tue, 10 Sep 2019 23:19:35 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - 190cc3fd-8b80-402d-9bfc-fc37bb5ce735 - 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-ggim - X-Cache: - - Miss from cloudfront - Via: - - 1.1 1002c05e647d0804e83147cdd205d14a.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - xDSzxhHkZhdkyu8vuTaEWwi7-Rzw3MMKo6ND_kpRM3dgQkcJl1bp_g== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"kristina.tanya","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"kristina.tanya","real_name_normalized":"kristina.tanya","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568067980,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela - Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela - Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela - Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy - Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy - Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy - Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"borking","status_emoji":":star-struck:","status_expiration":1568185199,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568150826,"has_2fa":false}],"cache_ts":1568157575,"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Tue, 10 Sep 2019 23:19:35 GMT -recorded_with: VCR 5.0.0 diff --git a/test/cassettes/workspace.yml b/test/cassettes/workspace.yml index 8f93ea19..e69de29b 100644 --- a/test/cassettes/workspace.yml +++ b/test/cassettes/workspace.yml @@ -1,86 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://slack.com/api/users.list?token= - body: - encoding: US-ASCII - string: '' - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json; charset=utf-8 - Content-Length: - - '1463' - Connection: - - keep-alive - Date: - - Wed, 11 Sep 2019 20:15:17 GMT - Server: - - Apache - X-Content-Type-Options: - - nosniff - X-Slack-Req-Id: - - b4ec2b03-d212-4857-b2d6-04d6949f2d58 - 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-1zz5 - X-Cache: - - Miss from cloudfront - Via: - - 1.1 fec77e486350d1bd33f526a760d8b5a4.cloudfront.net (CloudFront) - X-Amz-Cf-Pop: - - SEA19-C1 - X-Amz-Cf-Id: - - froaetbkDLuOt3HN5MYUNLP0UsXKky9_VZ4L3Enr0agmIVwoWiGF9A== - body: - encoding: ASCII-8BIT - string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"Kristina - M","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kristina - M","real_name_normalized":"Kristina M","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","first_name":"Kristina","last_name":"M","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568159573,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela - Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela - Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela - Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy - Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy - Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy - Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific - Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568185310,"has_2fa":false}],"cache_ts":1568232917,"response_metadata":{"next_cursor":""}}' - http_version: - recorded_at: Wed, 11 Sep 2019 20:15:17 GMT -recorded_with: VCR 5.0.0 diff --git a/test/test_helper.rb b/test/test_helper.rb index f2abcbd7..7b00bc03 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,7 +7,7 @@ require 'minitest/autorun' require 'minitest/reporters' require 'minitest/skip_dsl' -require "webmock/minitest" +# require "webmock/minitest" require 'vcr' require "dotenv" require 'httparty' @@ -20,14 +20,14 @@ require_relative '../lib/channel' require_relative '../lib/workspace' -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 - } - config.filter_sensitive_data("") do - ENV["SLACK_TOKEN"] - end -end \ No newline at end of file +# 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 +# } +# config.filter_sensitive_data("") do +# ENV["SLACK_TOKEN"] +# end +# end \ No newline at end of file diff --git a/test/user_test.rb b/test/user_test.rb index 8ed8242c..16caa88a 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -1,51 +1,51 @@ -require_relative 'test_helper' -require 'awesome_print' - -describe "User" do - before do - @user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") - VCR.use_cassette("user") do - @response = @user.get_api - @list = @user.list - @print_list = @user.print_list - end - end - - describe "initialize" do - it "establishes the base attributes when instantiated" do - user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") - [:username, :real_name, :slack_id].each do |attribute| - expect(user).must_respond_to attribute - end - end - end - - describe ".get_api" do - it "returns a instance of HTTParty::Response" do - expect(@response).must_be_kind_of HTTParty::Response - expect(@response["members"]).must_be_kind_of Array - expect(@response["members"][0]["name"]).wont_be_nil - expect(@response["members"][0]["real_name"]).wont_be_nil - expect(@response["members"][0]["id"]).wont_be_nil - end - end - - describe ".list" do - it "returns an array of User objects" do - expect(@list).must_be_kind_of Array - expect(@list[0]).must_be_instance_of Slack::User - end - - it "returns an array with the correct length" do - expect(@list.length).must_equal 7 - end - end - - describe ".print_list" do - it "displays the username, real name, and Slack ID for all users of workspace" do - expect(@print_list).must_be_kind_of String - end - end +# require_relative 'test_helper' +# require 'awesome_print' + +# describe "User" do +# before do +# @user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") +# VCR.use_cassette("user") do +# @response = @user.get_api +# @list = @user.list +# @print_list = @user.print_list +# end +# end + +# describe "initialize" do +# it "establishes the base attributes when instantiated" do +# user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") +# [:username, :real_name, :slack_id].each do |attribute| +# expect(user).must_respond_to attribute +# end +# end +# end + +# describe ".get_api" do +# it "returns a instance of HTTParty::Response" do +# expect(@response).must_be_kind_of HTTParty::Response +# expect(@response["members"]).must_be_kind_of Array +# expect(@response["members"][0]["name"]).wont_be_nil +# expect(@response["members"][0]["real_name"]).wont_be_nil +# expect(@response["members"][0]["id"]).wont_be_nil +# end +# end + +# describe ".list" do +# it "returns an array of User objects" do +# expect(@list).must_be_kind_of Array +# expect(@list[0]).must_be_instance_of Slack::User +# end + +# it "returns an array with the correct length" do +# expect(@list.length).must_equal 7 +# end +# end + +# describe ".print_list" do +# it "displays the username, real name, and Slack ID for all users of workspace" do +# expect(@print_list).must_be_kind_of String +# end +# end @@ -67,4 +67,4 @@ -end \ No newline at end of file +# end \ No newline at end of file diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 68fce956..bf40f665 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -4,8 +4,13 @@ describe "initialize" do it "can be initialized" do workspace = Slack::Workspace.new + workspace.user_list + # response = Slack::User.get_api expect(workspace).must_be_kind_of Slack::Workspace + expect(workspace.users).must_be_kind_of Array + expect(workspace.users[0]).must_be_kind_of Slack::User + end From 02c4e54970a3351ee964ab4cef08ce58b174c5a7 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 14:17:45 -0700 Subject: [PATCH 17/32] Wrote test for workspace intialize and workspace get_api test passing --- lib/slack.rb | 12 +++-- lib/user.rb | 43 ---------------- lib/workspace.rb | 35 +++++++------ test/cassettes/workspace_user.yml | 86 +++++++++++++++++++++++++++++++ test/test_helper.rb | 24 ++++----- test/workspace_test.rb | 22 +++++--- 6 files changed, 140 insertions(+), 82 deletions(-) create mode 100644 test/cassettes/workspace_user.yml diff --git a/lib/slack.rb b/lib/slack.rb index af9ea522..3957bb03 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -2,11 +2,17 @@ require_relative "user" require_relative "channel" require_relative "acceptor" +require 'httparty' +require "dotenv" +Dotenv.load def main puts "Welcome to the Ada Slack CLI!" # TO-DO: Display total count of users and channels + workspace = Slack::Workspace.new + workspace.user_list + puts "Darn Cute Puppers has #{workspace.users.count} users." prompt = "Please select from the following options: List Users @@ -19,9 +25,9 @@ def main case command when "quit" exit - # when "list users" - # TO-DO: call print_list method for user - # break - to avoid asking for more input + when "list users" + puts workspace.print_user_list + break # when "list channels" # TO-DO: call print_list method for channel # break - to avoid asking for more input diff --git a/lib/user.rb b/lib/user.rb index 34c6df9a..0ae88252 100644 --- a/lib/user.rb +++ b/lib/user.rb @@ -1,9 +1,3 @@ -# require 'dotenv' -# require 'awesome_print' -# require 'httparty' - -# Dotenv.load - module Slack class User attr_reader :username, :real_name, :slack_id @@ -13,42 +7,5 @@ def initialize(username:, real_name:, slack_id:) @real_name = real_name @slack_id = slack_id end - - URL = "https://slack.com/api/users.list" - - # def self.get_api - # query_parameters = { - # token: ENV['SLACK_TOKEN'] - # } - # return HTTParty.get(URL, query: query_parameters) - # end - - # def self.list - # all_users = [] - # api_members = self.get_api["members"] - # api_members.each do |each_member| - # username = each_member["name"] - # real_name = each_member["real_name"] - # slack_id = each_member["id"] - # all_users << Slack::User.new(username: username, real_name: real_name, slack_id: slack_id) - # end - # return all_users - # end - - # def print_list - # all_users = self.list - # user_counter = 0 - # result = nil - # all_users.each do |each_user| - # user_counter += 1 - # result = result + "User #{user_counter} - username: #{each_user.username}, real name: #{each_user.real_name}, Slack ID: #{each_user.slack_id}\n" - # print result - # end - # return result - # end end end - -# user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") -# ap user.list - diff --git a/lib/workspace.rb b/lib/workspace.rb index 7d2b5bfc..a2277b8c 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -6,7 +6,8 @@ module Slack class Workspace - URL = "https://slack.com/api/users.list" + USER_URL = "https://slack.com/api/users.list" + # URL2 = attr_reader :users, :channels, :selected @@ -16,20 +17,16 @@ def initialize @selected = [] end - # call user api method - OR MAYBE NOT B/C LIST CALLS GET_API - # TO-DO: should we make get_api a class method in User? - # TO-DO: decide on how this interacts with the CLI - # end - - def get_api + def get_api(url) query_parameters = { token: ENV['SLACK_TOKEN'] } - return HTTParty.get(URL, query: query_parameters) + return HTTParty.get(url, query: query_parameters) end def user_list - api_members = self.get_api["members"] + api_user_response = get_api(USER_URL) + api_members = api_user_response["members"] api_members.each do |each_member| username = each_member["name"] real_name = each_member["real_name"] @@ -38,11 +35,15 @@ def user_list end end - # call user list method - # users = Slack::User.list #store the return value of .list inside of the users - # iterate through users and call instance variables on user - # for each user in users, puts user.username, user.real_name, user.slack_id - # end + def print_user_list + user_counter = 0 + result = '' + @users.each do |each_user| + user_counter += 1 + result = result + "User #{user_counter} - username: #{each_user.username}, real name: #{each_user.real_name}, Slack ID: #{each_user.slack_id}\n" + end + return result + end # def select_user # code @@ -63,6 +64,6 @@ def user_list end end -hello = Slack::Workspace.new -hello.user_list -ap hello.users +# hello = Slack::Workspace.new +# hello.user_list +# puts hello.print_user_list diff --git a/test/cassettes/workspace_user.yml b/test/cassettes/workspace_user.yml new file mode 100644 index 00000000..9d64162e --- /dev/null +++ b/test/cassettes/workspace_user.yml @@ -0,0 +1,86 @@ +--- +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: + - '1463' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:13:49 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 622eef41-585c-4cc4-b37b-717ce3bb3e35 + 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-x0x4 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 ec2a2c75c16156e4d43504606c118b91.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - 8rd_VRwpAz-Vjb5DL9LO2ubPWuPwIHSEL64z8jmk2tJrcePl3yfZ6Q== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"members":[{"id":"USLACKBOT","team_id":"TN843TM63","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":"TN843TM63"},"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":"UMTERDBPU","team_id":"TN843TM63","name":"kristina.tanya","deleted":false,"color":"9f69e7","real_name":"Kristina + M","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Kristina + M","real_name_normalized":"Kristina M","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g3e9b0330d1c","first_name":"Kristina","last_name":"M","image_24":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/3e9b0330d1c2e104f1d9dbe0c6d81104.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0021-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568159573,"has_2fa":false},{"id":"UMURAK10T","team_id":"TN843TM63","name":"rvesteinsdottir","deleted":false,"color":"3c989f","real_name":"Raisah","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Raisah","real_name_normalized":"Raisah","display_name":"Raisah","display_name_normalized":"Raisah","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g1166bfab69b","image_24":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/1166bfab69bc4d1c79dcb245ee03288a.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0026-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071907,"has_2fa":false},{"id":"UMURAL35H","team_id":"TN843TM63","name":"dnsanche","deleted":false,"color":"e96699","real_name":"Daniela + Sanchez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Daniela + Sanchez","real_name_normalized":"Daniela Sanchez","display_name":"Daniela + Sanchez","display_name_normalized":"Daniela Sanchez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb0d197e7328","image_24":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b0d197e73289b9054faa0517726ff139.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0006-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568072127,"has_2fa":false},{"id":"UN69JKYQ0","team_id":"TN843TM63","name":"cloudylopez","deleted":false,"color":"674b1b","real_name":"Cloudy + Lopez","tz":"America\/Los_Angeles","tz_label":"Pacific Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Cloudy + Lopez","real_name_normalized":"Cloudy Lopez","display_name":"Cloudy Lopez","display_name_normalized":"Cloudy + Lopez","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g877656756b0","image_24":"https:\/\/secure.gravatar.com\/avatar\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.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\/877656756b0aed370014507bf3552664.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0009-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568071916,"has_2fa":false},{"id":"UN69RK75K","team_id":"TN843TM63","name":"gyjinn","deleted":false,"color":"4bbe2e","real_name":"Ga-Young","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"Ga-Young","real_name_normalized":"Ga-Young","display_name":"","display_name_normalized":"","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"g816359af264","image_24":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/816359af2646dc0038a37f6704efd389.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0005-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568130004,"has_2fa":false},{"id":"UN85KTCHM","team_id":"TN843TM63","name":"alicesunhi","deleted":false,"color":"e7392d","real_name":"taro","tz":"America\/Los_Angeles","tz_label":"Pacific + Daylight Time","tz_offset":-25200,"profile":{"title":"","phone":"","skype":"","real_name":"taro","real_name_normalized":"taro","display_name":"taro","display_name_normalized":"taro","status_text":"","status_emoji":"","status_expiration":0,"avatar_hash":"gb68b3fce35e","image_24":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-24.png","image_32":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-32.png","image_48":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-48.png","image_72":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-72.png","image_192":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-192.png","image_512":"https:\/\/secure.gravatar.com\/avatar\/b68b3fce35eedec31832996b6e7a6bd3.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F80588%2Fimg%2Favatars%2Fuser_shapes%2Fava_0017-512.png","status_text_canonical":"","team":"TN843TM63"},"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":1568185310,"has_2fa":false}],"cache_ts":1568236429,"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:13:49 GMT +recorded_with: VCR 5.0.0 diff --git a/test/test_helper.rb b/test/test_helper.rb index 7b00bc03..f2abcbd7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,7 +7,7 @@ require 'minitest/autorun' require 'minitest/reporters' require 'minitest/skip_dsl' -# require "webmock/minitest" +require "webmock/minitest" require 'vcr' require "dotenv" require 'httparty' @@ -20,14 +20,14 @@ require_relative '../lib/channel' require_relative '../lib/workspace' -# 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 -# } -# config.filter_sensitive_data("") do -# ENV["SLACK_TOKEN"] -# end -# end \ No newline at end of file +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 + } + config.filter_sensitive_data("") do + ENV["SLACK_TOKEN"] + end +end \ No newline at end of file diff --git a/test/workspace_test.rb b/test/workspace_test.rb index bf40f665..8a5f1a43 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -3,16 +3,24 @@ describe "Workspace" do describe "initialize" do it "can be initialized" do - workspace = Slack::Workspace.new - workspace.user_list - - # response = Slack::User.get_api + workspace = Slack::Workspace.new + # VCR.use_cassette("workspace_user") do + # @response = workspace.user_list + # end expect(workspace).must_be_kind_of Slack::Workspace - expect(workspace.users).must_be_kind_of Array - expect(workspace.users[0]).must_be_kind_of Slack::User - end + end + describe "workspace methods" do + describe "get_api" do + it "returns a response from Slack api" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + @response = workspace.get_api("https://slack.com/api/users.list") + end + expect(@response).must_be_kind_of HTTParty::Response + end + end From 006161edc83209c7784dcdc9856453bf245ad8b0 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 14:38:05 -0700 Subject: [PATCH 18/32] Modified user test to only test for intialized attributes. --- test/user_test.rb | 83 +++++++----------------------------------- test/workspace_test.rb | 32 +++++++++++++--- 2 files changed, 39 insertions(+), 76 deletions(-) diff --git a/test/user_test.rb b/test/user_test.rb index 16caa88a..3b58a228 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -1,70 +1,13 @@ -# require_relative 'test_helper' -# require 'awesome_print' - -# describe "User" do -# before do -# @user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") -# VCR.use_cassette("user") do -# @response = @user.get_api -# @list = @user.list -# @print_list = @user.print_list -# end -# end - -# describe "initialize" do -# it "establishes the base attributes when instantiated" do -# user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") -# [:username, :real_name, :slack_id].each do |attribute| -# expect(user).must_respond_to attribute -# end -# end -# end - -# describe ".get_api" do -# it "returns a instance of HTTParty::Response" do -# expect(@response).must_be_kind_of HTTParty::Response -# expect(@response["members"]).must_be_kind_of Array -# expect(@response["members"][0]["name"]).wont_be_nil -# expect(@response["members"][0]["real_name"]).wont_be_nil -# expect(@response["members"][0]["id"]).wont_be_nil -# end -# end - -# describe ".list" do -# it "returns an array of User objects" do -# expect(@list).must_be_kind_of Array -# expect(@list[0]).must_be_instance_of Slack::User -# end - -# it "returns an array with the correct length" do -# expect(@list.length).must_equal 7 -# end -# end - -# describe ".print_list" do -# it "displays the username, real name, and Slack ID for all users of workspace" do -# expect(@print_list).must_be_kind_of String -# end -# end - - - - - - - - - - - - - - - - - - - - - -# end \ No newline at end of file +require_relative 'test_helper' +require 'awesome_print' + +describe "User" do + describe "initialize" do + it "establishes the base attributes when instantiated" do + user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") + [:username, :real_name, :slack_id].each do |attribute| + expect(user).must_respond_to attribute + end + end + end +end \ No newline at end of file diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 8a5f1a43..65b94ea7 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -4,21 +4,41 @@ describe "initialize" do it "can be initialized" do workspace = Slack::Workspace.new - # VCR.use_cassette("workspace_user") do - # @response = workspace.user_list - # end - expect(workspace).must_be_kind_of Slack::Workspace + expect(workspace).must_be_instance_of Slack::Workspace end end - describe "workspace methods" do + describe "workspace_user methods" do describe "get_api" do it "returns a response from Slack api" do workspace = Slack::Workspace.new VCR.use_cassette("workspace_user") do @response = workspace.get_api("https://slack.com/api/users.list") end - expect(@response).must_be_kind_of HTTParty::Response + expect(@response).must_be_instance_of HTTParty::Response + end + end + + describe "user_list" do + it "populates the a list of users inside Workspace" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + workspace.user_list + end + expect(workspace.users).must_be_kind_of Array + expect(workspace.users[0]).must_be_instance_of Slack::User + expect(workspace.users.length).must_equal 7 + end + end + + describe "print_user_list" do + it "prints a string with user info" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + workspace.user_list + @user_info_string = workspace.print_user_list + end + expect(@user_info_string).must_be_kind_of String end end From 26454d675deecf22be9af20c3b07f9c31502ed22 Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 14:42:47 -0700 Subject: [PATCH 19/32] Created Channel class, tested instantation of class. Test passing. --- lib/channel.rb | 12 ++++++++++++ test/channel_test.rb | 12 ++++++++++++ test/user_test.rb | 3 +-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/channel.rb b/lib/channel.rb index e69de29b..5ff647ea 100644 --- a/lib/channel.rb +++ b/lib/channel.rb @@ -0,0 +1,12 @@ +module Slack + class Channel + attr_reader :channel_name, :topic, :member_count, :slack_id + + def initialize(channel_name:, topic:, member_count:, slack_id:) + @channel_name = channel_name + @topic = topic + @member_count = member_count + @slack_id = slack_id + end + end +end \ No newline at end of file diff --git a/test/channel_test.rb b/test/channel_test.rb index e69de29b..19d59774 100644 --- a/test/channel_test.rb +++ b/test/channel_test.rb @@ -0,0 +1,12 @@ +require_relative 'test_helper' + +describe "Channel" do + describe "initialize" do + it "establishes the base attributes when instantiated" do + channel = Slack::Channel.new(channel_name:"#random", topic:"pupper toes", member_count: 6, slack_id:"CMUPUL1R9") + [:channel_name, :topic, :member_count, :slack_id].each do |attribute| + expect(channel).must_respond_to attribute + end + end + end +end \ No newline at end of file diff --git a/test/user_test.rb b/test/user_test.rb index 3b58a228..219c75e2 100644 --- a/test/user_test.rb +++ b/test/user_test.rb @@ -1,10 +1,9 @@ require_relative 'test_helper' -require 'awesome_print' describe "User" do describe "initialize" do it "establishes the base attributes when instantiated" do - user = Slack::User.new(username: "spengler", real_name: "Bob Spengler", slack_id: "W012A3CDE") + user = Slack::User.new(username: "SlackBot", real_name: "SlackBot", slack_id: "W012A3CDE") [:username, :real_name, :slack_id].each do |attribute| expect(user).must_respond_to attribute end From 5d0d7c1a7bc05825707af622faf5fce567dff75f Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 11 Sep 2019 14:59:12 -0700 Subject: [PATCH 20/32] Wave 1 completed. --- lib/slack.rb | 9 +-- lib/workspace.rb | 25 ++++++++- test/cassettes/workspace_channel.yml | 82 ++++++++++++++++++++++++++++ test/workspace_test.rb | 38 +++++++++++++ 4 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 test/cassettes/workspace_channel.yml diff --git a/lib/slack.rb b/lib/slack.rb index 3957bb03..75b541f9 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -12,7 +12,8 @@ def main # TO-DO: Display total count of users and channels workspace = Slack::Workspace.new workspace.user_list - puts "Darn Cute Puppers has #{workspace.users.count} users." + workspace.channel_list + puts "Darn Cute Puppers has #{workspace.users.count} users and #{workspace.channels.count} channels." prompt = "Please select from the following options: List Users @@ -28,9 +29,9 @@ def main when "list users" puts workspace.print_user_list break - # when "list channels" - # TO-DO: call print_list method for channel - # break - to avoid asking for more input + when "list channels" + puts workspace.print_channel_list + break else puts "Error: Invalid selection. Returning to main menu...." puts prompt diff --git a/lib/workspace.rb b/lib/workspace.rb index a2277b8c..f50e2288 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -7,7 +7,7 @@ module Slack class Workspace USER_URL = "https://slack.com/api/users.list" - # URL2 = + CHANNEL_URL = "https://slack.com/api/channels.list" attr_reader :users, :channels, :selected @@ -45,6 +45,29 @@ def print_user_list return result end + def channel_list + api_channel_response = get_api(CHANNEL_URL) + api_channels = api_channel_response["channels"] + api_channels.each do |each_channel| + channel_name = each_channel["name"] + topic = each_channel["topic"]["value"] + member_count = each_channel["num_members"] + slack_id = each_channel["id"] + @channels << Channel.new(channel_name: channel_name, topic: topic, member_count: member_count, slack_id: slack_id) + end + end + + def print_channel_list + channel_counter = 0 + result = '' + @channels.each do |each_channel| + channel_counter += 1 + result = result + "Channel #{channel_counter} - channel name: #{each_channel.channel_name}, topic: #{each_channel.topic}, member count: #{each_channel.member_count}, Slack ID: #{each_channel.slack_id}\n" + end + return result + end + + # def select_user # code # end diff --git a/test/cassettes/workspace_channel.yml b/test/cassettes/workspace_channel.yml new file mode 100644 index 00000000..92e8aaf6 --- /dev/null +++ b/test/cassettes/workspace_channel.yml @@ -0,0 +1,82 @@ +--- +http_interactions: +- request: + method: get + uri: https://slack.com/api/channels.list?token= + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '681' + Connection: + - keep-alive + Date: + - Wed, 11 Sep 2019 21:45:26 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 368d4ab9-c9ad-41a9-87d8-46bf30b69889 + 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-1nva + X-Cache: + - Miss from cloudfront + Via: + - 1.1 324a68a6c25ee50d774953f3e15a611d.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - NldFLHawcoJ5pFvEsCbJu4uRzTmZ_xFCGSpLwbe-Z7RgAzoH8k0_GA== + body: + encoding: ASCII-8BIT + string: '{"ok":true,"channels":[{"id":"CMUPUL1R9","name":"pupper-pics","is_channel":true,"created":1568067981,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTERDBPU","name_normalized":"pupper-pics","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTERDBPU","UMURAK10T","UMURAL35H","UN69JKYQ0","UN69RK75K","UN85KTCHM"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"To + share darn cute pupper pics!","creator":"UMTERDBPU","last_set":1568081755},"previous_names":[],"num_members":6},{"id":"CMWARHPNF","name":"sploots","is_channel":true,"created":1568159409,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UN69RK75K","name_normalized":"sploots","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTERDBPU","UMURAK10T","UMURAL35H","UN69JKYQ0","UN69RK75K","UN85KTCHM"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"look + at cute doggy butts and toes","creator":"UN69RK75K","last_set":1568159410},"previous_names":[],"num_members":6},{"id":"CN5PU7BBN","name":"general","is_channel":true,"created":1568067980,"is_archived":false,"is_general":true,"unlinked":0,"creator":"UMTERDBPU","name_normalized":"general","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTERDBPU","UMURAK10T","UMURAL35H","UN69JKYQ0","UN69RK75K","UN85KTCHM"],"topic":{"value":"Company-wide + announcements and work-based matters","creator":"UMTERDBPU","last_set":1568067980},"purpose":{"value":"This + channel is for workspace-wide communication and announcements. All members + are in this channel.","creator":"UMTERDBPU","last_set":1568067980},"previous_names":[],"num_members":6},{"id":"CN689KKBP","name":"random","is_channel":true,"created":1568067980,"is_archived":false,"is_general":false,"unlinked":0,"creator":"UMTERDBPU","name_normalized":"random","is_shared":false,"is_org_shared":false,"is_member":true,"is_private":false,"is_mpim":false,"members":["UMTERDBPU","UMURAK10T","UMURAL35H","UN69JKYQ0","UN69RK75K","UN85KTCHM"],"topic":{"value":"Non-work + banter and water cooler conversation","creator":"UMTERDBPU","last_set":1568067980},"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":"UMTERDBPU","last_set":1568067980},"previous_names":[],"num_members":6}],"response_metadata":{"next_cursor":""}}' + http_version: + recorded_at: Wed, 11 Sep 2019 21:45:26 GMT +recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 65b94ea7..609f1c70 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -41,10 +41,48 @@ expect(@user_info_string).must_be_kind_of String end end + end + + describe "workspace_channel methods" do + describe "get_api" do + it "returns a response from Slack api" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + @response = workspace.get_api("https://slack.com/api/channels.list") + end + expect(@response).must_be_instance_of HTTParty::Response + end + end + describe "channel_list" do + it "populates the a list of channels inside Workspace" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + workspace.channel_list + end + expect(workspace.channels).must_be_kind_of Array + p workspace.channels[0] + expect(workspace.channels[0]).must_be_instance_of Slack::Channel + expect(workspace.channels.length).must_equal 4 + end + end + + describe "print_channel_list" do + it "prints a string with channel info" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + workspace.channel_list + @channel_info_string = workspace.print_channel_list + end + expect(@channel_info_string).must_be_kind_of String + end + end + + + end end \ No newline at end of file From 1edf180551ec4274243811abf2706295672c83d3 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 08:41:28 -0700 Subject: [PATCH 21/32] work in progress --- lib/slack.rb | 26 ++++++++++++++++++++++++-- lib/workspace.rb | 22 +++++++++++++--------- test/workspace_test.rb | 39 +++++++++++++++++++++++++++++++++++---- 3 files changed, 72 insertions(+), 15 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 75b541f9..b39b9d7e 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -9,7 +9,6 @@ def main puts "Welcome to the Ada Slack CLI!" - # TO-DO: Display total count of users and channels workspace = Slack::Workspace.new workspace.user_list workspace.channel_list @@ -18,6 +17,9 @@ def main prompt = "Please select from the following options: List Users List Channels + Select Users + Select Channels + Show Details Quit" puts prompt @@ -31,7 +33,27 @@ def main break when "list channels" puts workspace.print_channel_list - break + break + when "select users" + # code + name = gets.chomp + search (user, name) + # ask the user to enter a username OR slack id + # completed: use the username/slack_id and iterate through a list of users in Workspace + # completed: saved user to @selected inside workspace + # if @selected = nil, let customer know and return to main + # if @selected !=nil , display details and message + + when "select channels" + # code + # if user selects a channel, search for that channel, + # if channel not found output a message to user and return to main menu + # if channel found, display "do you want to see details or send message or go back to the main menu?" + # if user selects either option, do that command, + # exit program + search (channel, name) + when "show details" + # code else puts "Error: Invalid selection. Returning to main menu...." puts prompt diff --git a/lib/workspace.rb b/lib/workspace.rb index f50e2288..a04d40f4 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -14,7 +14,7 @@ class Workspace def initialize @users = [] @channels = [] - @selected = [] + @selected = nil end def get_api(url) @@ -67,14 +67,18 @@ def print_channel_list return result end - - # def select_user - # code - # end - - # def select_channel - # code - # end + def search(data_source, query_term) + @selected = nil + if data_source == "user" + @users.each do |current_user| + if current_user.username == query_term || current_user.slack_id == query_term + @selected = current_user + break + end + end + return @selected + end + end # def show_details # code diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 609f1c70..0e9f87ee 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -8,7 +8,7 @@ end end - describe "workspace_user methods" do + describe "workspace_user list methods" do describe "get_api" do it "returns a response from Slack api" do workspace = Slack::Workspace.new @@ -43,7 +43,7 @@ end end - describe "workspace_channel methods" do + describe "workspace_channel list methods" do describe "get_api" do it "returns a response from Slack api" do workspace = Slack::Workspace.new @@ -61,7 +61,6 @@ workspace.channel_list end expect(workspace.channels).must_be_kind_of Array - p workspace.channels[0] expect(workspace.channels[0]).must_be_instance_of Slack::Channel expect(workspace.channels.length).must_equal 4 end @@ -77,6 +76,38 @@ expect(@channel_info_string).must_be_kind_of String end end + end + + describe "Workspace select methods" do + describe ".search users" do + it "will search through users and save that user to selected" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + workspace.user_list + workspace.search("user", "Slackbot") + end + puts workspace.print_user_list + expect(workspace.selected).must_be_instance_of Slack::User + expect(workspace.selected.username).must_equal "Slackbot" + end + + # add test for bad name + # add test for bad id + # add test for good id + + + + end + + describe ".search channels" do + it "will search through channels and save that channel to selected" do + + end + end + + + end + @@ -84,5 +115,5 @@ - end + end \ No newline at end of file From 202adb8ef72dc8ede085afbb07f7bbcb6bde7f12 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 10:09:25 -0700 Subject: [PATCH 22/32] Created search method in Workspace to search across users, passed corresponding tests. --- lib/slack.rb | 16 +++++++++------- test/workspace_test.rb | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index b39b9d7e..5109d45d 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -35,15 +35,17 @@ def main puts workspace.print_channel_list break when "select users" - # code - name = gets.chomp - search (user, name) - # ask the user to enter a username OR slack id - # completed: use the username/slack_id and iterate through a list of users in Workspace - # completed: saved user to @selected inside workspace + puts "Please enter the username or slack id: " + user_query_term = gets.chomp + # TO-DO: how to handle username is downcase, slack id is upcase + # search(user, user_query_term) # if @selected = nil, let customer know and return to main # if @selected !=nil , display details and message - + + + # completed: use the username/slack_id and iterate through a list of users in Workspace + # completed: saved user to @selected inside workspace + when "select channels" # code # if user selects a channel, search for that channel, diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 0e9f87ee..12ef1d2c 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -80,22 +80,47 @@ describe "Workspace select methods" do describe ".search users" do - it "will search through users and save that user to selected" do + it "will search through usernames and save that user to selected" do workspace = Slack::Workspace.new VCR.use_cassette("workspace_user") do workspace.user_list - workspace.search("user", "Slackbot") + workspace.search("user", "slackbot") end - puts workspace.print_user_list + workspace.print_user_list expect(workspace.selected).must_be_instance_of Slack::User - expect(workspace.selected.username).must_equal "Slackbot" + expect(workspace.selected.username).must_equal "slackbot" end - # add test for bad name - # add test for bad id - # add test for good id - + it "if username does not exist it will set the value of @selected to nil" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + workspace.user_list + workspace.search("user", "slackboot") + end + p workspace.print_user_list + expect(workspace.selected).must_be_nil + end + + it "will search through user slack_ids and save that user to selected" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + workspace.user_list + workspace.search("user", "USLACKBOT") + end + workspace.print_user_list + expect(workspace.selected).must_be_instance_of Slack::User + expect(workspace.selected.slack_id).must_equal "USLACKBOT" + end + it "if slack_id does not exist it will set the value of @selected to nil" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + workspace.user_list + workspace.search("user", "USLACKBOOT") + end + workspace.print_user_list + expect(workspace.selected).must_be_nil + end end From 2e5fbb463b975bc042fa6acdd3c9207b08998d9d Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 13:46:48 -0700 Subject: [PATCH 23/32] Created show_details method, implemented for User. Passed corresponding tests. --- lib/slack.rb | 73 +++++++++++++++++++++++++++++------------- lib/workspace.rb | 19 +++++++++-- test/workspace_test.rb | 35 +++++++++++++++++--- 3 files changed, 98 insertions(+), 29 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 5109d45d..b9ba1d00 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -7,19 +7,18 @@ Dotenv.load def main - puts "Welcome to the Ada Slack CLI!" workspace = Slack::Workspace.new workspace.user_list workspace.channel_list + puts "Darn Cute Puppers has #{workspace.users.count} users and #{workspace.channels.count} channels." prompt = "Please select from the following options: List Users List Channels - Select Users - Select Channels - Show Details + Select User + Select Channel Quit" puts prompt @@ -34,28 +33,58 @@ def main when "list channels" puts workspace.print_channel_list break - when "select users" - puts "Please enter the username or slack id: " - user_query_term = gets.chomp - # TO-DO: how to handle username is downcase, slack id is upcase - # search(user, user_query_term) + when "select user" + puts "Would you like to search for a user by username or id?" + search_user_choice = gets.chomp.downcase + if search_user_choice == "username" + puts "Please enter the username: " + username = gets.chomp.downcase + search_result = workspace.search("user", username) + if search_result == nil + puts "User not found. Returning to main menu..." + puts prompt + else + puts "User found. Please select from the following options: + Show Details + Send Message" + # take user input and call show_details + selected_command = gets.chomp.downcase + if selected_command == "show details" + puts workspace.show_details(search_result) + break + end + end + elsif search_user_choice == "id" + puts "Please enter the slack id: " + slack_id = gets.chomp.upcase + search_result = workspace.search("user", slack_id) + if search_result == nil + puts "User not found. Returning to main menu..." + puts prompt + else + puts "User found. Please select from the following options: + Show Details + Send Message" + end + else + puts "Invalid input. Returnng to main menu..." + puts prompt + end + # if @selected = nil, let customer know and return to main # if @selected !=nil , display details and message - - # completed: use the username/slack_id and iterate through a list of users in Workspace - # completed: saved user to @selected inside workspace - when "select channels" - # code - # if user selects a channel, search for that channel, - # if channel not found output a message to user and return to main menu - # if channel found, display "do you want to see details or send message or go back to the main menu?" - # if user selects either option, do that command, - # exit program - search (channel, name) - when "show details" - # code + # when "select channel" + # # code + # # if user selects a channel, search for that channel, + # # if channel not found output a message to user and return to main menu + # # if channel found, display "do you want to see details or send message or go back to the main menu?" + # # if user selects either option, do that command, + # # exit program + # search (channel, name) + # when "show details" + # # code else puts "Error: Invalid selection. Returning to main menu...." puts prompt diff --git a/lib/workspace.rb b/lib/workspace.rb index a04d40f4..66dafe1d 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -78,11 +78,24 @@ def search(data_source, query_term) end return @selected end + + # add code for Channel end - # def show_details - # code - # end + def show_details(selected_receiver) + # if selected is a User object + details = '''' + if @selected.class == Slack::User + details = details + "Username: #{selected.username}, Real name: #{selected.real_name}, Slack ID: #{selected.slack_id}" + end + return details + # it will print User.username, User.real_name, User.slack_id + + + # if the selected is a Channel object + # it will print the Channel.channel_name, Channel.topic, Channel.member_count, + # & Channel.slack_id + end # def send_message # code diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 12ef1d2c..a428ee16 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -43,7 +43,7 @@ end end - describe "workspace_channel list methods" do + describe "workspace channel list methods" do describe "get_api" do it "returns a response from Slack api" do workspace = Slack::Workspace.new @@ -122,16 +122,43 @@ expect(workspace.selected).must_be_nil end + describe ".search channels" do + it "will search through channels and save that channel to selected" do + + end + end + + + + end + end + + describe "Workspace show details methods" do + describe ".show_details for user" do + it "will print the details of the selected user" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_user") do + workspace.user_list + workspace.search("user", "USLACKBOT") + @selected = workspace.users[0] + end + expect(workspace.show_details(@selected)).must_be_kind_of String + end - describe ".search channels" do - it "will search through channels and save that channel to selected" do + end + describe ".show_details for channel" do + it "will print the details of the selected channel" do + # end end + + end + - end + From f98a3b2e854c395fb4537195d84c7dc99d8a4709 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 14:05:22 -0700 Subject: [PATCH 24/32] Modified search method to search through channels. Passed corresponding tests. --- lib/slack.rb | 1 + lib/workspace.rb | 11 +++++-- test/workspace_test.rb | 66 ++++++++++++++++++++++++++++++------------ 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index b9ba1d00..db61dd3f 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -11,6 +11,7 @@ def main workspace = Slack::Workspace.new workspace.user_list workspace.channel_list + p workspace.channels puts "Darn Cute Puppers has #{workspace.users.count} users and #{workspace.channels.count} channels." diff --git a/lib/workspace.rb b/lib/workspace.rb index 66dafe1d..c9ea7933 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -77,13 +77,18 @@ def search(data_source, query_term) end end return @selected + elsif data_source == "channel" + @channels.each do |current_channel| + if current_channel.channel_name == query_term || current_channel.slack_id == query_term + @selected = current_channel + break + end + end + return @selected end - - # add code for Channel end def show_details(selected_receiver) - # if selected is a User object details = '''' if @selected.class == Slack::User details = details + "Username: #{selected.username}, Real name: #{selected.real_name}, Slack ID: #{selected.slack_id}" diff --git a/test/workspace_test.rb b/test/workspace_test.rb index a428ee16..b1e6f0ec 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -97,7 +97,7 @@ workspace.user_list workspace.search("user", "slackboot") end - p workspace.print_user_list + workspace.print_user_list expect(workspace.selected).must_be_nil end @@ -112,7 +112,7 @@ expect(workspace.selected.slack_id).must_equal "USLACKBOT" end - it "if slack_id does not exist it will set the value of @selected to nil" do + it "if user slack_id does not exist it will set the value of selected to nil" do workspace = Slack::Workspace.new VCR.use_cassette("workspace_user") do workspace.user_list @@ -123,9 +123,52 @@ end describe ".search channels" do - it "will search through channels and save that channel to selected" do - + it "will search through channel names and save that channel to selected" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + workspace.channel_list + workspace.search("channel", "random") + end + workspace.print_channel_list + expect(workspace.selected).must_be_instance_of Slack::Channel + expect(workspace.selected.channel_name).must_equal "random" + end + + it "if channel name does not exist it will set the value of selected to nil" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + workspace.channel_list + workspace.search("channel", "randomz") + end + workspace.print_channel_list + expect(workspace.selected).must_be_nil + end + + it "will search through channel slack_ids and save that channel to selected" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + workspace.channel_list + workspace.search("channel", "CN689KKBP") + end + workspace.print_channel_list + expect(workspace.selected).must_be_instance_of Slack::Channel + expect(workspace.selected.slack_id).must_equal "CN689KKBP" end + + it "if channel slack_id does not exist it will set the value of selected to nil" do + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + workspace.channel_list + workspace.search("channel", "CN8888888") + end + workspace.print_channel_list + expect(workspace.selected).must_be_nil + end + + + + + end @@ -153,19 +196,6 @@ # end end - - end - - - - - - - - - - - - + end end \ No newline at end of file From 752045408a061368c6f07238a2db6b15269dabb0 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 14:59:55 -0700 Subject: [PATCH 25/32] Modified show details to work for channels. Passed corresponding tests. Updated slack.rb. Wave 2 Completed. --- lib/slack.rb | 65 ++++++++++++++++++++++++++++++------------ lib/workspace.rb | 20 ++++++------- test/workspace_test.rb | 20 ++++++------- 3 files changed, 65 insertions(+), 40 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index db61dd3f..6e5c82a3 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -11,7 +11,6 @@ def main workspace = Slack::Workspace.new workspace.user_list workspace.channel_list - p workspace.channels puts "Darn Cute Puppers has #{workspace.users.count} users and #{workspace.channels.count} channels." @@ -48,7 +47,6 @@ def main puts "User found. Please select from the following options: Show Details Send Message" - # take user input and call show_details selected_command = gets.chomp.downcase if selected_command == "show details" puts workspace.show_details(search_result) @@ -66,26 +64,57 @@ def main puts "User found. Please select from the following options: Show Details Send Message" + selected_command = gets.chomp.downcase + if selected_command == "show details" + puts workspace.show_details(search_result) + break + end end else - puts "Invalid input. Returnng to main menu..." + puts "Invalid input. Returning to main menu..." + puts prompt + end + when "select channel" + puts "Would you like to search for a channel by channel name or id?" + search_channel_choice = gets.chomp.downcase + if search_channel_choice == "channel name" + puts "Please enter the channel name: " + channel_name = gets.chomp.downcase + search_result = workspace.search("channel", channel_name) + if search_result == nil + puts "Channel not found. Returning to main menu..." + puts prompt + else + puts "Channel found. Please select from the following options: + Show Details + Send Message" + selected_command = gets.chomp.downcase + if selected_command == "show details" + puts workspace.show_details(search_result) + break + end + end + elsif search_channel_choice == "id" + puts "Please enter the channel's slack id: " + slack_id = gets.chomp.upcase + search_result = workspace.search("channel", slack_id) + if search_result == nil + puts "Channel not found. Returning to main menu..." + puts prompt + else + puts "Channel found. Please select from the following options: + Show Details + Send Message" + selected_command = gets.chomp.downcase + if selected_command == "show details" + puts workspace.show_details(search_result) + break + end + end + else + puts "Invalid input. Returning to main menu..." puts prompt end - - # if @selected = nil, let customer know and return to main - # if @selected !=nil , display details and message - - - # when "select channel" - # # code - # # if user selects a channel, search for that channel, - # # if channel not found output a message to user and return to main menu - # # if channel found, display "do you want to see details or send message or go back to the main menu?" - # # if user selects either option, do that command, - # # exit program - # search (channel, name) - # when "show details" - # # code else puts "Error: Invalid selection. Returning to main menu...." puts prompt diff --git a/lib/workspace.rb b/lib/workspace.rb index c9ea7933..ed47e983 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -90,21 +90,19 @@ def search(data_source, query_term) def show_details(selected_receiver) details = '''' - if @selected.class == Slack::User - details = details + "Username: #{selected.username}, Real name: #{selected.real_name}, Slack ID: #{selected.slack_id}" + if selected_receiver.class == Slack::User + details = details + "Username: #{@selected.username}, Real name: #{@selected.real_name}, Slack ID: #{@selected.slack_id}" + return details + elsif selected_receiver.class == Slack::Channel + details = details + "Channel name: #{@selected.channel_name}, Topic: #{@selected.topic}, Member count: #{@selected.member_count}, Slack ID: #{@selected.slack_id}" + return details end - return details - # it will print User.username, User.real_name, User.slack_id - - - # if the selected is a Channel object - # it will print the Channel.channel_name, Channel.topic, Channel.member_count, - # & Channel.slack_id end - # def send_message + + def send_message # code - # end + end end end diff --git a/test/workspace_test.rb b/test/workspace_test.rb index b1e6f0ec..d158458d 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -164,16 +164,7 @@ workspace.print_channel_list expect(workspace.selected).must_be_nil end - - - - - end - - - - end end @@ -187,13 +178,20 @@ @selected = workspace.users[0] end expect(workspace.show_details(@selected)).must_be_kind_of String + expect(@selected).must_be_instance_of Slack::User end - end describe ".show_details for channel" do it "will print the details of the selected channel" do - # + workspace = Slack::Workspace.new + VCR.use_cassette("workspace_channel") do + workspace.channel_list + workspace.search("channel", "random") + @selected = workspace.channels.last + end + expect(workspace.show_details(@selected)).must_be_kind_of String + expect(@selected).must_be_instance_of Slack::Channel end end From 9f8acc0cc827d2284499bc6bc3d00e1a32631728 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 15:48:31 -0700 Subject: [PATCH 26/32] Created send message method in Workspace. Successfully called API and posted message to channel. Passed corresponding tests. --- lib/slack.rb | 3 +- lib/workspace.rb | 22 +++- test/cassettes/send_message_channel.yml | 139 ++++++++++++++++++++++++ test/workspace_test.rb | 32 ++++++ 4 files changed, 191 insertions(+), 5 deletions(-) create mode 100644 test/cassettes/send_message_channel.yml diff --git a/lib/slack.rb b/lib/slack.rb index 6e5c82a3..b306f8f2 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -124,5 +124,4 @@ def main end -main if __FILE__ == $PROGRAM_NAME - +main if __FILE__ == $PROGRAM_NAME \ No newline at end of file diff --git a/lib/workspace.rb b/lib/workspace.rb index ed47e983..3dd3547c 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -5,9 +5,11 @@ require 'awesome_print' module Slack + class SlackApiError < StandardError; end class Workspace USER_URL = "https://slack.com/api/users.list" CHANNEL_URL = "https://slack.com/api/channels.list" + POST_MSG_URL = "https://slack.com/api/chat.postMessage" attr_reader :users, :channels, :selected @@ -99,11 +101,25 @@ def show_details(selected_receiver) end end - - def send_message - # code + def send_message(message, selected_receiver) + response = HTTParty.post( + POST_MSG_URL, + body: { + token: ENV['SLACK_TOKEN'], + text: message, + channel: selected_receiver + }, + headers: { 'Content-Type' => 'application/x-www-form-urlencoded' } + ) + + unless response.parsed_response["ok"] + raise SlackApiError, "Error when posting #{message} to #{selected_receiver}, error: #{response.parsed_response["error"]}" + end + return response end + + end end diff --git a/test/cassettes/send_message_channel.yml b/test/cassettes/send_message_channel.yml new file mode 100644 index 00000000..3d57fd13 --- /dev/null +++ b/test/cassettes/send_message_channel.yml @@ -0,0 +1,139 @@ +--- +http_interactions: +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=This%20post%20should%20not%20work&channel=invalid-channel + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 22:40:40 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - e094058c-f000-470e-a3a5-b2bedfd6cf3d + 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-xtep + X-Cache: + - Miss from cloudfront + Via: + - 1.1 2e20768704c71ff3ce2e677251d27f3c.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - g-NaQYyv1aaa-hay89RWQ_2lWk7FWi84nD2CKPmws_rn2CwbYUmiAQ== + body: + encoding: UTF-8 + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Thu, 12 Sep 2019 22:40:40 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=Hi%20Pupper%20Friends%21&channel=random + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 22:40:40 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 7eed6677-9bab-4b11-9ff0-b517f0121a34 + 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-6he5 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 aabd01c4a20dae837d162bd972422efc.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - gM6EEaMzkrb_Vb-oJMTSbBCohlpSfqOSVpSxMWupRRdkjc-6LuJ14g== + body: + encoding: UTF-8 + string: '{"ok":true,"channel":"CN689KKBP","ts":"1568328040.000200","message":{"type":"message","subtype":"bot_message","text":"Hi + Pupper Friends!","ts":"1568328040.000200","username":"Leaves - Kristina & + Ga-Young","bot_id":"BN8EPGQ4E"}}' + http_version: + recorded_at: Thu, 12 Sep 2019 22:40:40 GMT +recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index d158458d..debb9c8c 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -194,6 +194,38 @@ expect(@selected).must_be_instance_of Slack::Channel end end + end + + describe "Workspace send message methods" do + it "if a channel is selected it will send a direct message to a channel" do + workspace = Slack::Workspace.new + VCR.use_cassette("send_message_channel") do + @response = workspace.send_message("Hi Pupper Friends!", "random") + end + expect(@response).must_be_instance_of HTTParty::Response + end + + it "will raise an error when given an invalid channel" do + workspace = Slack::Workspace.new + VCR.use_cassette("send_message_channel") do + exception = expect { + workspace.send_message("This post should not work", "invalid-channel") + }.must_raise Slack::SlackApiError + + expect(exception.message).must_equal 'Error when posting This post should not work to invalid-channel, error: channel_not_found' + + end + end + + # it "if a user is selected it will send a direct message to a user" do + + # end + + + + + + end end \ No newline at end of file From 8e750a9044cc293f9486f11fb08fb6c5ec52a2b7 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 15:56:06 -0700 Subject: [PATCH 27/32] Modified CLI program to allow user to send a message to a channel via channel name or channel id. --- lib/slack.rb | 10 ++++++++++ test/workspace_test.rb | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/slack.rb b/lib/slack.rb index b306f8f2..96be15b6 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -92,6 +92,11 @@ def main if selected_command == "show details" puts workspace.show_details(search_result) break + elsif selected_command == "send message" + puts "What message do you want to send?" + message_body = gets.chomp + workspace.send_message(message_body, channel_name) + break end end elsif search_channel_choice == "id" @@ -109,6 +114,11 @@ def main if selected_command == "show details" puts workspace.show_details(search_result) break + elsif selected_command == "send message" + puts "What message do you want to send?" + message_body = gets.chomp + workspace.send_message(message_body, slack_id) + break end end else diff --git a/test/workspace_test.rb b/test/workspace_test.rb index debb9c8c..03988b52 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -213,7 +213,6 @@ }.must_raise Slack::SlackApiError expect(exception.message).must_equal 'Error when posting This post should not work to invalid-channel, error: channel_not_found' - end end From b71f28ab00194fae43fd524136301348addbdf07 Mon Sep 17 00:00:00 2001 From: Kristina Date: Thu, 12 Sep 2019 17:21:40 -0700 Subject: [PATCH 28/32] Modified CLI program to allow user to send a message to selected user. Passed corresponding tests. Wave 3 complete. --- lib/slack.rb | 12 +- lib/workspace.rb | 11 +- test/cassettes/send_message_user.yml | 273 +++++++++++++++++++++++++++ test/workspace_test.rb | 26 ++- 4 files changed, 302 insertions(+), 20 deletions(-) create mode 100644 test/cassettes/send_message_user.yml diff --git a/lib/slack.rb b/lib/slack.rb index 96be15b6..8e3514fb 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -33,7 +33,7 @@ def main when "list channels" puts workspace.print_channel_list break - when "select user" + when "select user" puts "Would you like to search for a user by username or id?" search_user_choice = gets.chomp.downcase if search_user_choice == "username" @@ -51,6 +51,11 @@ def main if selected_command == "show details" puts workspace.show_details(search_result) break + elsif selected_command == "send message" + puts "What message do you want to send?" + message_body = gets.chomp + workspace.send_message(message_body, "@#{username}") + break end end elsif search_user_choice == "id" @@ -68,6 +73,11 @@ def main if selected_command == "show details" puts workspace.show_details(search_result) break + elsif selected_command == "send message" + puts "What message do you want to send?" + message_body = gets.chomp + workspace.send_message(message_body, slack_id) + break end end else diff --git a/lib/workspace.rb b/lib/workspace.rb index 3dd3547c..07e8f8d7 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -2,8 +2,6 @@ require_relative "channel" require_relative "acceptor" -require 'awesome_print' - module Slack class SlackApiError < StandardError; end class Workspace @@ -117,12 +115,5 @@ def send_message(message, selected_receiver) end return response end - - - end -end - -# hello = Slack::Workspace.new -# hello.user_list -# puts hello.print_user_list +end \ No newline at end of file diff --git a/test/cassettes/send_message_user.yml b/test/cassettes/send_message_user.yml new file mode 100644 index 00000000..a71bc3a9 --- /dev/null +++ b/test/cassettes/send_message_user.yml @@ -0,0 +1,273 @@ +--- +http_interactions: +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=Hi%20Pupper%20Friends%21&channel=%40username + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:37:18 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - fb620464-d989-49ae-bf71-a6a2055466a4 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:user,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-lx8n + X-Cache: + - Miss from cloudfront + Via: + - 1.1 1570d93226c1bbca2ebaad510cff3e0d.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - iXyEQik3RZXlOq-OCuDEKmTRyAAzxitEIcWMPYR8GjrkV0LsHo7T8Q== + body: + encoding: UTF-8 + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:37:18 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=Hi%20Pupper%20Friends%21&channel=%40kristina.tanya + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:37:33 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 21228778-49d0-4836-b825-0856eeb738a8 + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:user,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-4tyc + X-Cache: + - Miss from cloudfront + Via: + - 1.1 e5147bed59b539c23be4f2e01cf6f6f5.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C1 + X-Amz-Cf-Id: + - f_SQTQpsGwCR6L-qT8cYOAwENDIM8PfZUPdmeZdK7DUs44dO_EknkQ== + body: + encoding: UTF-8 + string: '{"ok":true,"channel":"DMUPUKT5Z","ts":"1568331453.000200","message":{"type":"message","subtype":"bot_message","text":"Hi + Pupper Friends!","ts":"1568331453.000200","username":"Leaves - Kristina & + Ga-Young","bot_id":"BN8EPGQ4E"}}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:37:33 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=This%20post%20should%20not%20work&channel=%40invaliduser + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:38:06 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - 52c511d7-d9aa-4091-84e7-d2beb85e8eca + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:user,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-ecjy + X-Cache: + - Miss from cloudfront + Via: + - 1.1 d8792dbd3191bbe722eba5b536b979c8.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - Dsx1_-w98m2eu8oblThqQujr061xiYIT_7nFvyxtOul0VXc9hJfR6Q== + body: + encoding: UTF-8 + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:38:06 GMT +- request: + method: post + uri: https://slack.com/api/chat.postMessage + body: + encoding: UTF-8 + string: token=&text=This%20post%20should%20not%20work&channel=%40invalid_user + headers: + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Date: + - Thu, 12 Sep 2019 23:38:48 GMT + Server: + - Apache + X-Content-Type-Options: + - nosniff + X-Slack-Req-Id: + - c39ad379-4606-45dc-80fb-4c21a18c03ea + X-Oauth-Scopes: + - identify,channels:read,users:read,chat:write:user,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-xqej + X-Cache: + - Miss from cloudfront + Via: + - 1.1 112d82578d402a38d8d02e8b857617e1.cloudfront.net (CloudFront) + X-Amz-Cf-Pop: + - SEA19-C2 + X-Amz-Cf-Id: + - tnW-RqF5jQDWF_0Yms2gLVy57hMzCjjPVIWgxrK5cJx4o7TwqN3W4g== + body: + encoding: UTF-8 + string: '{"ok":false,"error":"channel_not_found"}' + http_version: + recorded_at: Thu, 12 Sep 2019 23:38:48 GMT +recorded_with: VCR 5.0.0 diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 03988b52..825d486c 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -216,15 +216,23 @@ end end - # it "if a user is selected it will send a direct message to a user" do - - # end - - - - - - + it "if a user is selected it will send a direct message to a user" do + workspace = Slack::Workspace.new + VCR.use_cassette("send_message_user") do + @response = workspace.send_message("Hi Pupper Friends!", "@kristina.tanya") + end + expect(@response).must_be_instance_of HTTParty::Response + end + it "will raise an error when given an invalid user" do + workspace = Slack::Workspace.new + VCR.use_cassette("send_message_user") do + exception = expect { + workspace.send_message("This post should not work", "@invalid_user") + }.must_raise Slack::SlackApiError + + expect(exception.message).must_equal 'Error when posting This post should not work to @invalid_user, error: channel_not_found' + end + end end end \ No newline at end of file From 3ba429ce9c798d78a7081fd600fab12d2bbed92b Mon Sep 17 00:00:00 2001 From: Kristina Date: Fri, 13 Sep 2019 13:13:30 -0700 Subject: [PATCH 29/32] Removed acceptor class and file. --- lib/acceptor.rb | 17 ----------------- test/acceptor_test.rb | 0 2 files changed, 17 deletions(-) delete mode 100644 lib/acceptor.rb delete mode 100644 test/acceptor_test.rb diff --git a/lib/acceptor.rb b/lib/acceptor.rb deleted file mode 100644 index 5bafd5d2..00000000 --- a/lib/acceptor.rb +++ /dev/null @@ -1,17 +0,0 @@ -# module Slack -# class Acceptor -# attr_reader :slack_id, :name - -# def initialize(slack_id, name) -# @slack_id = slack_id -# @name = name -# end - - # def send_message(message) - # end - - # def self.get(url, query) - # end - -# end -# end \ No newline at end of file diff --git a/test/acceptor_test.rb b/test/acceptor_test.rb deleted file mode 100644 index e69de29b..00000000 From 22c9cf28516d0915e0be484ddf8326e8d0f3a2d3 Mon Sep 17 00:00:00 2001 From: Kristina Date: Fri, 13 Sep 2019 13:22:49 -0700 Subject: [PATCH 30/32] Cleaned up workspace test. --- lib/workspace.rb | 2 +- test/workspace_test.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/workspace.rb b/lib/workspace.rb index 07e8f8d7..d64322f4 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -89,7 +89,7 @@ def search(data_source, query_term) end def show_details(selected_receiver) - details = '''' + details = "" if selected_receiver.class == Slack::User details = details + "Username: #{@selected.username}, Real name: #{@selected.real_name}, Slack ID: #{@selected.slack_id}" return details diff --git a/test/workspace_test.rb b/test/workspace_test.rb index 825d486c..beb19fb6 100644 --- a/test/workspace_test.rb +++ b/test/workspace_test.rb @@ -8,7 +8,7 @@ end end - describe "workspace_user list methods" do + describe "workspace user list methods" do describe "get_api" do it "returns a response from Slack api" do workspace = Slack::Workspace.new @@ -78,7 +78,7 @@ end end - describe "Workspace select methods" do + describe "workspace select methods" do describe ".search users" do it "will search through usernames and save that user to selected" do workspace = Slack::Workspace.new @@ -168,7 +168,7 @@ end end - describe "Workspace show details methods" do + describe "workspace show details methods" do describe ".show_details for user" do it "will print the details of the selected user" do workspace = Slack::Workspace.new @@ -196,7 +196,7 @@ end end - describe "Workspace send message methods" do + describe "workspace send message methods" do it "if a channel is selected it will send a direct message to a channel" do workspace = Slack::Workspace.new VCR.use_cassette("send_message_channel") do From a8df6c06e1b321e11df88dd8f8944472bdfb9024 Mon Sep 17 00:00:00 2001 From: Kristina Date: Fri, 13 Sep 2019 13:25:26 -0700 Subject: [PATCH 31/32] Removed all references to acceptor.rb --- lib/slack.rb | 1 - lib/workspace.rb | 1 - test/test_helper.rb | 1 - 3 files changed, 3 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index 8e3514fb..e9dfd306 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -1,7 +1,6 @@ require_relative "workspace" require_relative "user" require_relative "channel" -require_relative "acceptor" require 'httparty' require "dotenv" Dotenv.load diff --git a/lib/workspace.rb b/lib/workspace.rb index d64322f4..d4bc765d 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -1,6 +1,5 @@ require_relative "user" require_relative "channel" -require_relative "acceptor" module Slack class SlackApiError < StandardError; end diff --git a/test/test_helper.rb b/test/test_helper.rb index f2abcbd7..1cb1db93 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,7 +15,6 @@ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new -require_relative '../lib/acceptor' require_relative '../lib/user' require_relative '../lib/channel' require_relative '../lib/workspace' From a55e36f65b42c21b4b3e71b811c765ae64f8dbe5 Mon Sep 17 00:00:00 2001 From: Kristina Date: Fri, 13 Sep 2019 14:56:59 -0700 Subject: [PATCH 32/32] Completed project. --- lib/slack.rb | 161 ++++++++++++++++++++--------------------------- lib/workspace.rb | 4 +- 2 files changed, 69 insertions(+), 96 deletions(-) diff --git a/lib/slack.rb b/lib/slack.rb index e9dfd306..174877c7 100755 --- a/lib/slack.rb +++ b/lib/slack.rb @@ -6,19 +6,19 @@ Dotenv.load def main - puts "Welcome to the Ada Slack CLI!" + puts "Welcome to the Ada Slack CLI!\n" workspace = Slack::Workspace.new workspace.user_list workspace.channel_list - puts "Darn Cute Puppers has #{workspace.users.count} users and #{workspace.channels.count} channels." + puts "\nDarn Cute Puppers has #{workspace.users.count} users and #{workspace.channels.count} channels.\n" - prompt = "Please select from the following options: + prompt = "\nPlease select from the following options: List Users List Channels Select User Select Channel - Quit" + Quit\n" puts prompt @@ -28,119 +28,92 @@ def main exit when "list users" puts workspace.print_user_list - break + puts prompt when "list channels" puts workspace.print_channel_list - break + puts prompt when "select user" - puts "Would you like to search for a user by username or id?" - search_user_choice = gets.chomp.downcase - if search_user_choice == "username" - puts "Please enter the username: " - username = gets.chomp.downcase - search_result = workspace.search("user", username) - if search_result == nil - puts "User not found. Returning to main menu..." - puts prompt - else - puts "User found. Please select from the following options: - Show Details - Send Message" - selected_command = gets.chomp.downcase - if selected_command == "show details" - puts workspace.show_details(search_result) - break - elsif selected_command == "send message" - puts "What message do you want to send?" - message_body = gets.chomp - workspace.send_message(message_body, "@#{username}") + puts "Please enter a username or Slack ID." + username = gets.chomp.downcase + search_result = workspace.search("user", username) + if search_result == nil + puts "User not found. Returning to main menu..." + puts prompt + break + else + puts "User found." + options = "Please select from the following options: + Show Details + Send Message + Main Menu" + puts options + while selected_command = gets.chomp.downcase + case selected_command + when "main menu" + puts prompt break - end - end - elsif search_user_choice == "id" - puts "Please enter the slack id: " - slack_id = gets.chomp.upcase - search_result = workspace.search("user", slack_id) - if search_result == nil - puts "User not found. Returning to main menu..." - puts prompt - else - puts "User found. Please select from the following options: - Show Details - Send Message" - selected_command = gets.chomp.downcase - if selected_command == "show details" + when "show details" puts workspace.show_details(search_result) - break - elsif selected_command == "send message" + puts options + when "send message" puts "What message do you want to send?" message_body = gets.chomp - workspace.send_message(message_body, slack_id) + convert_to_username = workspace.selected.username + workspace.send_message(message_body, "@#{convert_to_username}") + puts "Message sent. Returning to main menu..." + puts prompt + break + else + puts "Invalid input. Returning to main menu..." + puts prompt break end end - else - puts "Invalid input. Returning to main menu..." - puts prompt end when "select channel" - puts "Would you like to search for a channel by channel name or id?" - search_channel_choice = gets.chomp.downcase - if search_channel_choice == "channel name" - puts "Please enter the channel name: " - channel_name = gets.chomp.downcase - search_result = workspace.search("channel", channel_name) - if search_result == nil - puts "Channel not found. Returning to main menu..." - puts prompt - else - puts "Channel found. Please select from the following options: - Show Details - Send Message" - selected_command = gets.chomp.downcase - if selected_command == "show details" - puts workspace.show_details(search_result) - break - elsif selected_command == "send message" - puts "What message do you want to send?" - message_body = gets.chomp - workspace.send_message(message_body, channel_name) + puts "Please enter a channel name or Slack ID." + channel_name = gets.chomp.downcase + search_result = workspace.search("channel", channel_name) + if search_result == nil + puts "Channel not found. Returning to main menu..." + puts prompt + break + else + puts "Channel found." + options = "Please select from the following options: + Show Details + Send Message + Main Menu" + puts options + while selected_command = gets.chomp.downcase + case selected_command + when "main menu" + puts prompt break - end - end - elsif search_channel_choice == "id" - puts "Please enter the channel's slack id: " - slack_id = gets.chomp.upcase - search_result = workspace.search("channel", slack_id) - if search_result == nil - puts "Channel not found. Returning to main menu..." - puts prompt - else - puts "Channel found. Please select from the following options: - Show Details - Send Message" - selected_command = gets.chomp.downcase - if selected_command == "show details" + when "show details" puts workspace.show_details(search_result) - break - elsif selected_command == "send message" + puts options + when "send message" puts "What message do you want to send?" message_body = gets.chomp - workspace.send_message(message_body, slack_id) + convert_to_channel_name = workspace.selected.channel_name + workspace.send_message(message_body, convert_to_channel_name) + puts "Message sent. Returning to main menu..." + puts prompt + break + else + puts "Invalid input. Returning to main menu..." + puts prompt break end end - else - puts "Invalid input. Returning to main menu..." - puts prompt end else - puts "Error: Invalid selection. Returning to main menu...." - puts prompt + puts "Invalid input. Returning to main menu..." + break end end puts "Thank you for using the Ada Slack CLI" - end -main if __FILE__ == $PROGRAM_NAME \ No newline at end of file +main if __FILE__ == $PROGRAM_NAME diff --git a/lib/workspace.rb b/lib/workspace.rb index d4bc765d..0ef2328d 100644 --- a/lib/workspace.rb +++ b/lib/workspace.rb @@ -70,7 +70,7 @@ def search(data_source, query_term) @selected = nil if data_source == "user" @users.each do |current_user| - if current_user.username == query_term || current_user.slack_id == query_term + if current_user.username == query_term || current_user.slack_id == query_term.upcase @selected = current_user break end @@ -78,7 +78,7 @@ def search(data_source, query_term) return @selected elsif data_source == "channel" @channels.each do |current_channel| - if current_channel.channel_name == query_term || current_channel.slack_id == query_term + if current_channel.channel_name == query_term || current_channel.slack_id == query_term.upcase @selected = current_channel break end