Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rachael and Christabel Slack-CLI #3

Open
wants to merge 44 commits into
base: master
Choose a base branch
from

Conversation

RachaelGomez
Copy link

Assignment Submission: Slack CLI

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

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 carefully read the docs we learned a lot about .env and being careful about what each API requires.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? Within the request/response cycle our program acts as the client sending requests such as GET and POST to the server.
How does your program check for and handle errors when using the Slack API? Our program looks for response errors and repeats them back to the program so that the programmer has a more informed idea of what needs to be fixed.
How did the design and organization of your project change over time? In the first wave of our project workspace.rb was handling all of the information. As our project expanded it became necessary to create new classes to better handle the information and keep the class relationships clear so that each class can interact with one another in a concise and efficient manner.
Did you use any of the inheritance idioms we've talked about in class? How? We used two template methods within our code. Both can be found in the Recipient class which is the parent class to both Users and Channels. These template methods are #details .list_all. This allows them to be used in the user and channel classes whenever a recipient is created.
How does VCR aid in testing a program that uses an API? VCR helped us in testing our programs so that we did not have to continuously call on the API to test each individual test. By saving the responses that the API gave to the VCR within a cassette, it saved time running the tests and money because each call can cost the user money. It also lessened the likelihood of a token being revoked by the API for overuse if an infinite loop was accidentally created within the code.

RachaelGomez and others added 30 commits October 6, 2020 14:08
Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

Slack CLI

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Practices best practices working with APIs. The .env is not checked into git, and no API token was directly used in the Ruby code without ENV. ✔️
Practices error handling with APIs. For all pieces of code that make an API call, it handles API requests that come back with errors/error status codes appropriately. ✔️
Implements inheritance and inheritance idioms. There is a Recipient class. User and Channel inherit from Recipient. In Recipient, there are appropriate methods defined that are used in both User and Channel. Some may be implemented. Some may be template methods. ✔️
Practices clean code. lib/slack.rb only interacts with Workspace to show a separation of responsibilities. Complex logic is broken into smaller helper methods. ✔️
Practices instance methods vs. class methods appropriately. The methods to list all Channels or Users is likely a class method within those respective classes. ✔️
Practices best practices for testing. The project has and uses VCR mocking when running tests, and can run offline. ✔️
Practices writing tests. The User, Channel, and Workspace classes have unit tests. ✔️
Practices writing tests. There are tests for sending messages (the location of these tests may differ, but is likely in Recipient) ✔️
Practices git with at least 15 small commits and meaningful commit messages ✔️

Functional Requirements

Functional Requirement yes/no
As a user of the CLI program, I can list users and channels ✔️
As a user of the CLI program, I can select users and channels ✔️
As a user of the CLI program, I can show the details of a selected user or channel ✔️
As a user of the CLI program, when I input something inappropriately, the program runs without crashing ✔️

Overall Feedback

Excellent work 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, including ways you could consider refactoring. Keep up the hard work!

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 7+ in Code Review && 3+ in Functional Requirements ✔️
Yellow (Approaches Standards) 6+ in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0-5 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Perfect Indentation
Elegant/Clever
Concise
Logical/Organized

Comment on lines +31 to +37
def self.error_message(response)
if response["ok"] != true
raise ArgumentError, "API request failed with error: #{response["error"]}."
else
return response
end
end

Choose a reason for hiding this comment

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

Nice use of a helper method


def send_message(message)
params = {token: ENV['SLACK_TOKEN'], channel: @slack_id, text: message}
return self.class.error_message(HTTParty.post(POST_URL, body: params))

Choose a reason for hiding this comment

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

This is a lot in one line. Consider making the post request, storing the response in a variable likeresponse and then calling the helper method error_message to increase readability.

Comment on lines +35 to +50
if selected_recipient
puts "Would you like details? (yes/no)"
details_selection = input_validation(gets.chomp.downcase)
if details_selection == "yes"
puts workspace.show_details(selected_recipient)
end
puts "Would you like to #{selected_recipient.class == User ? "send a message" : "post"} to #{selected_recipient.name}? (yes/no)"
message_selection = input_validation(gets.chomp.downcase)
if message_selection == "yes"
puts "Please write your message."
message = gets.chomp
selected_recipient.send_message(message)
end
else
puts "No #{(selection == 3) ? "user" : "channel"} found."
end

Choose a reason for hiding this comment

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

Nice choice to only prompt the user for details of sending message if a user has been selected. Consider breaking the functionality to show details and send message into helper methods.

return input
end

def translate_input(string_input)

Choose a reason for hiding this comment

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

Great use of a helper method.

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.

3 participants