Skip to content

Commit 241a25f

Browse files
committed
feat(inner_range/integriti): add csv sync field
1 parent 50f64f6 commit 241a25f

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/inner_range/integriti.cr

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class InnerRange::Integriti < PlaceOS::Driver
3030
custom_field_hid_origo: "cf_HasVirtualCard",
3131
custom_field_email: "cf_EmailAddress",
3232
custom_field_phone: "cf_Mobile",
33+
custom_field_csv_sync: "cf_CSVCustom",
3334

3435
# 16 bit card number in Wiegand 26
3536
# Ideally guests have their own site id and the full range of card numbers
@@ -48,6 +49,7 @@ class InnerRange::Integriti < PlaceOS::Driver
4849
@cf_origo = setting?(String, :custom_field_hid_origo) || "cf_HasVirtualCard"
4950
@cf_email = setting?(String, :custom_field_email) || "cf_EmailAddress"
5051
@cf_phone = setting?(String, :custom_field_phone) || "cf_Mobile"
52+
@cf_csv = setting?(String, :custom_field_csv_sync) || "cf_CSVCustom"
5153
@guest_card_template = setting?(String, :guest_card_template) || ""
5254
guest_card_start = setting?(UInt16, :guest_card_start) || 0_u16
5355
guest_card_end = setting?(UInt16, :guest_card_end) || (UInt16::MAX - 1_u16)
@@ -77,6 +79,7 @@ class InnerRange::Integriti < PlaceOS::Driver
7779
getter cf_email : String = "cf_EmailAddress"
7880
getter cf_phone : String = "cf_Mobile"
7981
getter cf_origo : String = "cf_HasVirtualCard"
82+
getter cf_csv : String = "cf_CSVCustom"
8083
getter guest_card_template : String = ""
8184
getter guest_access_group : String = ""
8285
@guest_card_range : Range(UInt16, UInt16) = 0_u16..UInt16::MAX
@@ -624,6 +627,7 @@ class InnerRange::Integriti < PlaceOS::Driver
624627
"cf_origo" => origo : Bool,
625628
"cf_phone" => phone : String,
626629
"cf_email" => email : String,
630+
"cf_csv" => csv : String,
627631
"PrimaryPermissionGroup" => primary_permission_group : PermissionGroup,
628632
})
629633

@@ -636,6 +640,7 @@ class InnerRange::Integriti < PlaceOS::Driver
636640
"cf_origo" => origo : Bool,
637641
"cf_phone" => phone : String,
638642
"cf_email" => email : String,
643+
"cf_csv" => csv : String,
639644
"PrimaryPermissionGroup" => primary_permission_group : PermissionGroup, # ref only
640645
}) do
641646
def site_id
@@ -674,18 +679,39 @@ class InnerRange::Integriti < PlaceOS::Driver
674679
end
675680

676681
@[PlaceOS::Driver::Security(Level::Support)]
677-
def create_user(name : String, email : String, phone : String? = nil, site_id : String | Int64? = nil) : String
682+
def create_user(name : String, email : String, phone : String? = nil, site_id : String | Int64? = nil, csv : String? = nil) : String
678683
first_name, second_name = name.split(' ', 2)
679684
user = extract_add_or_update_result(add_entry("User", UpdateFields{
680685
"FirstName" => first_name,
681686
"SecondName" => second_name,
682687
"Site" => Ref.new("SiteKeyword", (site_id || default_site_id).to_s),
683688
cf_email => email.strip.downcase,
684689
cf_phone => phone,
690+
cf_csv => csv,
685691
}.compact!))
686692
user.address.as(String)
687693
end
688694

695+
@[PlaceOS::Driver::Security(Level::Support)]
696+
def update_user_custom(
697+
user_id : String,
698+
email : String? = nil,
699+
phone : String? = nil,
700+
origo : Bool? = nil,
701+
csv : String? = nil,
702+
)
703+
fields = UpdateFields{
704+
cf_email => email.try(&.strip.downcase),
705+
cf_phone => phone,
706+
cf_origo => origo,
707+
cf_csv => csv,
708+
}.compact!
709+
710+
return nil if fields.empty?
711+
712+
extract_add_or_update_result(update_entry("User", user_id, fields))
713+
end
714+
689715
# ================
690716
# User Permissions
691717
# ================

0 commit comments

Comments
 (0)