Class: RandomOrg::ApiClient Private
- Inherits:
-
Object
- Object
- RandomOrg::ApiClient
- Defined in:
- lib/random_org/api_client.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The API client responsible for making all the calls.
Class Method Summary collapse
-
.build_request(which_request, args = nil) ⇒ Hash
private
Constructs a request to the API.
-
.perform_request(req) ⇒ Hash
private
Performs a request to the API.
Class Method Details
.build_request(which_request, args = nil) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Constructs a request to the API
14 15 16 17 18 19 20 21 |
# File 'lib/random_org/api_client.rb', line 14 def self.build_request(which_request, args = nil) req = base_request req[:params] = args.merge('apiKey' => RandomOrg.configuration.api_key) req[:method] = setup_request_method(which_request) req end |
.perform_request(req) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Performs a request to the API
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/random_org/api_client.rb', line 26 def self.perform_request(req) response = RestClient.post(@endpoint_uri, req.to_json) case response.code when 200 return JSON.parse(response.body) when 400 wrong_api_key_error when 500 api_server_error end nil end |