-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add file upload #169
Merged
Merged
Add file upload #169
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cdccollins
force-pushed
the
add-file-upload
branch
from
September 11, 2023 10:35
83356a1
to
4c5121d
Compare
benjamineskola
approved these changes
Sep 11, 2023
) | ||
end | ||
|
||
def construct_response(params) | ||
tags = params[:tags].scan(/[a-z]+[_[a-z]]*/) | ||
|
||
tags.map do |tag| | ||
"#{tag.to_s.humanize}: #{params[:"#{tag}"]}\n" | ||
"#{tag.to_s.humanize}: #{params[:"#{tag.strip}"]}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we just do:
Suggested change
"#{tag.to_s.humanize}: #{params[:"#{tag.strip}"]}\n" | |
"#{tag.to_s.humanize}: #{params[tag.strip.to_sym]}\n" |
app/services/http_client.rb
Outdated
Comment on lines
23
to
36
def http_party(endpoint, method, params) | ||
if method.to_s == "post" | ||
HTTParty.post( | ||
"#{api_base_url}#{endpoint}", | ||
headers: { Authorization: authorization_header }, | ||
body: params.merge(file_params_body(params)) | ||
) | ||
else | ||
HTTParty.patch( | ||
"#{api_base_url}#{endpoint}", | ||
headers: { Authorization: authorization_header }, | ||
body: file_params_body(params) | ||
) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do this all in one call, I think:
Suggested change
def http_party(endpoint, method, params) | |
if method.to_s == "post" | |
HTTParty.post( | |
"#{api_base_url}#{endpoint}", | |
headers: { Authorization: authorization_header }, | |
body: params.merge(file_params_body(params)) | |
) | |
else | |
HTTParty.patch( | |
"#{api_base_url}#{endpoint}", | |
headers: { Authorization: authorization_header }, | |
body: file_params_body(params) | |
) | |
end | |
def http_party(endpoint, method, params) | |
HTTParty.send(method | |
"#{api_base_url}#{endpoint}", | |
headers: { Authorization: authorization_header }, | |
body: method == :post ? params.merge(file_params_body(params)) : file_params_body(params) | |
) |
Or if not then I think we still don't need to convert the symbol to a string
Suggested change
def http_party(endpoint, method, params) | |
if method.to_s == "post" | |
HTTParty.post( | |
"#{api_base_url}#{endpoint}", | |
headers: { Authorization: authorization_header }, | |
body: params.merge(file_params_body(params)) | |
) | |
else | |
HTTParty.patch( | |
"#{api_base_url}#{endpoint}", | |
headers: { Authorization: authorization_header }, | |
body: file_params_body(params) | |
) | |
end | |
def http_party(endpoint, method, params) | |
if method == :post | |
HTTParty.post( | |
"#{api_base_url}#{endpoint}", | |
headers: { Authorization: authorization_header }, | |
body: params.merge(file_params_body(params)) | |
) | |
else | |
HTTParty.patch( | |
"#{api_base_url}#{endpoint}", | |
headers: { Authorization: authorization_header }, | |
body: file_params_body(params) | |
) | |
end |
cdccollins
force-pushed
the
add-file-upload
branch
from
September 12, 2023 09:25
4c5121d
to
86d3c4c
Compare
cdccollins
force-pushed
the
add-file-upload
branch
from
September 12, 2023 09:32
86d3c4c
to
35ffb89
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow members of the public to attach files to their responses