Module: HealthCards::Importer

Defined in:
lib/health_cards/importer.rb

Overview

Converts a JWS to formats needed by endpoints (e.g. $issue-health-card, download and qr code)

Class Method Summary collapse

Class Method Details

.scan(qr_contents) ⇒ Hash

Scan QR code

Parameters:

  • Array (Array<String>)

    containing numeric QR chunks

Returns:

  • (Hash)

    Hash containing the JWS payload and verification contents



20
21
22
23
# File 'lib/health_cards/importer.rb', line 20

def self.scan(qr_contents)
  qr_codes = QRCodes.new(qr_contents)
  verify_jws qr_codes.to_jws
end

.upload(jws_string) ⇒ Array<Hash>

Import JWS from file upload

Parameters:

  • JSON (String)

    string containing file upload contents

Returns:

  • (Array<Hash>)

    An array of Hashes containing JWS payload and verification contents



9
10
11
12
13
14
15
# File 'lib/health_cards/importer.rb', line 9

def self.upload(jws_string)
  vc = JSON.parse(jws_string)
  vc_jws = vc['verifiableCredential']
  vc_jws.map do |j|
    verify_jws j
  end
end