Skip to content

Conversation

@dtingg
Copy link

@dtingg dtingg commented Sep 13, 2019

slack.rb

Congratulations! You're submitting your assignment!

You and your partner should collaborate on the answers to these questions.

Comprehension Questions

Question Answer
How did you go about exploring the Slack API? Did you learn anything that would be useful for your next project involving an API? We started by reading the documentation closely, then we tried various API calls to experiment with the methods. We learned that Postman is very helpful when deciphering API responses.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? Whenever we make an API call, we are making a request and the server returns a response that we can parse.
How does your program check for and handle errors when using the Slack API? We make sure that the selected user/channel does exist, which prevents invalid queries from being passed to the API. For all API calls, if the response code isn’t 200 and ok isn’t true, then a SlackAPIError is raised.
Did you need to make any changes to the design work we did in class? If so, what were they? Our send_message method is inside the Workspace class, whereas the instructor design placed it within the Recipient class. We also didn’t implement the details method in Recipient. We placed it in the slack.rb file because it primarily prints.
Did you use any of the inheritance idioms we've talked about in class? How? Yes, Recipient is an abstract class with a template method called self.all. We implement this in the child classes (User and Channel). We also use polymorphism for the self.get method, because it can get data for a User or a Channel.
How does VCR aid in testing a program that uses an API? It reduces the number of API calls you have to make and it allows you to run the tests without an active internet connection.

/specs/cassettes/

# Ignore slack token verification
slack_token_verification_test.rb

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good on you to have this test!


PUMPKIN_SPICE = SlackCLI::Workspace.new()

MAIN_MENU = ["List Users", "List Channels", "Select User", "Select Channel", "Details", "Send Message", "Get Message History", "Change Bot Settings", "Quit"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of a global constant.

im_query = { token: ENV["SLACK_API_TOKEN"]}
im_response = HTTParty.get(im_url, query: im_query)

unless im_response.code == 200 && im_response.parsed_response["ok"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of a custom exception. Consider using a begin/rescue in your CLI so that it doesn't break when this happens.

query = { token: ENV["SLACK_API_TOKEN"] }
response = HTTParty.get(url, query: query)

unless response.code == 200 && response.parsed_response["ok"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work adding this exception raising here.

end
end

describe "send_message method" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work testing for positive and negative results.

@beccaelenzil
Copy link

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) check
Comprehension questions check
Functionality
List users/channels check
Select user/channel check
Show details check
Send message check
Program runs without crashing mostly -- it crashed when an exception was raised
Implementation
API errors are handled appropriately check -- make sure to handle these in the cli
Inheritance model matches in-class activity check
Inheritance idioms (abstract class, template methods, polymorphism) used appropriately check
Methods are used to break work down into simpler tasks check
Class and instance methods are used appropriately check
Tests written for User functionality check
Tests written for Channel Functionality check
Tests written for sending a message check
Overall Excellent job overall. This code is well-written and well-tested. It is clear to me that the learning goals around understanding the request/response cycle, consuming an API, and implementing a design using inheritance from scratch were all met. I've left a few inline comments for you to review below, but in general I'm quite impressed by what I see here. Keep up the hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants