Class: NdsApi::Http
- Inherits:
-
Object
- Object
- NdsApi::Http
- Defined in:
- lib/nds_api/http.rb
Instance Method Summary collapse
- #get(url) ⇒ Object
-
#initialize(options = {}) ⇒ Http
constructor
A new instance of Http.
- #post(url, data) ⇒ Object
- #put(url, data) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Http
Returns a new instance of Http.
8 9 10 |
# File 'lib/nds_api/http.rb', line 8 def initialize( = {}) = .dup end |
Instance Method Details
#get(url) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/nds_api/http.rb', line 12 def get(url) JSON.parse(open(url, http_basic_authentication: [api_user, api_password]).read) rescue StandardError => error puts "NDS API ERROR: #{error} (GET:#{url})" raise error end |
#post(url, data) ⇒ Object
19 20 21 |
# File 'lib/nds_api/http.rb', line 19 def post(url, data) http_action('post', url, data) end |
#put(url, data) ⇒ Object
23 24 25 |
# File 'lib/nds_api/http.rb', line 23 def put(url, data) http_action('put', url, data) end |