mawsitsit 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13d6796c67206b0f552f9551fa5aefde1c3eb96a8e1aee3de6b777246e1d78e9
4
- data.tar.gz: b7a8de632bc9006744e9f29ca1548051acf3743f0af53d1d062364c3e09af0b4
3
+ metadata.gz: 6bf107f10254c4381ea6ddb43804bab677e9d21652f88979c92aee21efe85bf0
4
+ data.tar.gz: cae9847e3ed605ab6c9323883b4b04577455a42f52b3e27bc4f2305a39616122
5
5
  SHA512:
6
- metadata.gz: '080ed2ee076ebdd1a971bb44686b9e112aa860464331bc7dc1c7520094a05525ddc668b73774983a96d95cd2f2ae983de1526d31dc058c1c72fe14a894f91ad6'
7
- data.tar.gz: f8e0194501ae5fb49075de6fce8a6c9cb9481da604094e931113b6c7f8d790658b3db425cca424efe85f10c2e3e2cbe97d7152af61e5a724db432c7aa0507f67
6
+ metadata.gz: 287bc58ab99f97a3f0c78c7ac71f558e5d3d40dafff21e7bcd41fdc08f3ddce1cbc2d152dd9cf035f332c5b97ad62f222d1d61016bde01ccaf68433e9716d7e4
7
+ data.tar.gz: 61dfc1aec419c9e2665d71551bdcaf57bebf5e590a08e6a982d4ad413c6a82cc60af51451d8a1f942f552aa10f8c6060360f3bddf4f8684c947825d57183117e
data/Cargo.lock CHANGED
@@ -26,6 +26,21 @@ dependencies = [
26
26
  "memchr",
27
27
  ]
28
28
 
29
+ [[package]]
30
+ name = "android-tzdata"
31
+ version = "0.1.1"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
34
+
35
+ [[package]]
36
+ name = "android_system_properties"
37
+ version = "0.1.5"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
40
+ dependencies = [
41
+ "libc",
42
+ ]
43
+
29
44
  [[package]]
30
45
  name = "async-recursion"
31
46
  version = "1.1.1"
@@ -34,7 +49,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
34
49
  dependencies = [
35
50
  "proc-macro2",
36
51
  "quote",
37
- "syn 2.0.67",
52
+ "syn 2.0.68",
38
53
  ]
39
54
 
40
55
  [[package]]
@@ -76,7 +91,7 @@ version = "0.69.4"
76
91
  source = "registry+https://github.com/rust-lang/crates.io-index"
77
92
  checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
78
93
  dependencies = [
79
- "bitflags 2.5.0",
94
+ "bitflags 2.6.0",
80
95
  "cexpr",
81
96
  "clang-sys",
82
97
  "itertools",
@@ -87,7 +102,7 @@ dependencies = [
87
102
  "regex",
88
103
  "rustc-hash",
89
104
  "shlex",
90
- "syn 2.0.67",
105
+ "syn 2.0.68",
91
106
  ]
92
107
 
93
108
  [[package]]
@@ -98,9 +113,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
98
113
 
99
114
  [[package]]
100
115
  name = "bitflags"
101
- version = "2.5.0"
116
+ version = "2.6.0"
102
117
  source = "registry+https://github.com/rust-lang/crates.io-index"
103
- checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
118
+ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
104
119
 
105
120
  [[package]]
106
121
  name = "bumpalo"
@@ -116,9 +131,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
116
131
 
117
132
  [[package]]
118
133
  name = "cc"
119
- version = "1.0.99"
134
+ version = "1.0.101"
120
135
  source = "registry+https://github.com/rust-lang/crates.io-index"
121
- checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695"
136
+ checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d"
122
137
 
123
138
  [[package]]
124
139
  name = "cexpr"
@@ -135,6 +150,20 @@ version = "1.0.0"
135
150
  source = "registry+https://github.com/rust-lang/crates.io-index"
136
151
  checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
137
152
 
153
+ [[package]]
154
+ name = "chrono"
155
+ version = "0.4.38"
156
+ source = "registry+https://github.com/rust-lang/crates.io-index"
157
+ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
158
+ dependencies = [
159
+ "android-tzdata",
160
+ "iana-time-zone",
161
+ "js-sys",
162
+ "num-traits",
163
+ "wasm-bindgen",
164
+ "windows-targets 0.52.5",
165
+ ]
166
+
138
167
  [[package]]
139
168
  name = "clang-sys"
140
169
  version = "1.8.1"
@@ -164,9 +193,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
164
193
 
165
194
  [[package]]
166
195
  name = "either"
167
- version = "1.12.0"
196
+ version = "1.13.0"
168
197
  source = "registry+https://github.com/rust-lang/crates.io-index"
169
- checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
198
+ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
170
199
 
171
200
  [[package]]
172
201
  name = "encoding_rs"
@@ -316,7 +345,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
316
345
  dependencies = [
317
346
  "proc-macro2",
318
347
  "quote",
319
- "syn 2.0.67",
348
+ "syn 2.0.68",
320
349
  ]
321
350
 
322
351
  [[package]]
@@ -516,6 +545,29 @@ dependencies = [
516
545
  "tracing",
517
546
  ]
518
547
 
548
+ [[package]]
549
+ name = "iana-time-zone"
550
+ version = "0.1.60"
551
+ source = "registry+https://github.com/rust-lang/crates.io-index"
552
+ checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
553
+ dependencies = [
554
+ "android_system_properties",
555
+ "core-foundation-sys",
556
+ "iana-time-zone-haiku",
557
+ "js-sys",
558
+ "wasm-bindgen",
559
+ "windows-core",
560
+ ]
561
+
562
+ [[package]]
563
+ name = "iana-time-zone-haiku"
564
+ version = "0.1.2"
565
+ source = "registry+https://github.com/rust-lang/crates.io-index"
566
+ checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
567
+ dependencies = [
568
+ "cc",
569
+ ]
570
+
519
571
  [[package]]
520
572
  name = "idna"
521
573
  version = "0.5.0"
@@ -568,9 +620,9 @@ dependencies = [
568
620
 
569
621
  [[package]]
570
622
  name = "lazy_static"
571
- version = "1.4.0"
623
+ version = "1.5.0"
572
624
  source = "registry+https://github.com/rust-lang/crates.io-index"
573
- checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
625
+ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
574
626
 
575
627
  [[package]]
576
628
  name = "lazycell"
@@ -586,9 +638,9 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
586
638
 
587
639
  [[package]]
588
640
  name = "libloading"
589
- version = "0.8.3"
641
+ version = "0.8.4"
590
642
  source = "registry+https://github.com/rust-lang/crates.io-index"
591
- checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
643
+ checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d"
592
644
  dependencies = [
593
645
  "cfg-if",
594
646
  "windows-targets 0.52.5",
@@ -612,9 +664,9 @@ dependencies = [
612
664
 
613
665
  [[package]]
614
666
  name = "log"
615
- version = "0.4.21"
667
+ version = "0.4.22"
616
668
  source = "registry+https://github.com/rust-lang/crates.io-index"
617
- checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
669
+ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
618
670
 
619
671
  [[package]]
620
672
  name = "magnus"
@@ -636,7 +688,7 @@ checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
636
688
  dependencies = [
637
689
  "proc-macro2",
638
690
  "quote",
639
- "syn 2.0.67",
691
+ "syn 2.0.68",
640
692
  ]
641
693
 
642
694
  [[package]]
@@ -644,7 +696,7 @@ name = "mawsitsit"
644
696
  version = "0.1.0"
645
697
  dependencies = [
646
698
  "async-recursion",
647
- "base64",
699
+ "chrono",
648
700
  "exitfailure",
649
701
  "futures",
650
702
  "magnus",
@@ -722,6 +774,15 @@ dependencies = [
722
774
  "minimal-lexical",
723
775
  ]
724
776
 
777
+ [[package]]
778
+ name = "num-traits"
779
+ version = "0.2.19"
780
+ source = "registry+https://github.com/rust-lang/crates.io-index"
781
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
782
+ dependencies = [
783
+ "autocfg",
784
+ ]
785
+
725
786
  [[package]]
726
787
  name = "num_cpus"
727
788
  version = "1.16.0"
@@ -753,7 +814,7 @@ version = "0.10.64"
753
814
  source = "registry+https://github.com/rust-lang/crates.io-index"
754
815
  checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
755
816
  dependencies = [
756
- "bitflags 2.5.0",
817
+ "bitflags 2.6.0",
757
818
  "cfg-if",
758
819
  "foreign-types",
759
820
  "libc",
@@ -770,7 +831,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
770
831
  dependencies = [
771
832
  "proc-macro2",
772
833
  "quote",
773
- "syn 2.0.67",
834
+ "syn 2.0.68",
774
835
  ]
775
836
 
776
837
  [[package]]
@@ -837,7 +898,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
837
898
  dependencies = [
838
899
  "proc-macro2",
839
900
  "quote",
840
- "syn 2.0.67",
901
+ "syn 2.0.68",
841
902
  ]
842
903
 
843
904
  [[package]]
@@ -897,7 +958,7 @@ dependencies = [
897
958
  "quote",
898
959
  "regex",
899
960
  "shell-words",
900
- "syn 2.0.67",
961
+ "syn 2.0.68",
901
962
  ]
902
963
 
903
964
  [[package]]
@@ -912,7 +973,7 @@ version = "0.5.2"
912
973
  source = "registry+https://github.com/rust-lang/crates.io-index"
913
974
  checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd"
914
975
  dependencies = [
915
- "bitflags 2.5.0",
976
+ "bitflags 2.6.0",
916
977
  ]
917
978
 
918
979
  [[package]]
@@ -1020,7 +1081,7 @@ version = "0.38.34"
1020
1081
  source = "registry+https://github.com/rust-lang/crates.io-index"
1021
1082
  checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
1022
1083
  dependencies = [
1023
- "bitflags 2.5.0",
1084
+ "bitflags 2.6.0",
1024
1085
  "errno",
1025
1086
  "libc",
1026
1087
  "linux-raw-sys",
@@ -1094,7 +1155,7 @@ version = "2.11.0"
1094
1155
  source = "registry+https://github.com/rust-lang/crates.io-index"
1095
1156
  checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0"
1096
1157
  dependencies = [
1097
- "bitflags 2.5.0",
1158
+ "bitflags 2.6.0",
1098
1159
  "core-foundation",
1099
1160
  "core-foundation-sys",
1100
1161
  "libc",
@@ -1134,14 +1195,14 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
1134
1195
  dependencies = [
1135
1196
  "proc-macro2",
1136
1197
  "quote",
1137
- "syn 2.0.67",
1198
+ "syn 2.0.68",
1138
1199
  ]
1139
1200
 
1140
1201
  [[package]]
1141
1202
  name = "serde_json"
1142
- version = "1.0.117"
1203
+ version = "1.0.118"
1143
1204
  source = "registry+https://github.com/rust-lang/crates.io-index"
1144
- checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
1205
+ checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4"
1145
1206
  dependencies = [
1146
1207
  "itoa",
1147
1208
  "ryu",
@@ -1225,9 +1286,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
1225
1286
 
1226
1287
  [[package]]
1227
1288
  name = "subtle"
1228
- version = "2.6.0"
1289
+ version = "2.6.1"
1229
1290
  source = "registry+https://github.com/rust-lang/crates.io-index"
1230
- checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5"
1291
+ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
1231
1292
 
1232
1293
  [[package]]
1233
1294
  name = "syn"
@@ -1242,9 +1303,9 @@ dependencies = [
1242
1303
 
1243
1304
  [[package]]
1244
1305
  name = "syn"
1245
- version = "2.0.67"
1306
+ version = "2.0.68"
1246
1307
  source = "registry+https://github.com/rust-lang/crates.io-index"
1247
- checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90"
1308
+ checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9"
1248
1309
  dependencies = [
1249
1310
  "proc-macro2",
1250
1311
  "quote",
@@ -1325,14 +1386,14 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
1325
1386
  dependencies = [
1326
1387
  "proc-macro2",
1327
1388
  "quote",
1328
- "syn 2.0.67",
1389
+ "syn 2.0.68",
1329
1390
  ]
1330
1391
 
1331
1392
  [[package]]
1332
1393
  name = "tinyvec"
1333
- version = "1.6.0"
1394
+ version = "1.6.1"
1334
1395
  source = "registry+https://github.com/rust-lang/crates.io-index"
1335
- checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
1396
+ checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82"
1336
1397
  dependencies = [
1337
1398
  "tinyvec_macros",
1338
1399
  ]
@@ -1370,7 +1431,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
1370
1431
  dependencies = [
1371
1432
  "proc-macro2",
1372
1433
  "quote",
1373
- "syn 2.0.67",
1434
+ "syn 2.0.68",
1374
1435
  ]
1375
1436
 
1376
1437
  [[package]]
@@ -1545,7 +1606,7 @@ dependencies = [
1545
1606
  "once_cell",
1546
1607
  "proc-macro2",
1547
1608
  "quote",
1548
- "syn 2.0.67",
1609
+ "syn 2.0.68",
1549
1610
  "wasm-bindgen-shared",
1550
1611
  ]
1551
1612
 
@@ -1579,7 +1640,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
1579
1640
  dependencies = [
1580
1641
  "proc-macro2",
1581
1642
  "quote",
1582
- "syn 2.0.67",
1643
+ "syn 2.0.68",
1583
1644
  "wasm-bindgen-backend",
1584
1645
  "wasm-bindgen-shared",
1585
1646
  ]
@@ -1600,6 +1661,15 @@ dependencies = [
1600
1661
  "wasm-bindgen",
1601
1662
  ]
1602
1663
 
1664
+ [[package]]
1665
+ name = "windows-core"
1666
+ version = "0.52.0"
1667
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1668
+ checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
1669
+ dependencies = [
1670
+ "windows-targets 0.52.5",
1671
+ ]
1672
+
1603
1673
  [[package]]
1604
1674
  name = "windows-sys"
1605
1675
  version = "0.48.0"
@@ -17,9 +17,8 @@ serde_json = "1.0.73"
17
17
  serde_derive = "1.0.130"
18
18
  reqwest = { version = "0.12.4", features = ["json"] }
19
19
  exitfailure = "0.5.1"
20
- base64 = "0.22.1"
21
20
  futures = "0.3.30"
22
21
  async-recursion = "1.1.1"
23
22
  thiserror = "1.0.61"
24
-
23
+ chrono = "0.4.38"
25
24
 
@@ -4,7 +4,6 @@ use crate::parser::parser::JsonToJson;
4
4
  use serde_magnus::deserialize;
5
5
  use magnus::{Value as RubyValue, RHash};
6
6
 
7
-
8
7
  fn hello(subject: String) -> String {
9
8
  format!("Hello from Rust, {subject}!")
10
9
  }
@@ -21,11 +20,10 @@ async fn parse(args: &[RubyValue]) -> Result<RubyValue, magnus::Error> {
21
20
  let origin = deserialize(origin).unwrap();
22
21
  let destination = deserialize(destination).unwrap();
23
22
  let mut parser = JsonToJson::new(origin, destination);
24
- if let Some(no_null) = no_null {
25
- parser.no_null = no_null;
26
- }
27
-
28
23
  parser.call().await;
24
+ if no_null.is_some() {
25
+ parser.destination.drop_nulls();
26
+ }
29
27
  Ok(parser.destination.to_ruby())
30
28
  }
31
29
 
@@ -1,18 +1,37 @@
1
1
  use crate::parser::utils::{application_option::ApplicationOption, helpers::{fetch, str_vec}};
2
- use magnus::Exception;
3
- use serde_json::{Map, Value};
2
+ use serde_json::{Map, Value, json};
4
3
  use std::collections::HashMap;
5
4
  use serde_json::Value::Null;
6
5
  use crate::parser::parser::JsonValue;
7
- use super::utils::application_option::parse_ashby_type;
8
- pub fn like_enum(args: &str, enm: &str) -> Value {
6
+ use super::utils::application_option::{parse_ashby_type, parse_lever_type};
7
+ use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
8
+
9
+ pub enum EnumValue {
10
+ Str(String),
11
+ Bool(bool),
12
+ }
13
+
14
+ pub fn like_enum(args: EnumValue, enm: &str) -> Value {
9
15
  let enm_list = str_vec(enm, ",");
10
16
  let mut enm_map: Map<String, Value> = serde_json::Map::new();
17
+
11
18
  for enm_a in enm_list {
12
19
  let enm_args = enm_a.split(':').collect::<Vec<&str>>();
13
20
  enm_map.insert(enm_args[0].to_string(), serde_json::Value::String(enm_args[1].to_string()));
14
21
  }
15
- return enm_map.get(args).unwrap().clone();
22
+
23
+ match args {
24
+ EnumValue::Str(str_value) => {
25
+ enm_map.get(&str_value).unwrap_or_else(|| enm_map.get("else").unwrap_or(&serde_json::Value::Null)).clone()
26
+ },
27
+ EnumValue::Bool(bool_value) => {
28
+ if bool_value {
29
+ enm_map.get("true").unwrap_or_else(|| enm_map.get("else").unwrap_or(&serde_json::Value::Null)).clone()
30
+ } else {
31
+ enm_map.get("false").unwrap_or_else(|| enm_map.get("else").unwrap_or(&serde_json::Value::Null)).clone()
32
+ }
33
+ },
34
+ }
16
35
  }
17
36
 
18
37
  pub async fn like_fetch(args: &str, ftch: &str) -> Value {
@@ -21,8 +40,15 @@ pub async fn like_fetch(args: &str, ftch: &str) -> Value {
21
40
  let mut input : HashMap<&str,&str> = HashMap::new();
22
41
  input.insert(ftch_list[4], new_args.as_str());
23
42
  let result = fetch(ftch_list[0], ftch_list[1], ftch_list[3], input).await;
24
- let result_value = JsonValue::new(result.unwrap());
25
- return result_value.get_by_path(ftch_list[5]).expect("Not found").clone();
43
+ let result = match result {
44
+ Ok(res) => JsonValue::new(res),
45
+ Err(_err) => JsonValue::null(),
46
+ };
47
+ let final_value = result
48
+ .get_by_path(ftch_list[5])
49
+ .map_or(serde_json::Value::Null, |v| v.clone());
50
+
51
+ final_value
26
52
  }
27
53
 
28
54
  pub fn like_lambda(_args: &str, _enm: &str) -> Value {
@@ -106,3 +132,99 @@ pub fn like_ashby(_args: &Value) -> Value {
106
132
 
107
133
  return serde_json::Value::Array(new_appl);
108
134
  }
135
+
136
+ pub fn like_lever(_args: &Value) -> Value {
137
+ let mut new_appl: Vec<serde_json::Value> = Vec::new();
138
+
139
+ if let Value::Object(map) = _args {
140
+ if let Some(Value::Array(arr)) = map.get("customQuestions") {
141
+ for value in arr {
142
+ if let Value::Object(map) = value {
143
+ if let Some(Value::Array(fields)) = map.get("fields") {
144
+ for field in fields {
145
+ process_field(field, &mut new_appl);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ if let Some(Value::Array(arr)) = map.get("personalInformation") {
153
+ for value in arr {
154
+ if let Value::Object(_) = value {
155
+ process_field(value, &mut new_appl);
156
+ }
157
+ }
158
+ }
159
+
160
+ if let Some(Value::Array(arr)) = map.get("urls") {
161
+ for value in arr {
162
+ if let Value::Object(_) = value {
163
+ process_field(value, &mut new_appl);
164
+ }
165
+ }
166
+ }
167
+
168
+ if let Some(Value::Object(map)) = map.get("eeoQuestions") {
169
+ for key in ["gender", "race", "veteran", "disability", "disabilitySignature", "disabilitySignatureDate"] {
170
+ if let Some(Value::Object(map)) = map.get(key) {
171
+ process_eeo(map, key, &mut new_appl);
172
+ }
173
+ }
174
+ }
175
+ }
176
+
177
+ serde_json::Value::Array(new_appl)
178
+ }
179
+
180
+ fn process_field(value: &Value, new_appl: &mut Vec<serde_json::Value>) {
181
+ let question = value.get("text").and_then(Value::as_str).unwrap_or("Unknown question");
182
+ let question_type = value.get("type").and_then(Value::as_str).unwrap_or("Unknown type");
183
+ let ext_id = value.get("id").or_else(|| value.get("name"))
184
+ .and_then(Value::as_str)
185
+ .map(|s| format!("lever__{}", s))
186
+ .unwrap_or("Unknown question".to_string());
187
+ let required = value.get("required").and_then(Value::as_bool).unwrap_or(false);
188
+ let answer_options = value.get("options").and_then(Value::as_array).map(|array| {
189
+ array.iter().filter_map(|item| item.get("text").and_then(Value::as_str)).map(|s| s.to_string()).collect()
190
+ });
191
+
192
+ let app_option = ApplicationOption::new(
193
+ question.to_string(),
194
+ parse_lever_type(question_type).unwrap(),
195
+ Some(ext_id),
196
+ answer_options,
197
+ required,
198
+ );
199
+
200
+ new_appl.push(app_option.to_json());
201
+ }
202
+
203
+ fn process_eeo(map: &serde_json::Map<String, Value>, key: &str, new_appl: &mut Vec<serde_json::Value>) {
204
+ let question = map.get("text").and_then(Value::as_str).unwrap_or("Unknown question");
205
+ let question_type = map.get("type").and_then(Value::as_str).unwrap_or("Unknown type");
206
+ let ext_id = format!("lever__{}", key);
207
+ let required = map.get("required").and_then(Value::as_bool).unwrap_or(false);
208
+ let answer_options = map.get("options").and_then(Value::as_array).map(|array| {
209
+ array.iter().filter_map(|item| item.get("text").and_then(Value::as_str)).map(|s| s.to_string()).collect()
210
+ });
211
+
212
+ let app_option = ApplicationOption::new(
213
+ question.to_string(),
214
+ parse_lever_type(question_type).unwrap(),
215
+ Some(ext_id),
216
+ answer_options,
217
+ required,
218
+ );
219
+
220
+ new_appl.push(app_option.to_json());
221
+ }
222
+
223
+ pub fn int_to_dt(timestamp: i64) -> Value {
224
+ // Convert the timestamp (which is in seconds since Unix epoch) to a NaiveDateTime
225
+ let datetime = DateTime::from_timestamp(timestamp, 0);
226
+ println!("Datetime {:?}", datetime);
227
+ json!("none".to_string())
228
+
229
+
230
+ }