diff --git a/README.md b/README.md index 949933c..ceae0d4 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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()` | - | diff --git a/lib/accessgrid/console.rb b/lib/accessgrid/console.rb index f1addf1..a239f34 100644 --- a/lib/accessgrid/console.rb +++ b/lib/accessgrid/console.rb @@ -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) @@ -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 diff --git a/spec/console_spec.rb b/spec/console_spec.rb index 9f5733a..21a101f 100644 --- a/spec/console_spec.rb +++ b/spec/console_spec.rb @@ -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