Module: CoronaPresenceTracing::Base::ClassMethods

Defined in:
lib/corona_presence_tracing/base.rb

Instance Method Summary collapse

Instance Method Details

#decode(encoded_payload) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/corona_presence_tracing/base.rb', line 18

def decode(encoded_payload)
  base64_segment = encoded_payload.split('#').last
  qr_payload = QRCodePayload.decode(Base64.urlsafe_decode64(base64_segment))
  location = qr_payload.locationData

  new(
    description: location.description,
    address: location.address,
    start_time: Time.at(location.startTimestamp),
    end_time: Time.at(location.endTimestamp),
    **vendor_info(qr_payload.countryData)
  )
end