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

India and Richelle - Water #12

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

Conversation

indiakato
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 used postman to help us explore working with APIs. We learned how to read API documentation, how to set up permissions, and how to save tokens safely without uploading to github.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? The command line interface sends a request to the slack API. Slack API server returns a list of channels/users in the C14 workspace. If the request or url is invalid, the api will return an error code and message and the cli will display the error.
How does your program check for and handle errors when using the Slack API? Our cli main file checks for user input, and will loop when there is valid input. We check the validity of the API request in the recipient class, where we have the URLs hard coded. If the url is invalid, it will raise a SlackApiError, which we tested in our user_test.rb file.
How did the design and organization of your project change over time? We originally called the APIs separately in different classes, but eventually refactored to where the code for the API call is only in the superclass. The main file changed a lot so that we are only referencing the constructor class (workspace.rb).
Did you use any of the inheritance idioms we've talked about in class? How? Yes, we used inheritance and we have an abstract class and abstract/template methods. We used polymorphism for our .list_all and .detail template methods. We were able to call the same method on separate objects and have those methods act differently based on which object it is acting on.
How does VCR aid in testing a program that uses an API? VCR allows us to store the data from an API call, so that every time you run the tests, you don't have to keep calling the API and prevent getting locked out from the API.

indiakato and others added 30 commits October 6, 2020 10:36
…space & updated select channel & user accordingly
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. ✔️, however User and Channel are pretty skimpy.
Practices writing tests. There are tests for sending messages (the location of these tests may differ, but is likely in Recipient) ✔️, no tests for invalid or unselected channels/users.
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

Nice work, you hit the learning goals here. Well done. Take a look at my comments and let me know what questions you have.

@@ -4,3 +4,4 @@

# Ignore environemnt variables
.env
.idea/

Choose a reason for hiding this comment

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

Thank you! However also please add coverage, it makes for a smaller PR.

Suggested change
.idea/
.idea/
coverage

def self.list_all
base_url = "https://slack.com/api/conversations.list"

response = self.get(base_url)

Choose a reason for hiding this comment

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

Good helper method

@@ -0,0 +1,45 @@
class SlackApiError < StandardError; end

class Recipient

Choose a reason for hiding this comment

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

Great abstract class! 😍

Comment on lines +14 to +22
def select_user(input)
@selected = @users.find { |user| user.name == input }
if @selected
return @selected
else
@selected = @users.find { |user| user.slack_id == input }
end
return @selected
end

Choose a reason for hiding this comment

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

Notice that select user and channel do the same thing, just to different arrays, can you make a helper method?

@@ -0,0 +1,17 @@
require_relative 'test_helper'

describe "Channel class" do

Choose a reason for hiding this comment

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

You should also have tests for the attr_reader attributes for channels, and the constructor.

@@ -0,0 +1,26 @@
require_relative 'test_helper'

describe "User class" do

Choose a reason for hiding this comment

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

You should also have tests for the constructor/attr_reader methods.

expect(@workspace.show_details).must_equal "This user's id is: USLACKBOT, the username is: slackbot and their real name is: Slackbot. They have a status emoji of: N/A and their status text is: N/A"
end

it "can post message to channel and return true" do

Choose a reason for hiding this comment

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

What about posting messages when there is no selected channel/user?

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