Skip to content

Commit

Permalink
feat(interface/guest_building_access): standardise guest access
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Sep 12, 2024
1 parent 8f7ada5 commit 4b6745c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/placeos-driver/interface/guest_building_access.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "json"

abstract class PlaceOS::Driver
module Interface::GuestBuildingAccess
# use inheritance to provide additional details as required to revoke access
abstract class AccessDetails
include JSON::Serializable
include JSON::Serializable::Unmapped

property card_hex : String
end

# a function for granting guests access to a building
# should return a payload that can be encoded into a QR code
# the response is expected to be hexstring
abstract def grant_guest_access(email : String, from : Int64, until : Int64) : AccessDetails

Check failure on line 16 in src/placeos-driver/interface/guest_building_access.cr

View workflow job for this annotation

GitHub Actions / deploy

cannot use 'until' as a parameter name

# revoke access to a building
def revoke_guest_access(access : AccessDetails) : Nil
access_json = access.to_json
details = {{ parse_type("::PlaceOS::Driver::Interface::GuestBuildingAccess::AccessDetails").resolve.subclasses.first }}.from_json(access_json)
revoke_access details
end

# where details is an instance of your AccessDetails subclass
abstract protected def revoke_access(details)
end
end

0 comments on commit 4b6745c

Please sign in to comment.