Skip to content

Space- Shonda#30

Open
Shonda860 wants to merge 3 commits intoAda-C13:masterfrom
Shonda860:master
Open

Space- Shonda#30
Shonda860 wants to merge 3 commits intoAda-C13:masterfrom
Shonda860:master

Conversation

@Shonda860
Copy link

No description provided.

@tildeee
Copy link

tildeee commented Apr 2, 2020

Great work on this assignment, Shonda! The review of Slack CLI looks great, and the reflection answers you have look good too. I'm adding a few comments in areas where I think the answers could be more clear or I want to add more info, so let me know if you have any questions. Otherwise, well done!

```ruby
# Copy and paste your answer below this comment
```ruby # Copy and paste your answer below this comment
def self.get(sub_url) # self calls only know about its self to call in another method # must call the (Class name).something # Recipent.get(querty) is called on the respective class that
Copy link

Choose a reason for hiding this comment

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

This is a perfect explanation of self/the class method syntax! Nice!

```ruby # Copy and paste your answer below this comment
def self.get(sub_url) # self calls only know about its self to call in another method # must call the (Class name).something # Recipent.get(querty) is called on the respective class that
url = "https://slack.com/api/#{sub_url}?token=#{SLACK_TOKEN}&pretty=1"
response = HTTParty.get(url)
Copy link

Choose a reason for hiding this comment

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

This is a perfectly good way to make this HTTP call! You construct the url by interpolating a lot of the important things you need, such as the sub_url and API key.

In case the string interpolation is confusing to read, it's good to know that the API key is being passed in as a query parameter. (One way to tell this by reading it is seeing any URL that has a ? in it, and seeing the different pairs afterwards. In this example, we see token=...)

If you wanted to try an alternative syntax, you may use this syntax with HTTParty:

HTTParty.get("https://slack.com/api/#{sub_url}", query: {token: ENV['SLACK_TOKEN']})

This line is saying "Make a GET request to this url. Also, pass along these query parameters: token, with a value of ENV[SLACK_TOKEN]"

Again, both syntaxes are correct; just wanted to make sure you knew the other option!

- Answer: GET
1. What is the path (or the URL, or endpoint) of this request?
- Answer: "https://slack.com/api/#{sub_url}?token=#{SLACK_TOKEN}&pretty=1"
1. What are the query params (the additional data sent with the request, besides the verb and the path)?
Copy link

Choose a reason for hiding this comment

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

Do you have an answer here? In this case, it's the token, which holds the value of the Slack API Key/Slack Token!

```

1. What does the program do if the response comes back with a status code of 200?
- Answer: if the response is not true or equal to 200
Copy link

Choose a reason for hiding this comment

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

Hm, this answer doesn't quite make sense considering the question.

The program makes a request to send a message... and a response eventually comes back from the server, back to the program. A response always has a status code. In the case that the response has a status code of 200, what does the program do?

This question is asking what happens when the response comes back with a status code of 200. Your answer should be talking about the program's logic of what happens after that! What does a status code of 200 mean?

1. What does the program do if the response comes back with a status code of 200?
- Answer: if the response is not true or equal to 200
1. What does the program do if the response does not come back with a status code of 200?
- Answer: Raise a built in response era
Copy link

Choose a reason for hiding this comment

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

Similar to my other comment, I'd love to hear more details about this. What does your program do if the response has a status code that isn't 200? What does "Raise a built in response era" mean in this case?

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