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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

strategy:
matrix:
ruby: ['4.0', '3.4', '2.7', '2.6']
ruby: ['4.0', '3.4', '2.7', '2.19']

steps:
- name: Checkout code
Expand Down
42 changes: 23 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,57 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
addressable (2.8.9)
public_suffix (>= 2.0.2, < 8.0)
ast (2.4.3)
base64 (0.3.0)
bigdecimal (3.1.9)
bigdecimal (4.0.1)
bundler-audit (0.9.3)
bundler (>= 1.2.0)
thor (~> 1.0)
coderay (1.1.3)
crack (1.0.0)
crack (1.0.1)
bigdecimal
rexml
diff-lcs (1.5.1)
diff-lcs (1.6.2)
docile (1.4.1)
hashdiff (1.1.2)
json (2.18.0)
hashdiff (1.2.1)
io-console (0.8.2)
json (2.19.3)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
method_source (1.1.0)
parallel (1.27.0)
parser (3.3.10.1)
parser (3.3.10.2)
ast (~> 2.4.1)
racc
prism (1.9.0)
pry (0.15.2)
pry (0.16.0)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (6.0.1)
reline (>= 0.6.0)
public_suffix (7.0.5)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
rake (13.3.1)
regexp_parser (2.11.3)
reline (0.6.3)
io-console (~> 0.5)
rexml (3.4.4)
rspec (3.13.0)
rspec (3.13.2)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.2)
rspec-core (3.13.6)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
rspec-mocks (3.13.8)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
rubocop (1.84.0)
rspec-support (3.13.7)
rubocop (1.86.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
Expand All @@ -64,7 +68,7 @@ GEM
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.0)
rubocop-ast (1.49.1)
parser (>= 3.3.7.2)
prism (~> 1.7)
ruby-progressbar (1.13.0)
Expand All @@ -78,7 +82,7 @@ GEM
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.2.0)
webmock (3.24.0)
webmock (3.26.2)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down
56 changes: 40 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,24 @@ client.access_cards.delete("0xc4rd1d")

```ruby
template = client.console.create_template(
name: "Employee NFC key",
name: "Employee Access Pass",
platform: "apple",
use_case: "employee_badge",
protocol: "desfire",
allow_on_multiple_devices: true,
watch_count: 2,
iphone_count: 3,
design: {
background_color: "#FFFFFF",
label_color: "#000000",
label_secondary_color: "#333333",
background_image: "[image_in_base64_encoded_format]",
logo_image: "[image_in_base64_encoded_format]",
icon_image: "[image_in_base64_encoded_format]"
},
support_info: {
support_url: "https://help.yourcompany.com",
support_phone_number: "+1-555-123-4567",
support_email: "support@yourcompany.com",
privacy_policy_url: "https://yourcompany.com/privacy",
terms_and_conditions_url: "https://yourcompany.com/terms"
background_color: "#FFFFFF",
label_color: "#000000",
label_secondary_color: "#333333",
support_url: "https://help.yourcompany.com",
support_phone_number: "+1-555-123-4567",
support_email: "support@yourcompany.com",
privacy_policy_url: "https://yourcompany.com/privacy",
terms_and_conditions_url: "https://yourcompany.com/terms",
metadata: {
version: "2.1",
approval_status: "approved"
}
)
```
Expand Down Expand Up @@ -278,7 +276,7 @@ end

## Requirements

- Ruby 2.6 or higher
- Ruby 2.19 or higher

## Security

Expand All @@ -298,6 +296,32 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run

Bug reports and pull requests are welcome on GitHub at https://github.com/access-grid/accessgrid-rb.

## Feature Matrix

| Endpoint | Method | Supported |
|---|---|:---:|
| POST /v1/key-cards | `access_cards.issue()` | Y |
| GET /v1/key-cards/{id} | `access_cards.get()` | Y |
| PATCH /v1/key-cards/{id} | `access_cards.update()` | Y |
| GET /v1/key-cards | `access_cards.list()` | Y |
| POST /v1/key-cards/{id}/suspend | `access_cards.suspend()` | Y |
| POST /v1/key-cards/{id}/resume | `access_cards.resume()` | Y |
| POST /v1/key-cards/{id}/unlink | `access_cards.unlink()` | Y |
| POST /v1/key-cards/{id}/delete | `access_cards.delete()` | Y |
| POST /v1/console/card-templates | `console.create_template()` | Y |
| PUT /v1/console/card-templates/{id} | `console.update_template()` | Y |
| GET /v1/console/card-templates/{id} | `console.read_template()` | Y |
| GET /v1/console/card-templates/{id}/logs | `console.get_logs()` / `console.event_log()` | Y |
| GET /v1/console/pass-template-pairs | `console.list_pass_template_pairs()` | Y |
| POST /v1/console/card-templates/{id}/ios_preflight | `console.ios_preflight()` | - |
| GET /v1/console/ledger-items | `console.list_ledger_items()` | Y |
| GET /v1/console/webhooks | `console.webhooks.list()` | - |
| POST /v1/console/webhooks | `console.webhooks.create()` | - |
| DELETE /v1/console/webhooks/{id} | `console.webhooks.delete()` | - |
| POST /v1/console/hid/orgs | `console.hid.orgs.create()` | - |
| POST /v1/console/hid/orgs/activate | `console.hid.orgs.activate()` | - |
| GET /v1/console/hid/orgs | `console.hid.orgs.list()` | - |

## License

The gem is available as open source under the terms of the MIT License.
2 changes: 1 addition & 1 deletion accessgrid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.description = 'A Ruby client for the AccessGrid API'
spec.homepage = 'https://github.com/access-grid/accessgrid-rb'
spec.license = 'MIT'
spec.required_ruby_version = '>= 2.6.0'
spec.required_ruby_version = '>= 3.0'

spec.metadata = { 'source_code_uri' => 'https://github.com/access-grid/accessgrid-rb' }

Expand Down
21 changes: 8 additions & 13 deletions lib/accessgrid/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,14 @@ def list_ledger_items(params = {})
private

def transform_template_params(params)
design = params.delete(:design) || {}
support_info = params.delete(:support_info) || {}

params.merge(
background_color: design[:background_color],
label_color: design[:label_color],
label_secondary_color: design[:label_secondary_color],
support_url: support_info[:support_url],
support_phone_number: support_info[:support_phone_number],
support_email: support_info[:support_email],
privacy_policy_url: support_info[:privacy_policy_url],
terms_and_conditions_url: support_info[:terms_and_conditions_url]
)
design = params.delete(:design)
support_info = params.delete(:support_info)

# Only merge nested keys if they were provided (backward compat)
params.merge!(design) if design
params.merge!(support_info) if support_info

params
end
end

Expand Down
37 changes: 16 additions & 21 deletions spec/console_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,24 @@
expect { console.create_template(template_params) }.not_to raise_error
end

it 'handles missing design and support_info' do
minimal_params = { name: 'Minimal Template', platform: 'apple' }
minimal_request_body = {
name: 'Minimal Template',
it 'handles flat params without nested design/support_info' do
flat_params = {
name: 'Flat Template',
platform: 'apple',
background_color: nil,
label_color: nil,
label_secondary_color: nil,
support_url: nil,
support_email: nil,
support_phone_number: nil,
privacy_policy_url: nil,
terms_and_conditions_url: nil
background_color: '#FFFFFF',
support_url: 'https://help.example.com'
}

stub_api_request(:post, '/v1/console/card-templates', body: success_response, request_body: minimal_request_body)
stub_api_request(:post, '/v1/console/card-templates', body: success_response, request_body: flat_params)

template = console.create_template(flat_params)
expect(template).to be_a(AccessGrid::Template)
end

it 'handles minimal params' do
minimal_params = { name: 'Minimal Template', platform: 'apple' }

stub_api_request(:post, '/v1/console/card-templates', body: success_response, request_body: minimal_params)

template = console.create_template(minimal_params)
expect(template).to be_a(AccessGrid::Template)
Expand All @@ -125,14 +127,7 @@
{
name: 'Updated Badge',
watch_count: 3,
background_color: nil,
label_color: nil,
label_secondary_color: nil,
support_url: nil,
support_email: 'new-support@example.com',
support_phone_number: nil,
privacy_policy_url: nil,
terms_and_conditions_url: nil
support_email: 'new-support@example.com'
}
end

Expand Down