Class: EdmTrain::Client
- Inherits:
-
Object
- Object
- EdmTrain::Client
- Defined in:
- lib/edm_train/client.rb
Overview
Client for the EdmTrain API
Instance Method Summary collapse
-
#get(path, params = {}) ⇒ Hash
Perform a GET request to the EdmTrain API.
Instance Method Details
#get(path, params = {}) ⇒ Hash
Perform a GET request to the EdmTrain API
46 47 48 49 50 51 52 53 54 |
# File 'lib/edm_train/client.rb', line 46 def get(path, params = {}) raise MissingKeyError unless EdmTrain.api_key params[:client] = EdmTrain.api_key result = JSON.parse(URI.open("https://edmtrain.com/api/#{path}?#{to_query(params)}").read) raise APIError, result['message'] unless result['success'] result['data'] end |