Skip to content

Conversation

@iamsammysam
Copy link

@iamsammysam iamsammysam commented Sep 14, 2019

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 started with the Slack API documentation (which we found unusually helpful, with good examples of queries and output). Classmates also helped us explore the API's functionality. We got more comfortable working with APIs and feel more confident about interacting with them in the future.
Give a short summary of the request/response cycle. Where does your program fit into that scheme? Cycle summary: a client sends a message to a server, the server processes the request, then the server sends the response to the client. Our program is primarily in the client role, using HTTParty to send requests to the API server, which then responds with the requested information. An exception is the "send message" functionality, where our program briefly steps into the server role when it provides message text for the API to send to the Slack workspace.
How does your program check for and handle errors when using the Slack API? In addition to raising an error if the API returns a status other than 200, we created a custom error class (API_Error) that gets raised if someone tries to implement a child class method in the parent class. In retrospect, this error could have been given a more descriptive name (maybe "ParentClassError"?) and it probably would have been helpful to also have another custom error that told users when there is a problem with the API (as opposed to an error within the program) but unfortunately we didn't get that far.
Did you need to make any changes to the design work we did in class? If so, what were they? One change we made was combining the workspace methods select_channel and select_user into a single method. Since both methods took the same parameter (slack_id), this was an easy update and made our code a tiny bit DRYer (baby steps!).
Did you use any of the inheritance idioms we've talked about in class? How? We are still getting our heads around inheritance idioms, but we think updating our select method so that it works on both users and channels is an application of polymorphism. Also, the Recipient class methods self.list and details are template methods that are designed to be implemented in a child class.
How does VCR aid in testing a program that uses an API? VCR allows a program's interactions with the API server to be "recorded" so that repeated tests are interacting with a "tape" of the server responses instead of the live server. This is helpful because most tests will be quicker and cheaper if they don't need to be sent to the live server every time they are run.

Samantha Coll and others added 29 commits September 10, 2019 19:14
…e to quit and added select user method to CLI.
… above for user, recipient, channel, and workspace.
@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 yes
Show details yes
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 Great work overall! This really demonstrates that you met the learning goals! Keep up the hard work!

puts "\n"
end
else
puts "Sorry, I didn't understand your request. Please try again."

Choose a reason for hiding this comment

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

The quit options should probably not print this message!


user_input = gets.chomp

until user_input == "quit"

Choose a reason for hiding this comment

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

I'd do this slightly differently.

Suggested change
until user_input == "quit"
tracking_int = 1
until tracking_int == 0
case quit
tracking_int = 0
end

Choose a reason for hiding this comment

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

I'd maybe make it a bool, and give it a better name, but this way you address the quit case separately.

Comment on lines +16 to +22
def details
raise API_Error.new, 'Implement me in a child class!'
end

def self.list
raise API_Error.new, 'Implement me in a child class!'
end

Choose a reason for hiding this comment

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

Yeah!

require "httparty"
require 'pry'

class API_Error < StandardError

Choose a reason for hiding this comment

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

nice move implementing this here!

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