Class: CloudCheckr::API::Client
- Inherits:
-
Object
- Object
- CloudCheckr::API::Client
- Defined in:
- lib/cloud_checkr/api/client.rb
Constant Summary collapse
- DEFAULT_URL =
"https://api2.cloudcheckr.com".freeze
- DEFAULT_FORMAT =
:json
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #api ⇒ Object
- #default_params ⇒ Object
-
#get(controller_name, api_call, params = nil, headers = nil, &request_builder) ⇒ Object
API.
-
#initialize(options = {}, &connection_builder) ⇒ Client
constructor
A new instance of Client.
- #post(controller_name, api_call, params = nil, headers = nil, &request_builder) ⇒ Object
Constructor Details
#initialize(options = {}, &connection_builder) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 |
# File 'lib/cloud_checkr/api/client.rb', line 15 def initialize( = {}, &connection_builder) @access_key = .fetch(:access_key, API.access_key) @use_account = .fetch(:use_account, API.use_account) @url = .fetch(:url, DEFAULT_URL) @format = .fetch(:format, :json) @connection_builder = connection_builder end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
13 14 15 |
# File 'lib/cloud_checkr/api/client.rb', line 13 def access_key @access_key end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
13 14 15 |
# File 'lib/cloud_checkr/api/client.rb', line 13 def format @format end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/cloud_checkr/api/client.rb', line 13 def url @url end |
Instance Method Details
#api ⇒ Object
33 34 35 |
# File 'lib/cloud_checkr/api/client.rb', line 33 def api @api ||= build_connection end |
#default_params ⇒ Object
37 38 39 40 41 42 |
# File 'lib/cloud_checkr/api/client.rb', line 37 def default_params {}.tap do |params| params[:access_key] = @access_key unless @access_key.nil? params[:use_account] = @use_account unless @use_account.nil? end end |
#get(controller_name, api_call, params = nil, headers = nil, &request_builder) ⇒ Object
API
25 26 27 |
# File 'lib/cloud_checkr/api/client.rb', line 25 def get(controller_name, api_call, params = nil, headers = nil, &request_builder) handle_response api.get(prepare_path(controller_name, api_call), prepare_params(params), headers, &request_builder) end |
#post(controller_name, api_call, params = nil, headers = nil, &request_builder) ⇒ Object
29 30 31 |
# File 'lib/cloud_checkr/api/client.rb', line 29 def post(controller_name, api_call, params = nil, headers = nil, &request_builder) handle_response api.post(prepare_path(controller_name, api_call), prepare_params(params), headers, &request_builder) end |