Skip to content

Commit

Permalink
Clean up OpenURI call
Browse files Browse the repository at this point in the history
  • Loading branch information
swrobel committed Jan 30, 2019
1 parent 66feff9 commit 4d8fcbe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/api_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
module ApiMethods
def api_get(url)
uri = URI.parse(url)
response = JSON.parse(uri.open('User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7', 'Cookie' => "MSW_session=#{ENV['MSW_SESSION_ID']}").read, object_class: OpenStruct)
open_uri_args = {
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7',
'Cookie' => "MSW_session=#{ENV['MSW_SESSION_ID']}"
}
response = JSON.parse(uri.open(open_uri_args).read, object_class: OpenStruct)
request = ApiRequest.create(request: url, response: response, success: true)
OpenStruct.new(request: request, response: response)
rescue OpenURI::HTTPError => e
Expand Down

0 comments on commit 4d8fcbe

Please sign in to comment.