Class: AccessGrid::AccessCards
- Inherits:
-
Object
- Object
- AccessGrid::AccessCards
- Defined in:
- lib/accessgrid/access_cards.rb
Overview
Manages NFC key card lifecycle operations.
Instance Method Summary collapse
- #delete(card_id) ⇒ Object
- #get(card_id:) ⇒ Object
-
#initialize(client) ⇒ AccessCards
constructor
A new instance of AccessCards.
- #issue(params) ⇒ Object (also: #provision)
- #list(template_id, state = nil) ⇒ Object
- #resume(card_id) ⇒ Object
- #suspend(card_id) ⇒ Object
- #unlink(card_id) ⇒ Object
- #update(card_id, params) ⇒ Object
Constructor Details
#initialize(client) ⇒ AccessCards
Returns a new instance of AccessCards.
7 8 9 |
# File 'lib/accessgrid/access_cards.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#delete(card_id) ⇒ Object
49 50 51 |
# File 'lib/accessgrid/access_cards.rb', line 49 def delete(card_id) manage_state(card_id, 'delete') end |
#get(card_id:) ⇒ Object
19 20 21 22 |
# File 'lib/accessgrid/access_cards.rb', line 19 def get(card_id:) response = @client.make_request(:get, "/v1/key-cards/#{card_id}") Card.new(response) end |
#issue(params) ⇒ Object Also known as: provision
11 12 13 14 |
# File 'lib/accessgrid/access_cards.rb', line 11 def issue(params) response = @client.make_request(:post, '/v1/key-cards', params) Card.new(response) end |
#list(template_id, state = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/accessgrid/access_cards.rb', line 29 def list(template_id, state = nil) params = { template_id: template_id } params[:state] = state if state response = @client.make_request(:get, '/v1/key-cards', nil, params) response.fetch('keys', []).map { |item| Card.new(item) } end |
#resume(card_id) ⇒ Object
41 42 43 |
# File 'lib/accessgrid/access_cards.rb', line 41 def resume(card_id) manage_state(card_id, 'resume') end |
#suspend(card_id) ⇒ Object
37 38 39 |
# File 'lib/accessgrid/access_cards.rb', line 37 def suspend(card_id) manage_state(card_id, 'suspend') end |
#unlink(card_id) ⇒ Object
45 46 47 |
# File 'lib/accessgrid/access_cards.rb', line 45 def unlink(card_id) manage_state(card_id, 'unlink') end |