Class: ADPDownloader::HttpClient
- Inherits:
-
Object
- Object
- ADPDownloader::HttpClient
- Defined in:
- lib/adp-downloader/http_client.rb
Instance Method Summary collapse
- #download(url) ⇒ Object
- #get(url) ⇒ Object
-
#initialize ⇒ HttpClient
constructor
A new instance of HttpClient.
- #post(url, data) ⇒ Object
Constructor Details
#initialize ⇒ HttpClient
Returns a new instance of HttpClient.
6 7 8 9 |
# File 'lib/adp-downloader/http_client.rb', line 6 def initialize # FIXME: https://github.com/andersonvom/adp-downloader/issues/6 #_raise_on_error(_login(Config.credentials)) end |
Instance Method Details
#download(url) ⇒ Object
22 23 24 |
# File 'lib/adp-downloader/http_client.rb', line 22 def download(url) agent.get(url).body end |
#get(url) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/adp-downloader/http_client.rb', line 11 def get(url) res = agent.get(url) _raise_on_error(res) contents = res.body contents.to_s.empty? ? {} : JSON.parse(contents) end |
#post(url, data) ⇒ Object
18 19 20 |
# File 'lib/adp-downloader/http_client.rb', line 18 def post(url, data) agent.post(url, data) end |