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

Fire - Aimee and Tram #8

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

Fire - Aimee and Tram #8

wants to merge 41 commits into from

Conversation

trambui09
Copy link

@trambui09 trambui09 commented Oct 9, 2020

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? Explored it based on the instructions. Specifically, we looked at how the response was formatted through Postman/Ruby and what different parameters were needed. For the next project, we learned how to properly read through the API documentation.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? The client sends a request to the server and the server interprets the request and sends back a response. There are different types of requests, we used get and post in our project to the Slack API.
How does your program check for and handle errors when using the Slack API? We have a custom error called SlackAPI Error that inherited from Exception. If the user encounters the error, we rescued the error to ensure that our program does not break.
How did the design and organization of your project change over time? Our CLI control loop with the slack.rb changed wave after wave to account for the added requirements. We also discovered how template methods needed to be utilized in its child classes and be properly linked to the workspace class.
Did you use any of the inheritance idioms we've talked about in class? How? Yes, recipient is our abstract class, it was never instantiated, but the user and channel classes inherited from the recipient and overrode the template methods of details and .list_all.
How does VCR aid in testing a program that uses an API? VCR allows us to create cassettes (API mocking/stubbing) to record our prior requests and store the response in file. Therefore, we can run our code/tests without calling the API again (given that it's a recorded request). These recorded tests can be run offline.

Copy link

@CheezItMan CheezItMan 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. ✔️, nice work here!
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

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 7+ in Code Review && 3+ in Functional Requirements

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
Descriptive/Readable
Concise
Logical/Organized

Summary

This was really excellent work. You hit all the learning goals with a great design. Take a look at my comments and let me know what questions you have. Well done.

@@ -1,6 +1,7 @@
/coverage/
/old/

.DS_Store

# Ignore environemnt variables

Choose a reason for hiding this comment

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

Suggested change
# Ignore environemnt variables
# Ignore environment variables

@@ -1,6 +1,7 @@
/coverage/
/old/

Choose a reason for hiding this comment

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

Please add coverage to your .gitignore it keeps the pull request manageable in size.

Suggested change
/old/
/old/
coverage

Comment on lines +32 to +36
rescue SlackAPIError => exception
puts '🔥👾👾🔥👾🔥👾👾🔥👾🔥👾👾🔥👾👾🔥👾👾🔥👾👾🔥👾👾🔥'
puts "Encountered an error: #{exception}"
puts '🔥👾👾🔥👾🔥👾👾🔥👾🔥👾👾🔥👾👾🔥👾👾🔥👾👾🔥👾👾🔥'
end

Choose a reason for hiding this comment

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

Emojis!

Comment on lines +42 to +49
def self.get(url, params)
response = HTTParty.get(url, params)
unless response['ok'] == true
raise SlackAPIError, "API call failed - #{response['error']}"
end

return response
end

Choose a reason for hiding this comment

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

Great helper method

return info
end

def self.list_all

Choose a reason for hiding this comment

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

👍


Dotenv.load

class User < Recipient

Choose a reason for hiding this comment

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

👍 Nice work here!

Comment on lines +16 to +28
def select_user(id)

user_array = @users.find do |user|
user.slack_id == id || user.name == id
end
# @selected is an instance of the chosen user
@selected = user_array

puts "user #{id} not found" if @selected.nil?

return @selected

end

Choose a reason for hiding this comment

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

Just notice how select_user and select_channel are pretty much the same, just use a different array?

Maybe make a helper method that takes the list of recipients to search through as a parameter.

end
end

describe "send_message" do

Choose a reason for hiding this comment

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

Nice tests!

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