Class: AccessGrid::Console
- Inherits:
-
Object
- Object
- AccessGrid::Console
- Defined in:
- lib/accessgrid/console.rb
Overview
Manages enterprise template and logging operations.
Instance Attribute Summary collapse
-
#credential_profiles ⇒ Object
readonly
Returns the value of attribute credential_profiles.
-
#hid ⇒ Object
readonly
Returns the value of attribute hid.
-
#webhooks ⇒ Object
readonly
Returns the value of attribute webhooks.
Instance Method Summary collapse
- #create_landing_page(**params) ⇒ Object
- #create_pass_template_pair(params) ⇒ Object
- #create_template(params) ⇒ Object
-
#event_log(params) ⇒ Object
Keep event_log for backwards compatibility.
- #get_logs(template_id, params = {}) ⇒ Object
-
#initialize(client) ⇒ Console
constructor
A new instance of Console.
- #ios_preflight(card_template_id:, access_pass_ex_id:) ⇒ Object
- #list_landing_pages ⇒ Object
- #list_ledger_items(params = {}) ⇒ Object (also: #ledger_items)
- #list_pass_template_pairs(params = {}) ⇒ Object
- #publish_template(template_id) ⇒ Object
- #read_template(template_id) ⇒ Object
-
#reveal_smart_tap(template_id) ⇒ Object
Reveal the SmartTap private key for a card template, decrypted client-side.
- #update_landing_page(landing_page_id:, **params) ⇒ Object
- #update_template(template_id, params) ⇒ Object
Constructor Details
Instance Attribute Details
#credential_profiles ⇒ Object (readonly)
Returns the value of attribute credential_profiles.
7 8 9 |
# File 'lib/accessgrid/console.rb', line 7 def credential_profiles @credential_profiles end |
#hid ⇒ Object (readonly)
Returns the value of attribute hid.
7 8 9 |
# File 'lib/accessgrid/console.rb', line 7 def hid @hid end |
#webhooks ⇒ Object (readonly)
Returns the value of attribute webhooks.
7 8 9 |
# File 'lib/accessgrid/console.rb', line 7 def webhooks @webhooks end |
Instance Method Details
#create_landing_page(**params) ⇒ Object
111 112 113 114 |
# File 'lib/accessgrid/console.rb', line 111 def create_landing_page(**params) response = @client.make_request(:post, '/v1/console/landing-pages', params) LandingPage.new(response) end |
#create_pass_template_pair(params) ⇒ Object
59 60 61 62 |
# File 'lib/accessgrid/console.rb', line 59 def create_pass_template_pair(params) response = @client.make_request(:post, '/v1/console/card-template-pairs', params) PassTemplatePair.new(response) end |
#create_template(params) ⇒ Object
16 17 18 19 20 |
# File 'lib/accessgrid/console.rb', line 16 def create_template(params) transformed_params = transform_template_params(params) response = @client.make_request(:post, '/v1/console/card-templates', transformed_params) Template.new(response) end |
#event_log(params) ⇒ Object
Keep event_log for backwards compatibility
43 44 45 46 47 |
# File 'lib/accessgrid/console.rb', line 43 def event_log(params) template_id = params.delete(:card_template_id) response = get_logs(template_id, params) response['logs'] || [] end |
#get_logs(template_id, params = {}) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/accessgrid/console.rb', line 33 def get_logs(template_id, params = {}) response = @client.make_request(:get, "/v1/console/card-templates/#{template_id}/logs", nil, params) # Return full response to match Python's behavior response['logs'] = response['logs'].map { |log| Event.new(log) } if response['logs'] response end |
#ios_preflight(card_template_id:, access_pass_ex_id:) ⇒ Object
99 100 101 102 103 |
# File 'lib/accessgrid/console.rb', line 99 def ios_preflight(card_template_id:, access_pass_ex_id:) data = { access_pass_ex_id: access_pass_ex_id } response = @client.make_request(:post, "/v1/console/card-templates/#{card_template_id}/ios_preflight", data) IosPreflight.new(response) end |
#list_landing_pages ⇒ Object
105 106 107 108 109 |
# File 'lib/accessgrid/console.rb', line 105 def list_landing_pages response = @client.make_request(:get, '/v1/console/landing-pages') pages = response.is_a?(Array) ? response : response.fetch('landing_pages', []) pages.map { |page| LandingPage.new(page) } end |
#list_ledger_items(params = {}) ⇒ Object Also known as: ledger_items
64 65 66 67 68 69 70 71 72 |
# File 'lib/accessgrid/console.rb', line 64 def list_ledger_items(params = {}) response = @client.make_request(:get, '/v1/console/ledger-items', nil, params) if response['ledger_items'] response['ledger_items'] = response['ledger_items'].map { |item| LedgerItem.new(item) } end response end |
#list_pass_template_pairs(params = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/accessgrid/console.rb', line 49 def list_pass_template_pairs(params = {}) response = @client.make_request(:get, '/v1/console/card-template-pairs', nil, params) if response['card_template_pairs'] response['card_template_pairs'] = response['card_template_pairs'].map { |pair| PassTemplatePair.new(pair) } end response end |
#publish_template(template_id) ⇒ Object
76 77 78 79 |
# File 'lib/accessgrid/console.rb', line 76 def publish_template(template_id) response = @client.make_request(:post, "/v1/console/card-templates/#{template_id}/publish") PublishTemplateResponse.new(response) end |
#read_template(template_id) ⇒ Object
28 29 30 31 |
# File 'lib/accessgrid/console.rb', line 28 def read_template(template_id) response = @client.make_request(:get, "/v1/console/card-templates/#{template_id}") Template.new(response) end |
#reveal_smart_tap(template_id) ⇒ Object
Reveal the SmartTap private key for a card template, decrypted client-side.
The SDK generates a fresh ephemeral P-256 keypair per call, submits the public half, and decrypts the server’s response. The returned RevealTemplatePrivateKey carries the plaintext PEM in #private_key; the encrypted envelope is consumed internally and not exposed.
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/accessgrid/console.rb', line 87 def reveal_smart_tap(template_id) keypair = SmartTapRevealCrypto.generate_keypair response = @client.make_request( :post, "/v1/console/card-templates/#{template_id}/smart-tap/reveal", { client_public_key: keypair[:pub_pem] } ) plaintext = SmartTapRevealCrypto.decrypt_envelope(response['encrypted_private_key'], keypair[:priv]) RevealTemplatePrivateKey.new(response.merge('private_key' => plaintext)) end |
#update_landing_page(landing_page_id:, **params) ⇒ Object
116 117 118 119 |
# File 'lib/accessgrid/console.rb', line 116 def update_landing_page(landing_page_id:, **params) response = @client.make_request(:put, "/v1/console/landing-pages/#{landing_page_id}", params) LandingPage.new(response) end |
#update_template(template_id, params) ⇒ Object
22 23 24 25 26 |
# File 'lib/accessgrid/console.rb', line 22 def update_template(template_id, params) transformed_params = transform_template_params(params) response = @client.make_request(:put, "/v1/console/card-templates/#{template_id}", transformed_params) Template.new(response) end |