Skip to content
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

ruby: remove duplication in request methods, and make params uniform #136

Merged
merged 3 commits into from
Jul 5, 2016

Conversation

tiegz
Copy link
Contributor

@tiegz tiegz commented Jun 30, 2016

Some ruby [client] refactoring:

  • break out get, post, and delete http methods to reuse
  • moves the exception-catching boilerplate into ^ methods
  • swap filter and data naming with params, to make it clear we're talking about HTTP request params

puts e.inspect
end
def malware_analyses(params={})
params = params.merge(access_token: @access_token)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also toyed w/the idea of moving this line from each method into the HTTP methods -- thoughts?

@ghost ghost added the CLA Signed label Jun 30, 2016
@tiegz
Copy link
Contributor Author

tiegz commented Jul 1, 2016

@mgoffin got more where this came from, once this is merged 😎

@mgoffin
Copy link
Contributor

mgoffin commented Jul 1, 2016

Sounds good :) Although I don't maintain the Ruby stuff ;)

@tiegz
Copy link
Contributor Author

tiegz commented Jul 1, 2016

aha! That's the key, then I conjure @maus-

rescue => e
puts e.inspect
end
params[:after] = cursor
Copy link

Choose a reason for hiding this comment

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

I understand this was in here before, but it is generally considered bad style to change the input parameters. Would be better if this copies stuff, e.g.

query_params = (params || {}).merge(:after : cursor)

@tiegz
Copy link
Contributor Author

tiegz commented Jul 3, 2016

@tomdz thx for looking this over! I've implemented your suggestions, and I also have another changeset after this PR that cleans up the code more.

@maus-
Copy link
Contributor

maus- commented Jul 3, 2016

Awesome - the refactoring looks good. Glad to see this is getting some polish. I don't think this is a result of your changes but we still have some neglected functionality. IOC Submissions / Updates seem to be throwing 400 errors. I'll take a closer look shortly here.

@tiegz
Copy link
Contributor Author

tiegz commented Jul 3, 2016

@maus- thx, I have a PR incoming for that next! (with updates to the example script, etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants