Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
accessgrid (0.2.0)
accessgrid (0.4.0)
base64

GEM
Expand Down
94 changes: 90 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,25 @@ client = AccessGrid.new(account_id, secret_key)
card = client.access_cards.issue(
card_template_id: card_template_id,
employee_id: "123456789",
card_number: "16187",
tag_id: "DDEADB33FB00B5",
full_name: "Employee name",
email: "employee@yourwebsite.com",
phone_number: "+19547212241",
classification: "full_time",
start_date: "2025-01-31T22:46:25.601Z",
expiration_date: "2025-04-30T22:46:25.601Z",
employee_photo: "[image_in_base64_encoded_format]"
department: "Engineering",
location: "San Francisco",
site_name: "HQ Building A",
workstation: "4F-207",
mail_stop: "MS-401",
company_address: "123 Main St, San Francisco, CA 94105",
start_date: Time.now.utc.iso8601(3),
expiration_date: 3.months.from_now.utc.iso8601(3),
employee_photo: "[image_in_base64_encoded_format]",
title: "Engineering Manager",
metadata: {
"department": "engineering",
"badge_type": "contractor"
}
)

# Provision is an alias for issue (for backwards compatibility)
Expand Down Expand Up @@ -323,6 +333,77 @@ puts "Completed registration for org: #{result.name}"
puts "Status: #{result.status}"
```

### Landing Pages

#### List landing pages

```ruby
landing_pages = client.console.list_landing_pages

landing_pages.each do |page|
puts "ID: #{page.id}, Name: #{page.name}, Kind: #{page.kind}"
puts " Password Protected: #{page.password_protected}"
puts " Logo URL: #{page.logo_url}" if page.logo_url
end
```

#### Create a landing page

```ruby
landing_page = client.console.create_landing_page(
name: "Miami Office Access Pass",
kind: "universal",
additional_text: "Welcome to the Miami Office",
bg_color: "#f1f5f9",
allow_immediate_download: true
)

puts "Landing page created: #{landing_page.id}"
puts "Name: #{landing_page.name}, Kind: #{landing_page.kind}"
```

#### Update a landing page

```ruby
landing_page = client.console.update_landing_page(
landing_page_id: "0xlandingpage1d",
name: "Updated Miami Office Access Pass",
additional_text: "Welcome! Tap below to get your access pass.",
bg_color: "#e2e8f0"
)

puts "Landing page updated: #{landing_page.id}"
puts "Name: #{landing_page.name}"
```

### Credential Profiles

#### List credential profiles

```ruby
profiles = client.console.credential_profiles.list

profiles.each do |profile|
puts "ID: #{profile.id}, Name: #{profile.name}, AID: #{profile.aid}"
end
```

#### Create a credential profile

```ruby
profile = client.console.credential_profiles.create(
name: 'Main Office Profile',
app_name: 'KEY-ID-main',
keys: [
{ value: 'your_32_char_hex_master_key_here' },
{ value: 'your_32_char_hex__read_key__here' }
]
)

puts "Profile created: #{profile.id}"
puts "AID: #{profile.aid}"
```

## Configuration

The SDK can be configured with a custom API endpoint:
Expand Down Expand Up @@ -402,6 +483,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/access
| GET /v1/console/webhooks | `console.webhooks.list()` | Y |
| POST /v1/console/webhooks | `console.webhooks.create()` | Y |
| DELETE /v1/console/webhooks/{id} | `console.webhooks.delete()` | Y |
| GET /v1/console/landing-pages | `console.list_landing_pages()` | Y |
| POST /v1/console/landing-pages | `console.create_landing_page()` | Y |
| PUT /v1/console/landing-pages/{id} | `console.update_landing_page()` | Y |
| GET /v1/console/credential-profiles | `console.credential_profiles.list()` | Y |
| POST /v1/console/credential-profiles | `console.credential_profiles.create()` | Y |
| POST /v1/console/hid/orgs | `console.hid.orgs.create()` | Y |
| POST /v1/console/hid/orgs/activate | `console.hid.orgs.activate()` | Y |
| GET /v1/console/hid/orgs | `console.hid.orgs.list()` | Y |
Expand Down
6 changes: 5 additions & 1 deletion lib/accessgrid/access_cards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def manage_state(card_id, action)
class Card
attr_reader :id, :state, :url, :install_url, :details, :full_name,
:expiration_date, :card_template_id, :card_number, :site_code,
:file_data, :direct_install_url, :devices, :metadata, :temporary
:file_data, :direct_install_url, :devices, :metadata, :temporary,
:employee_id, :organization_name, :created_at

def initialize(data)
data ||= {}
Expand All @@ -86,6 +87,9 @@ def initialize(data)
@devices = data.fetch('devices', [])
@metadata = data.fetch('metadata', {})
@temporary = data.fetch('temporary', nil)
@employee_id = data.fetch('employee_id', nil)
@organization_name = data.fetch('organization_name', nil)
@created_at = data.fetch('created_at', nil)
end

def to_s
Expand Down
71 changes: 69 additions & 2 deletions lib/accessgrid/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
module AccessGrid
# Manages enterprise template and logging operations.
class Console
attr_reader :webhooks, :hid
attr_reader :webhooks, :hid, :credential_profiles

def initialize(client)
@client = client
@webhooks = Webhooks.new(client)
@hid = HID.new(client)
@credential_profiles = CredentialProfiles.new(client)
end

def create_template(params)
Expand Down Expand Up @@ -73,6 +74,22 @@ def ios_preflight(card_template_id:, access_pass_ex_id:)
IosPreflight.new(response)
end

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

def create_landing_page(**params)
response = @client.make_request(:post, '/v1/console/landing-pages', params)
LandingPage.new(response)
end

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

private

def transform_template_params(params)
Expand All @@ -91,7 +108,8 @@ def transform_template_params(params)
class Template
attr_reader :id, :name, :platform, :protocol, :use_case, :created_at,
:last_published_at, :issued_keys_count, :active_keys_count,
:allowed_device_counts, :support_settings, :terms_settings, :style_settings
:allowed_device_counts, :support_settings, :terms_settings, :style_settings,
:metadata

def initialize(data)
@id = data['id']
Expand All @@ -107,6 +125,7 @@ def initialize(data)
@support_settings = data['support_settings']
@terms_settings = data['terms_settings']
@style_settings = data['style_settings']
@metadata = data['metadata'] || {}
end
end

Expand Down Expand Up @@ -205,6 +224,54 @@ def initialize(data)
end
end

# Represents a landing page configuration.
class LandingPage
attr_reader :id, :name, :created_at, :kind, :password_protected, :logo_url

def initialize(data)
@id = data['id']
@name = data['name']
@created_at = data['created_at']
@kind = data['kind']
@password_protected = data['password_protected']
@logo_url = data['logo_url']
end
end

# Represents a credential profile configuration.
class CredentialProfile
attr_reader :id, :aid, :name, :apple_id, :created_at, :card_storage, :keys, :files

def initialize(data)
@id = data['id']
@aid = data['aid']
@name = data['name']
@apple_id = data['apple_id']
@created_at = data['created_at']
@card_storage = data['card_storage']
@keys = data['keys'] || []
@files = data['files'] || []
end
end

# Manages credential profile operations.
class CredentialProfiles
def initialize(client)
@client = client
end

def create(**params)
response = @client.make_request(:post, '/v1/console/credential-profiles', params)
CredentialProfile.new(response)
end

def list
response = @client.make_request(:get, '/v1/console/credential-profiles')
profiles = response.is_a?(Array) ? response : response.fetch('credential_profiles', [])
profiles.map { |profile| CredentialProfile.new(profile) }
end
end

# Manages webhook operations.
class Webhooks
def initialize(client)
Expand Down
2 changes: 1 addition & 1 deletion lib/accessgrid/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# lib/accessgrid/version.rb
module AccessGrid
VERSION = '0.2.0'
VERSION = '0.4.0'
end
Loading