Class: AccessGrid::Client
- Inherits:
-
Object
- Object
- AccessGrid::Client
- Defined in:
- lib/accessgrid.rb
Overview
API client for AccessGrid key card and template management.
Instance Attribute Summary collapse
-
#access_cards ⇒ Object
readonly
Returns the value of attribute access_cards.
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#api_host ⇒ Object
readonly
Returns the value of attribute api_host.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
-
#console ⇒ Object
readonly
Returns the value of attribute console.
Instance Method Summary collapse
-
#initialize(account_id, api_secret, api_host = 'https://api.accessgrid.com') ⇒ Client
constructor
A new instance of Client.
- #make_request(method, path, body = nil, params = nil) ⇒ Object
Constructor Details
#initialize(account_id, api_secret, api_host = 'https://api.accessgrid.com') ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/accessgrid.rb', line 23 def initialize(account_id, api_secret, api_host = 'https://api.accessgrid.com') raise ArgumentError, 'Account ID is required' if account_id.nil? || account_id.empty? raise ArgumentError, 'API Secret is required' if api_secret.nil? || api_secret.empty? @account_id = account_id @api_secret = api_secret @api_host = api_host.chomp('/') @access_cards = AccessCards.new(self) @console = Console.new(self) end |
Instance Attribute Details
#access_cards ⇒ Object (readonly)
Returns the value of attribute access_cards.
21 22 23 |
# File 'lib/accessgrid.rb', line 21 def access_cards @access_cards end |
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
21 22 23 |
# File 'lib/accessgrid.rb', line 21 def account_id @account_id end |
#api_host ⇒ Object (readonly)
Returns the value of attribute api_host.
21 22 23 |
# File 'lib/accessgrid.rb', line 21 def api_host @api_host end |
#api_secret ⇒ Object (readonly)
Returns the value of attribute api_secret.
21 22 23 |
# File 'lib/accessgrid.rb', line 21 def api_secret @api_secret end |
#console ⇒ Object (readonly)
Returns the value of attribute console.
21 22 23 |
# File 'lib/accessgrid.rb', line 21 def console @console end |
Instance Method Details
#make_request(method, path, body = nil, params = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/accessgrid.rb', line 34 def make_request(method, path, body = nil, params = nil) request = Request.new( account_id: account_id, body: body, host: api_host, http_method: method, params: params, path: path ) execute_and_process_request!(request) end |