Skip to content

Conversation

@calopter
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 the documentation for the endpoints we were interested in and used postman to verify a basic request.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? Our program makes requests and uses corresponding responses to build data.
How does your program check for and handle errors when using the Slack API? We raise a SlackAPIError anytime we get a non-successful response code.
Did you need to make any changes to the design work we did in class? If so, what were they? We made no changes.
Did you use any of the inheritance idioms we've talked about in class? How? Recipient defines template methods to be implemented by child classes.
How does VCR aid in testing a program that uses an API? It allows to avoid repeating requests every time we run the tests.

@kaidamasaki
Copy link

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) Yes.
Comprehension questions Yes.
Functionality
List users/channels Yes.
Select user/channel Yes.
Show details Yes.
Send message Yes.
Program runs without crashing Yes.
Implementation
API errors are handled appropriately Mostly.
Inheritance model matches in-class activity Yes.
Inheritance idioms (abstract class, template methods, polymorphism) used appropriately Yes.
Methods are used to break work down into simpler tasks Yes.
Class and instance methods are used appropriately Yes.
Tests written for User functionality Yes.
Tests written for Channel Functionality Yes.
Tests written for sending a message Yes.
Overall Great job! You have some issues with omitting error messages in exceptions but overall things look really good. Also, I liked how succinct your answers to the comprehension questions were.

1 similar comment
@kaidamasaki
Copy link

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) Yes.
Comprehension questions Yes.
Functionality
List users/channels Yes.
Select user/channel Yes.
Show details Yes.
Send message Yes.
Program runs without crashing Yes.
Implementation
API errors are handled appropriately Mostly.
Inheritance model matches in-class activity Yes.
Inheritance idioms (abstract class, template methods, polymorphism) used appropriately Yes.
Methods are used to break work down into simpler tasks Yes.
Class and instance methods are used appropriately Yes.
Tests written for User functionality Yes.
Tests written for Channel Functionality Yes.
Tests written for sending a message Yes.
Overall Great job! You have some issues with omitting error messages in exceptions but overall things look really good. Also, I liked how succinct your answers to the comprehension questions were.

class SlackApiError < Exception; end

def initialize(slack_id:, name:)
raise ArgumentError unless (slack_id && name)

Choose a reason for hiding this comment

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

This is redundant, keyword arguments without defaults are required.

end

def self.list
raise NotImplementedError, "template method"

Choose a reason for hiding this comment

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

Template method! 🎉


def self.get(url, params)
response = HTTParty.get(url, query: params)
raise SlackApiError unless response['ok']

Choose a reason for hiding this comment

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

It would be helpful to include the error in the message and also check the response code.

Suggested change
raise SlackApiError unless response['ok']
raise SlackApiError.new(response["error"]) unless response['ok'] && response.code == 200

raise SlackApiError
end

return true

Choose a reason for hiding this comment

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

Returning true is redundant here, since you know this succeeded if it returns.

begin
workspace.send_message
rescue Recipient::SlackApiError
puts "Unable to send message\n\n"

Choose a reason for hiding this comment

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

If you'd include a message you could print a more descriptive error here.

        rescue Recipient::SlackApiError => api_error
          puts "Unable to send message #{api_error.message}\n\n"


def send_message
if selected
puts "Please enter message to send to #{selected.name}: "

Choose a reason for hiding this comment

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

Printing belongs in your driver code (slack.rb). Including it here makes this difficult to unit-test.

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