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 - Jing & Ren #2

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

Fire - Jing & Ren #2

wants to merge 16 commits into from

Conversation

Jing-321
Copy link

@Jing-321 Jing-321 commented Oct 8, 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? Reading API document is very crucial to understand how to use a particular API.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? We send request as client to Slack API, and received response from Slack API. We use this process to look at users and channels and to send messages.
How does your program check for and handle errors when using the Slack API? We check the response["ok"] to make sure it is true. We also rescued one of the exceptions in slack.rb.
How did the design and organization of your project change over time? At first we just have our method in the driver code(slack.rb). Later, we added abstract class (Recipient), and child classes (User and Channel) to hold the methods. And then call them in the driver code.
Did you use any of the inheritance idioms we've talked about in class? How? abstract class, templet classs, Polymorphism
How does VCR aid in testing a program that uses an API? We use VCR for each test that interact Slack API. Therefore, it won't post a new message each time when we run the test.

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. ✔️
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

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

end

def self.list_all
response = self.get("https://slack.com/api/conversations.list")

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 in the parent class.

@@ -0,0 +1,23 @@
require_relative 'recipient'

class Channel < Recipient

Choose a reason for hiding this comment

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

👍

Comment on lines +20 to +22
def self.get(url)
return HTTParty.get(url, query: {token: SLACK_TOKEN})
end

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,23 @@
require_relative 'recipient'

class User < Recipient

Choose a reason for hiding this comment

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

👍

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.

You should also have tests for get or make that class method private.

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.

Good set of 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.

2 participants