Skip to content

Conversation

@llinneaa
Copy link

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 read through the documentation and utilized Postman to ensure the output is valid and as expected. Both tools will be useful and transferable to future API projects.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? The program requests information from an API, and the API responds with information fitting the request. Our program requests information about users/channels from the Slack API, and the Slack API responds with a JSON data structure, which our program can then use to respond to user requests from the CLI.
How does your program check for and handle errors when using the Slack API? Our CLI is always ensuring user input is valid by checking the user input against the previously requested data from the Slack API. If user input is not found within that structure, the command line reprompts the user until they enter valid input.
Did you need to make any changes to the design work we did in class? If so, what were they? Yes, we made Workspace a child class of the Recipient class and created instances to store each user and channels in the Workspace class.
Did you use any of the inheritance idioms we've talked about in class? How? We used abstract methods in the Parent class, Recipient, which were only implemented in the child class Workspace.
How does VCR aid in testing a program that uses an API? VCR keeps the data static so we are always running the tests against the same data (a local copy of the data requested from the Slack API).

@jmaddox19
Copy link

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) X
Comprehension questions X
Functionality
List users/channels Yes!
Select user/channel Yes!
Show details Yes!
Send message Yes!
Program runs without crashing Yeah it does!
Implementation
API errors are handled appropriately No (see comment on "get_channels" method)
Inheritance model matches in-class activity No, there is no behavior setup in Recipient, User, or Channel that appears to be used.
Inheritance idioms (abstract class, template methods, polymorphism) used appropriately There appears to have been an avoidance of using the classes that involved polymorphism (Recipient, User, & Channel) to support any of the functionality. I'm curious to understand from y'all what roadblocks you faced in writing functionality in those classes.
Methods are used to break work down into simpler tasks Yes, methods are very small and succinct (which the exception of "main" in "slack.rb" which is understandable)
Class and instance methods are used appropriately No class methods are actually implemented. "get_channels" and "get_users" would have been good opportunities to create class methods since those methods don't read or write the attributes of Workspace at all.
Tests written for User functionality Yes, though no functionality is written in it so the testing is appropriately minimal
Tests written for Channel Functionality Yes, though no functionality is written in it so the testing is appropriately minimal
Tests written for sending a message Yes
Overall Love the use of table_print! Shows an extra effort to make the program easily usable :) I'm concerned about the limited use of polymorphism (ie. the limited amount of code in the Recipient, User, and Channel classes). Also want to make sure y'all are able to write code to handle api error since I don't see that in this assignment.

lib/workspace.rb Outdated
def get_channels
response = self.get(BASE_URL + "channels.list", query: QUERY)

channels = response["channels"].map do |channel|

Choose a reason for hiding this comment

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

This is where you could check the code from the API and raise a SlackApiError (from the design scaffolding) if the code is not 200.

lib/workspace.rb Outdated
channel: @selected[0].id,
text: message
}
HTTParty.post(BASE_URL + "chat.postMessage", query: post_query)

Choose a reason for hiding this comment

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

Another place where API error codes could be handled

Choose a reason for hiding this comment

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

to be more explicit, anywhere an api call is made is somewhere api error codes ought to be handled.

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