Class: BGPView::API
- Inherits:
-
Object
- Object
- BGPView::API
- Defined in:
- lib/bgpview/api.rb
Constant Summary collapse
- API_BASE_URL =
'https://api.bgpview.io/'
Class Method Summary collapse
Class Method Details
.call(url) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bgpview/api.rb', line 11 def self.call(url) client = HTTPClient.new response = client.get("#{API_BASE_URL}#{url}") raise ApiError, response.reason if response.status != 200 hash = JSON.parse(response.body, symbolize_names: true) raise ApiError, hash[:status_message] unless hash[:status] == 'ok' hash end |