Module: Epitech::Api
- Included in:
- Connection
- Defined in:
- lib/version.rb,
lib/api/version.rb,
lib/epitech-api.rb,
lib/utils.rb
Defined Under Namespace
Modules: CheckApi, Errors, InfoApi, SearchApi Classes: Connection
Constant Summary collapse
- VERSION =
Gem version
"1.0.0"- BASE_URL =
JSON API URL
'http://ws.paysdu42.fr/JSON/?'
Instance Method Summary collapse
-
#call_api(opts = {}) ⇒ Object
Used to call the webservice.
Instance Method Details
#call_api(opts = {}) ⇒ Object
Used to call the webservice
8 9 10 11 12 13 14 |
# File 'lib/utils.rb', line 8 def call_api(opts={}) tmp = open(URI(URI.escape(BASE_URL + hash_to_req(opts)))).read tmp = tmp.split("\n").drop(1).join("\n") while tmp.start_with?(%Q(SSH connection failed.)) json = JSON.parse(tmp) raise get_error_class(json['error']) if json['error'] != 'none' json['result'] end |