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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,20 @@ end
puts response['pagination'] # { "current_page" => 1, "total_pages" => 3, ... }
```

#### iOS In-App Provisioning Preflight

```ruby
response = client.console.ios_preflight(
card_template_id: "0xt3mp14t3-3x1d",
access_pass_ex_id: "0xp455-3x1d"
)

puts "Provisioning Credential ID: #{response.provisioning_credential_identifier}"
puts "Sharing Instance ID: #{response.sharing_instance_identifier}"
puts "Card Template ID: #{response.card_template_identifier}"
puts "Environment ID: #{response.environment_identifier}"
```

## Configuration

The SDK can be configured with a custom API endpoint:
Expand Down Expand Up @@ -313,7 +327,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/access
| 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()` | - |
| POST /v1/console/card-templates/{id}/ios_preflight | `console.ios_preflight()` | Y |
| GET /v1/console/ledger-items | `console.list_ledger_items()` / `console.ledger_items()` | Y |
| GET /v1/console/webhooks | `console.webhooks.list()` | - |
| POST /v1/console/webhooks | `console.webhooks.create()` | - |
Expand Down
19 changes: 19 additions & 0 deletions lib/accessgrid/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def list_ledger_items(params = {})

alias ledger_items list_ledger_items

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

private

def transform_template_params(params)
Expand Down Expand Up @@ -141,6 +147,19 @@ def initialize(data)
end
end

# Represents an iOS In-App Provisioning preflight response.
class IosPreflight
attr_reader :provisioning_credential_identifier, :sharing_instance_identifier,
:card_template_identifier, :environment_identifier

def initialize(data)
@provisioning_credential_identifier = data['provisioningCredentialIdentifier']
@sharing_instance_identifier = data['sharingInstanceIdentifier']
@card_template_identifier = data['cardTemplateIdentifier']
@environment_identifier = data['environmentIdentifier']
end
end

# Represents a billing ledger item.
class LedgerItem
attr_reader :created_at, :amount, :id, :kind, :metadata, :access_pass
Expand Down
31 changes: 31 additions & 0 deletions spec/console_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,35 @@
expect(console.method(:ledger_items)).to eq(console.method(:list_ledger_items))
end
end

describe '#ios_preflight' do
let(:preflight_response) do
{
provisioningCredentialIdentifier: 'prov_cred_123',
sharingInstanceIdentifier: 'share_inst_456',
cardTemplateIdentifier: 'card_tmpl_789',
environmentIdentifier: 'env_abc'
}
end

it 'returns an IosPreflight object' do
stub_api_request(
:post,
'/v1/console/card-templates/tmpl_123/ios_preflight',
body: preflight_response,
request_body: { access_pass_ex_id: 'pass_456' }
)

result = console.ios_preflight(
card_template_id: 'tmpl_123',
access_pass_ex_id: 'pass_456'
)

expect(result).to be_a(AccessGrid::IosPreflight)
expect(result.provisioning_credential_identifier).to eq('prov_cred_123')
expect(result.sharing_instance_identifier).to eq('share_inst_456')
expect(result.card_template_identifier).to eq('card_tmpl_789')
expect(result.environment_identifier).to eq('env_abc')
end
end
end