Skip to content

Conversation

@idhallie
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 reviewed the API documentation, played with Postman, and tested in the terminal. We learned that API documentation can be vague at times. It's important to carefully review the JSON format to ensure that you are using the correct syntax to pull information.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? For our list_channel method, it invokes a request call to the API through HTTParty. The API processes/interprets the request and sends back a JSON file that HTTParty transforms into a response object in Ruby.
How does your program check for and handle errors when using the Slack API? Our program raises an exception if the response from Slack is not a response code 200. If not a 200, it indicates something was not right.
Did you need to make any changes to the design work we did in class? If so, what were they? No, we used the recommended design.
Did you use any of the inheritance idioms we've talked about in class? How? We utilized template methods: send_message in the Recipient class. Slack.rb gathers a message from the user (text) that is passed as an argument in workspace.send_message where a selected recipient (user/channel instance) is stored in an instance variable. workspace.send_message calls recipient.send_message with the parameters of message and slack_id (from the selected recipient instance stored there) and executes the request.
How does VCR aid in testing a program that uses an API? VCR makes a recording of the API call and tests. It is helpful to limit the calls to API during testing, which could sometimes cause delays or expense. Using VCR is tricky because you need to ensure that it is recording what you need to test. For instance, if you do not have the method call in the VCR recording, you cannot test the method result.

@dHelmgren
Copy link

slack.rb

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene (no slack tokens) Good
Comprehension questions good
Functionality
List users/channels good
Select user/channel good
Show details good
Send message yes
Program runs without crashing yes
Implementation
API errors are handled appropriately yes
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 Way to go! Very solid work on this. I have a few quibbles, but overall this is exemplary.

private

def details
raise NotImplementedError, 'Implement me in a child class!'

Choose a reason for hiding this comment

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

Nice!

end

def self.get(url)
response = HTTParty.get(url, query: {token: ENV["SLACK_TOKEN"]})

Choose a reason for hiding this comment

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

I like that this is at a low level of the program rather than being passed around

end

def self.list
response = Channel.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.

I'd put this URL in a variable, just for clarity's sake. I'm being picky.

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