Skip to content

Commit 3cca58c

Browse files
committed
feat(inner_range/integriti): add license custom field
1 parent 6ad6cd7 commit 3cca58c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/inner_range/integriti.cr

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class InnerRange::Integriti < PlaceOS::Driver
3131
custom_field_email: "cf_EmailAddress",
3232
custom_field_phone: "cf_Mobile",
3333
custom_field_csv_sync: "cf_CSVCustom",
34+
custom_field_license: "cf_LicensePlate",
3435

3536
# 16 bit card number in Wiegand 26
3637
# Ideally guests have their own site id and the full range of card numbers
@@ -50,6 +51,7 @@ class InnerRange::Integriti < PlaceOS::Driver
5051
@cf_email = setting?(String, :custom_field_email) || "cf_EmailAddress"
5152
@cf_phone = setting?(String, :custom_field_phone) || "cf_Mobile"
5253
@cf_csv = setting?(String, :custom_field_csv_sync) || "cf_CSVCustom"
54+
@cf_license = setting?(String, :custom_field_license) || "cf_LicensePlate"
5355
@guest_card_template = setting?(String, :guest_card_template) || ""
5456
guest_card_start = setting?(UInt16, :guest_card_start) || 0_u16
5557
guest_card_end = setting?(UInt16, :guest_card_end) || (UInt16::MAX - 1_u16)
@@ -80,6 +82,7 @@ class InnerRange::Integriti < PlaceOS::Driver
8082
getter cf_phone : String = "cf_Mobile"
8183
getter cf_origo : String = "cf_HasVirtualCard"
8284
getter cf_csv : String = "cf_CSVCustom"
85+
getter cf_license : String = "cf_LicensePlate"
8386
getter guest_card_template : String = ""
8487
getter guest_access_group : String = ""
8588
@guest_card_range : Range(UInt16, UInt16) = 0_u16..UInt16::MAX
@@ -628,6 +631,7 @@ class InnerRange::Integriti < PlaceOS::Driver
628631
"cf_phone" => phone : String,
629632
"cf_email" => email : String,
630633
"cf_csv" => csv : String,
634+
"cf_license" => license : String,
631635
"PrimaryPermissionGroup" => primary_permission_group : PermissionGroup,
632636
})
633637

@@ -641,6 +645,7 @@ class InnerRange::Integriti < PlaceOS::Driver
641645
"cf_phone" => phone : String,
642646
"cf_email" => email : String,
643647
"cf_csv" => csv : String,
648+
"cf_license" => license : String,
644649
"PrimaryPermissionGroup" => primary_permission_group : PermissionGroup, # ref only
645650
}) do
646651
def site_id
@@ -679,7 +684,7 @@ class InnerRange::Integriti < PlaceOS::Driver
679684
end
680685

681686
@[PlaceOS::Driver::Security(Level::Support)]
682-
def create_user(name : String, email : String, phone : String? = nil, site_id : String | Int64? = nil, csv : String? = nil) : String
687+
def create_user(name : String, email : String, phone : String? = nil, site_id : String | Int64? = nil, csv : String? = nil, license : String? = nil) : String
683688
first_name, second_name = name.split(' ', 2)
684689
user = extract_add_or_update_result(add_entry("User", UpdateFields{
685690
"FirstName" => first_name,
@@ -688,6 +693,7 @@ class InnerRange::Integriti < PlaceOS::Driver
688693
cf_email => email.strip.downcase,
689694
cf_phone => phone,
690695
cf_csv => csv,
696+
cf_license => license,
691697
}.compact!))
692698
user.address.as(String)
693699
end
@@ -699,12 +705,14 @@ class InnerRange::Integriti < PlaceOS::Driver
699705
phone : String? = nil,
700706
origo : Bool? = nil,
701707
csv : String? = nil,
708+
license : String? = nil,
702709
)
703710
fields = UpdateFields{
704-
cf_email => email.try(&.strip.downcase),
705-
cf_phone => phone,
706-
cf_origo => origo,
707-
cf_csv => csv,
711+
cf_email => email.try(&.strip.downcase),
712+
cf_phone => phone,
713+
cf_origo => origo,
714+
cf_csv => csv,
715+
cf_license => license,
708716
}.compact!
709717

710718
return nil if fields.empty?

0 commit comments

Comments
 (0)