diff --git a/feedback.md b/feedback.md index f90b999..5f4a2b6 100644 --- a/feedback.md +++ b/feedback.md @@ -1,8 +1,8 @@ # Feedback Rubric -- Student Being Reviewed: -- Reviewer: -- Classroom: +- Student Being Reviewed: Nataliya Pogodina +- Reviewer: Yesenia Torres +- Classroom: Time ## Manual App Testing @@ -17,7 +17,7 @@ 1. 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.) - yes/no + yes @@ -26,7 +26,7 @@ 2. 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.) - yes/no + yes, this is done neatly in Recipient class @@ -35,7 +35,7 @@ 3. 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. - yes/no + yes, makes use of both types of methods @@ -51,7 +51,7 @@ - yes/no + yes, thoughtful use of a "menu" helper function to display options to CLI user @@ -60,7 +60,7 @@ 5. Practices instance methods vs. class methods appropriately. (The methods to list all Channels or Users is a class method within those respective classes.) - yes/no + yes @@ -70,7 +70,7 @@ 6. Practices best practices for testing. (The project has and uses VCR mocking when running tests, and can run offline.) - yes/no + yes @@ -80,7 +80,7 @@ 7. Practices writing tests. (The User, Channel, and Workspace classes have unit tests.) - yes/no + yes, very thorough test of all classes, especially Recipient class @@ -90,7 +90,7 @@ 8. There are also tests for sending messages (the location of these tests may differ, but is likely in Recipient) - yes/no + yes @@ -100,7 +100,7 @@ 9. Practices git with at least 15 small commits and meaningful commit messages - yes/no + yes @@ -118,7 +118,7 @@ 1. As a user of the CLI program, I can list users and channels with the commands list users and list channels - yes/no + yes @@ -126,7 +126,7 @@ 2. As a user of the CLI program, I can select users and channels with the commands select user and select channel - yes/no + yes @@ -134,7 +134,7 @@ 3. As a user of the CLI program, I can show the details of a selected user or channel with the command details - yes/no + yes, good idea to incorporate the user's time zone when displaying details @@ -142,7 +142,7 @@ 4. As a user of the CLI program, when I input something inappropriately, the program runs without crashing. Example commands to try are do_something, or select user followed by Mr. Fakename - yes/no + yes, could be useful to relay the CLI user's input back to them when displaying error message diff --git a/individual-reflection.md b/individual-reflection.md index 603cdeb..36678ef 100644 --- a/individual-reflection.md +++ b/individual-reflection.md @@ -9,48 +9,71 @@ Answer the following comprehension questions **within this file.** Write your an ### `GET` Request Review 1. Describe a GET request that your project makes, and the high-level description of what it does - - Answer: + - Answer: User.load_all method includes a GET request which retrieves information about users of a Slack workspace. When you perform a GET request, the server looks for the data you requested and sends it back to you. GET request performs a READ operation in CRUD methodology. 1. What is the verb of this request? - - Answer: + - Answer: GET 1. What is the path (or the URL, or endpoint) of this request? - - Answer: + - Answer: https://slack.com/api/users.list 1. What are the query params (the additional data sent with the request, besides the verb and the path)? - - Answer: + - Answer: token is the only required argument based on Slack API documentation. Optionals are: cursor (for paginating through data), include_locale(language code of a user, useful for experience customization) and limit(max number of items returned). 1. What is the syntax used to make this request? (Copy and paste a code snippet here) - Answer: ```ruby # Copy and paste your answer below this comment + def self.get_api_data(url:) + response = HTTParty.get(url, query: {token: ENV['SLACK_TOKEN']}) + if response.code != 200 || response["ok"] == false + raise SlackAPIError, "Request processing error: #{response["error"]}" + end + return response + end + # Copy and paste your answer above this comment ``` 1. What does the program do if the response comes back with a status code of 200? - - Answer: + - Answer: it returns an instance of HTTParty::Response which will include information from retrieved JSON (decoded into a hash) 1. What does the program do if the response does not come back with a status code of 200? - - Answer: + - Answer: the program will raise a custom Exception (SlackAPIError) ### `POST` Request Review If your project does not make a POST request, read through Wave 3 on the original Slack CLI, and research and answer questions 1, 2, 3, 4, 6, and 7. 1. Describe a POST request that your project makes, and the high-level description of what it does - - Answer: + - Answer: Recipient#send_message sends a POST request resulting in a message sent to a user or a channel. POST request attempts to create a new data entry. The server will send back a response telling whether this creation was successful. POST request performs a CREATE operation in CRUD methodology. 1. What is the verb of this request? - - Answer: + - Answer: POST 1. What is the path (or the URL, or endpoint) of this request? - - Answer: + - Answer: https://slack.com/api/chat.postMessage 1. What are the query params (the additional data sent with the request, besides the verb and the path)? - - Answer: + - Answer: Required arguments are token, channel (ID or name) and text. There are also many optionals available, such as attachments, icon_emoji, icon_url, link_names, etc. 1. What is the syntax used to make this request? (Copy and paste a code snippet here) - Answer: ```ruby # Copy and paste your answer below this comment + def send_message(message:) + response = HTTParty.post(POST_URL, + query: { + token: ENV['SLACK_TOKEN'], + channel: slack_id, + text: message + } + ) + if response.code != 200 || response["ok"] == false + raise SlackAPIError, "Request processing error: #{response["error"]}" + end + + return response.code == 200 && response.parsed_response["ok"] + end + # Copy and paste your answer above this comment ``` 1. What does the program do if the response comes back with a status code of 200? - - Answer: + - Answer: the method will return true; the message has been sent. 1. What does the program do if the response does not come back with a status code of 200? - - Answer: + - Answer: it will raise a custom Exception (SlackAPIError) ## Request & Response Cycle @@ -62,11 +85,11 @@ There are two actors: Based on the project requirements, when Grace enters "list channels," 1. What is the request being made in the program? - - Answer: + - Answer: in my program channels data is being retrieved from the server as soon as `slack.rb` runs and an instance of Workspace is created (prior to Grace entering "list channels"). It's being accomplished with a GET request. 1. Who is the client? - - Answer: + - Answer: Grace's machine 1. Who is the server? - - Answer: + - Answer: Slack API server ## Part 2: Optional Refactoring @@ -80,4 +103,4 @@ If your reflection inspired you to make minimal changes to your Slack CLI implem ### Describe your optional Slack CLI changes here -Answer: +Answer: N/A