lcp-sdk 1.0.1 → 1.0.2
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 +4 -4
- data/lib/schema-bundle.json +86 -54
- data/lib/schema_validator.rb +42 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62c022daa49deaca29686086da6cb24e3b8f8cba2fd65fc5fd8443f306d0ce66
|
|
4
|
+
data.tar.gz: ef2ff43e0a408396682c561924f25aaa53d4bfba7b6dedef3a564bdb133d188f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 277d5be9e17a4e2ef371958c59e054eb99f3da93b016c498c6645fc1509cf2cc3fd5ce32352bde969e55fde44d8852144efc1fd8cfbe9c63cec54d984a7f711f
|
|
7
|
+
data.tar.gz: 1d7b8d764af3c8adbbbf8ff2ab6236450553b3b5313ede6375798c8d87ed2fc60fa821b656dfa113ae0164f750ec6511e0d47caf56a1b844ce5b2fc02f1fa2a8
|
data/lib/schema-bundle.json
CHANGED
|
@@ -53,6 +53,26 @@
|
|
|
53
53
|
"$id": "https://lcp.dev/schemas/bid.json",
|
|
54
54
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
55
55
|
"additionalProperties": false,
|
|
56
|
+
"allOf": [
|
|
57
|
+
{
|
|
58
|
+
"if": {
|
|
59
|
+
"properties": {
|
|
60
|
+
"decision": {
|
|
61
|
+
"const": "accept"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": [
|
|
65
|
+
"decision"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"then": {
|
|
69
|
+
"required": [
|
|
70
|
+
"bid_price_cents",
|
|
71
|
+
"currency"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
],
|
|
56
76
|
"description": "Buyer's response to a ping. Contains the bid price, accept/reject decision, and estimated contact speed. The platform collects bids from all pinged buyers and selects the winner. Created by Spear Systems (a Spear company). Open standard \u2014 Apache 2.0, free to implement.",
|
|
57
77
|
"properties": {
|
|
58
78
|
"bid_price_cents": {
|
|
@@ -97,9 +117,7 @@
|
|
|
97
117
|
},
|
|
98
118
|
"required": [
|
|
99
119
|
"ping_id",
|
|
100
|
-
"decision"
|
|
101
|
-
"bid_price_cents",
|
|
102
|
-
"currency"
|
|
120
|
+
"decision"
|
|
103
121
|
],
|
|
104
122
|
"title": "LCP Bid Message",
|
|
105
123
|
"type": "object"
|
|
@@ -2231,14 +2249,14 @@
|
|
|
2231
2249
|
"description": "Insurance lead attributes. Every field is tagged ping_safe: true|false \u2014 the conformance runner rejects any ping containing a non-ping_safe field. Created by Spear Systems (a Spear company). Open standard \u2014 Apache 2.0, free to implement.",
|
|
2232
2250
|
"properties": {
|
|
2233
2251
|
"claim_count_band": {
|
|
2234
|
-
"description": "Banded number of claims filed.",
|
|
2252
|
+
"description": "Banded number of claims filed. Sensitive underwriting data; post-only.",
|
|
2235
2253
|
"enum": [
|
|
2236
2254
|
"none",
|
|
2237
2255
|
"one",
|
|
2238
2256
|
"two",
|
|
2239
2257
|
"three_or_more"
|
|
2240
2258
|
],
|
|
2241
|
-
"ping_safe":
|
|
2259
|
+
"ping_safe": false,
|
|
2242
2260
|
"type": "string"
|
|
2243
2261
|
},
|
|
2244
2262
|
"coverage_amount_band": {
|
|
@@ -2307,23 +2325,23 @@
|
|
|
2307
2325
|
"type": "string"
|
|
2308
2326
|
},
|
|
2309
2327
|
"gender": {
|
|
2310
|
-
"description": "Gender \u2014
|
|
2328
|
+
"description": "Gender \u2014 sensitive underwriting data; post-only.",
|
|
2311
2329
|
"enum": [
|
|
2312
2330
|
"male",
|
|
2313
2331
|
"female",
|
|
2314
2332
|
"non_binary",
|
|
2315
2333
|
"prefer_not_to_say"
|
|
2316
2334
|
],
|
|
2317
|
-
"ping_safe":
|
|
2335
|
+
"ping_safe": false,
|
|
2318
2336
|
"type": "string"
|
|
2319
2337
|
},
|
|
2320
2338
|
"has_claims_history": {
|
|
2321
|
-
"description": "Has the consumer filed any claims?",
|
|
2322
|
-
"ping_safe":
|
|
2339
|
+
"description": "Has the consumer filed any claims? Sensitive underwriting data; post-only.",
|
|
2340
|
+
"ping_safe": false,
|
|
2323
2341
|
"type": "boolean"
|
|
2324
2342
|
},
|
|
2325
2343
|
"health_condition_band": {
|
|
2326
|
-
"description": "Self-reported health condition band for health insurance.",
|
|
2344
|
+
"description": "Self-reported health condition band for health insurance; sensitive health data, post-only.",
|
|
2327
2345
|
"enum": [
|
|
2328
2346
|
"excellent",
|
|
2329
2347
|
"good",
|
|
@@ -2331,11 +2349,11 @@
|
|
|
2331
2349
|
"poor",
|
|
2332
2350
|
"unknown"
|
|
2333
2351
|
],
|
|
2334
|
-
"ping_safe":
|
|
2352
|
+
"ping_safe": false,
|
|
2335
2353
|
"type": "string"
|
|
2336
2354
|
},
|
|
2337
2355
|
"height_band": {
|
|
2338
|
-
"description": "Banded height for health/life insurance underwriting.",
|
|
2356
|
+
"description": "Banded height for health/life insurance underwriting; sensitive health data, post-only.",
|
|
2339
2357
|
"enum": [
|
|
2340
2358
|
"under_5ft",
|
|
2341
2359
|
"5_5ft5",
|
|
@@ -2343,7 +2361,7 @@
|
|
|
2343
2361
|
"5ft9_6ft",
|
|
2344
2362
|
"over_6ft"
|
|
2345
2363
|
],
|
|
2346
|
-
"ping_safe":
|
|
2364
|
+
"ping_safe": false,
|
|
2347
2365
|
"type": "string"
|
|
2348
2366
|
},
|
|
2349
2367
|
"insurance_type": {
|
|
@@ -2366,11 +2384,11 @@
|
|
|
2366
2384
|
"separated",
|
|
2367
2385
|
"domestic_partnership"
|
|
2368
2386
|
],
|
|
2369
|
-
"ping_safe":
|
|
2387
|
+
"ping_safe": false,
|
|
2370
2388
|
"type": "string"
|
|
2371
2389
|
},
|
|
2372
2390
|
"occupation_class": {
|
|
2373
|
-
"description": "Occupation risk class for life/disability insurance underwriting.",
|
|
2391
|
+
"description": "Occupation risk class for life/disability insurance underwriting; sensitive employment data, post-only.",
|
|
2374
2392
|
"enum": [
|
|
2375
2393
|
"professional",
|
|
2376
2394
|
"clerical",
|
|
@@ -2380,7 +2398,7 @@
|
|
|
2380
2398
|
"self_employed",
|
|
2381
2399
|
"other"
|
|
2382
2400
|
],
|
|
2383
|
-
"ping_safe":
|
|
2401
|
+
"ping_safe": false,
|
|
2384
2402
|
"type": "string"
|
|
2385
2403
|
},
|
|
2386
2404
|
"property_type": {
|
|
@@ -2402,8 +2420,8 @@
|
|
|
2402
2420
|
"type": "string"
|
|
2403
2421
|
},
|
|
2404
2422
|
"smoker": {
|
|
2405
|
-
"description": "Smoking status for health/life insurance underwriting.",
|
|
2406
|
-
"ping_safe":
|
|
2423
|
+
"description": "Smoking status for health/life insurance underwriting; sensitive health data, post-only.",
|
|
2424
|
+
"ping_safe": false,
|
|
2407
2425
|
"type": "boolean"
|
|
2408
2426
|
},
|
|
2409
2427
|
"vehicle_type": {
|
|
@@ -2427,7 +2445,7 @@
|
|
|
2427
2445
|
"type": "string"
|
|
2428
2446
|
},
|
|
2429
2447
|
"weight_band": {
|
|
2430
|
-
"description": "Banded weight (lbs) for health/life insurance underwriting.",
|
|
2448
|
+
"description": "Banded weight (lbs) for health/life insurance underwriting; sensitive health data, post-only.",
|
|
2431
2449
|
"enum": [
|
|
2432
2450
|
"under_120",
|
|
2433
2451
|
"120_150",
|
|
@@ -2436,7 +2454,7 @@
|
|
|
2436
2454
|
"210_250",
|
|
2437
2455
|
"over_250"
|
|
2438
2456
|
],
|
|
2439
|
-
"ping_safe":
|
|
2457
|
+
"ping_safe": false,
|
|
2440
2458
|
"type": "string"
|
|
2441
2459
|
},
|
|
2442
2460
|
"years_with_current_insurer_band": {
|
|
@@ -2466,8 +2484,8 @@
|
|
|
2466
2484
|
"description": "Legal lead attributes. Every field is tagged ping_safe: true|false \u2014 the conformance runner rejects any ping containing a non-ping_safe field. Created by Spear Systems (a Spear company). Open standard \u2014 Apache 2.0, free to implement.",
|
|
2467
2485
|
"properties": {
|
|
2468
2486
|
"at_fault": {
|
|
2469
|
-
"description": "Was the consumer at fault?
|
|
2470
|
-
"ping_safe":
|
|
2487
|
+
"description": "Was the consumer at fault? Sensitive legal liability data; post-only.",
|
|
2488
|
+
"ping_safe": false,
|
|
2471
2489
|
"type": "boolean"
|
|
2472
2490
|
},
|
|
2473
2491
|
"case_type": {
|
|
@@ -2485,7 +2503,7 @@
|
|
|
2485
2503
|
"type": "string"
|
|
2486
2504
|
},
|
|
2487
2505
|
"claim_status": {
|
|
2488
|
-
"description": "Current status of the claim.",
|
|
2506
|
+
"description": "Current status of the claim; sensitive legal data, post-only.",
|
|
2489
2507
|
"enum": [
|
|
2490
2508
|
"not_filed",
|
|
2491
2509
|
"filed",
|
|
@@ -2494,12 +2512,12 @@
|
|
|
2494
2512
|
"settled",
|
|
2495
2513
|
"in_litigation"
|
|
2496
2514
|
],
|
|
2497
|
-
"ping_safe":
|
|
2515
|
+
"ping_safe": false,
|
|
2498
2516
|
"type": "string"
|
|
2499
2517
|
},
|
|
2500
2518
|
"has_attorney": {
|
|
2501
|
-
"description": "Does the consumer already have an attorney?",
|
|
2502
|
-
"ping_safe":
|
|
2519
|
+
"description": "Does the consumer already have an attorney? Legal-representation data; post-only.",
|
|
2520
|
+
"ping_safe": false,
|
|
2503
2521
|
"type": "boolean"
|
|
2504
2522
|
},
|
|
2505
2523
|
"incident_date": {
|
|
@@ -2514,7 +2532,7 @@
|
|
|
2514
2532
|
"type": "string"
|
|
2515
2533
|
},
|
|
2516
2534
|
"injury_severity": {
|
|
2517
|
-
"description": "Severity of injury sustained.",
|
|
2535
|
+
"description": "Severity of injury sustained; sensitive health/legal data, post-only.",
|
|
2518
2536
|
"enum": [
|
|
2519
2537
|
"none",
|
|
2520
2538
|
"minor",
|
|
@@ -2523,7 +2541,7 @@
|
|
|
2523
2541
|
"catastrophic",
|
|
2524
2542
|
"fatal"
|
|
2525
2543
|
],
|
|
2526
|
-
"ping_safe":
|
|
2544
|
+
"ping_safe": false,
|
|
2527
2545
|
"type": "string"
|
|
2528
2546
|
},
|
|
2529
2547
|
"insurance_company": {
|
|
@@ -2532,13 +2550,13 @@
|
|
|
2532
2550
|
"type": "string"
|
|
2533
2551
|
},
|
|
2534
2552
|
"medical_treatment_received": {
|
|
2535
|
-
"description": "Has medical treatment been received?",
|
|
2536
|
-
"ping_safe":
|
|
2553
|
+
"description": "Has medical treatment been received? Sensitive health/legal data; post-only.",
|
|
2554
|
+
"ping_safe": false,
|
|
2537
2555
|
"type": "boolean"
|
|
2538
2556
|
},
|
|
2539
2557
|
"police_report_filed": {
|
|
2540
|
-
"description": "Was a police report filed?",
|
|
2541
|
-
"ping_safe":
|
|
2558
|
+
"description": "Was a police report filed? Sensitive incident data; post-only.",
|
|
2559
|
+
"ping_safe": false,
|
|
2542
2560
|
"type": "boolean"
|
|
2543
2561
|
},
|
|
2544
2562
|
"schema_version": {
|
|
@@ -2546,10 +2564,10 @@
|
|
|
2546
2564
|
"type": "string"
|
|
2547
2565
|
},
|
|
2548
2566
|
"time_to_contact_deadline_days": {
|
|
2549
|
-
"description": "Days remaining to contact before statute of limitations or deadline.",
|
|
2567
|
+
"description": "Days remaining to contact before statute of limitations or deadline; sensitive legal timing, post-only.",
|
|
2550
2568
|
"maximum": 3650,
|
|
2551
2569
|
"minimum": 0,
|
|
2552
|
-
"ping_safe":
|
|
2570
|
+
"ping_safe": false,
|
|
2553
2571
|
"type": "integer"
|
|
2554
2572
|
},
|
|
2555
2573
|
"vertical": {
|
|
@@ -2589,8 +2607,8 @@
|
|
|
2589
2607
|
"type": "integer"
|
|
2590
2608
|
},
|
|
2591
2609
|
"bankruptcy_history": {
|
|
2592
|
-
"description": "Has the consumer filed for bankruptcy?
|
|
2593
|
-
"ping_safe":
|
|
2610
|
+
"description": "Has the consumer filed for bankruptcy? Sensitive financial data; post-only.",
|
|
2611
|
+
"ping_safe": false,
|
|
2594
2612
|
"type": "boolean"
|
|
2595
2613
|
},
|
|
2596
2614
|
"cash_out_amount_band": {
|
|
@@ -2611,6 +2629,7 @@
|
|
|
2611
2629
|
"type": "integer"
|
|
2612
2630
|
},
|
|
2613
2631
|
"credit_rating_band": {
|
|
2632
|
+
"description": "Credit classification is sensitive financial data; post-only.",
|
|
2614
2633
|
"enum": [
|
|
2615
2634
|
"excellent",
|
|
2616
2635
|
"good",
|
|
@@ -2618,7 +2637,7 @@
|
|
|
2618
2637
|
"poor",
|
|
2619
2638
|
"unknown"
|
|
2620
2639
|
],
|
|
2621
|
-
"ping_safe":
|
|
2640
|
+
"ping_safe": false,
|
|
2622
2641
|
"type": "string"
|
|
2623
2642
|
},
|
|
2624
2643
|
"current_lender": {
|
|
@@ -2660,8 +2679,8 @@
|
|
|
2660
2679
|
"type": "number"
|
|
2661
2680
|
},
|
|
2662
2681
|
"foreclosure_history": {
|
|
2663
|
-
"description": "Has the consumer had a foreclosure?
|
|
2664
|
-
"ping_safe":
|
|
2682
|
+
"description": "Has the consumer had a foreclosure? Sensitive financial data; post-only.",
|
|
2683
|
+
"ping_safe": false,
|
|
2665
2684
|
"type": "boolean"
|
|
2666
2685
|
},
|
|
2667
2686
|
"has_existing_mortgage": {
|
|
@@ -2861,8 +2880,8 @@
|
|
|
2861
2880
|
"type": "string"
|
|
2862
2881
|
},
|
|
2863
2882
|
"self_employed_income_verified": {
|
|
2864
|
-
"description": "For self-employed leads, whether income has been verified
|
|
2865
|
-
"ping_safe":
|
|
2883
|
+
"description": "For self-employed leads, whether income has been verified; sensitive financial data, post-only.",
|
|
2884
|
+
"ping_safe": false,
|
|
2866
2885
|
"type": "boolean"
|
|
2867
2886
|
},
|
|
2868
2887
|
"vertical": {
|
|
@@ -2870,13 +2889,14 @@
|
|
|
2870
2889
|
"type": "string"
|
|
2871
2890
|
},
|
|
2872
2891
|
"veteran_status": {
|
|
2892
|
+
"description": "Veteran or military status is sensitive eligibility data; post-only.",
|
|
2873
2893
|
"enum": [
|
|
2874
2894
|
"veteran",
|
|
2875
2895
|
"active_duty",
|
|
2876
2896
|
"reservist",
|
|
2877
2897
|
"non_veteran"
|
|
2878
2898
|
],
|
|
2879
|
-
"ping_safe":
|
|
2899
|
+
"ping_safe": false,
|
|
2880
2900
|
"type": "string"
|
|
2881
2901
|
}
|
|
2882
2902
|
},
|
|
@@ -2932,7 +2952,8 @@
|
|
|
2932
2952
|
"type": "string"
|
|
2933
2953
|
},
|
|
2934
2954
|
"claim_filed": {
|
|
2935
|
-
"
|
|
2955
|
+
"description": "Claim status is sensitive legal/insurance data; post-only.",
|
|
2956
|
+
"ping_safe": false,
|
|
2936
2957
|
"type": "boolean"
|
|
2937
2958
|
},
|
|
2938
2959
|
"claim_stage": {
|
|
@@ -2952,16 +2973,18 @@
|
|
|
2952
2973
|
"type": "boolean"
|
|
2953
2974
|
},
|
|
2954
2975
|
"consumer_insured": {
|
|
2976
|
+
"description": "Consumer insurance status is sensitive insurance data; post-only.",
|
|
2955
2977
|
"enum": [
|
|
2956
2978
|
"yes",
|
|
2957
2979
|
"no",
|
|
2958
2980
|
"unknown"
|
|
2959
2981
|
],
|
|
2960
|
-
"ping_safe":
|
|
2982
|
+
"ping_safe": false,
|
|
2961
2983
|
"type": "string"
|
|
2962
2984
|
},
|
|
2963
2985
|
"emergency_services_called": {
|
|
2964
|
-
"
|
|
2986
|
+
"description": "Emergency-response information is sensitive incident data; post-only.",
|
|
2987
|
+
"ping_safe": false,
|
|
2965
2988
|
"type": "boolean"
|
|
2966
2989
|
},
|
|
2967
2990
|
"evidence_available": {
|
|
@@ -2983,6 +3006,7 @@
|
|
|
2983
3006
|
"uniqueItems": true
|
|
2984
3007
|
},
|
|
2985
3008
|
"fault_position": {
|
|
3009
|
+
"description": "Fault position is sensitive legal/liability data; post-only.",
|
|
2986
3010
|
"enum": [
|
|
2987
3011
|
"not_at_fault",
|
|
2988
3012
|
"partially_at_fault",
|
|
@@ -2990,14 +3014,16 @@
|
|
|
2990
3014
|
"unclear",
|
|
2991
3015
|
"unknown"
|
|
2992
3016
|
],
|
|
2993
|
-
"ping_safe":
|
|
3017
|
+
"ping_safe": false,
|
|
2994
3018
|
"type": "string"
|
|
2995
3019
|
},
|
|
2996
3020
|
"injury_present": {
|
|
2997
|
-
"
|
|
3021
|
+
"description": "Injury indicator is sensitive health/legal data; post-only.",
|
|
3022
|
+
"ping_safe": false,
|
|
2998
3023
|
"type": "boolean"
|
|
2999
3024
|
},
|
|
3000
3025
|
"injury_severity_band": {
|
|
3026
|
+
"description": "Injury severity is sensitive health/legal data; post-only.",
|
|
3001
3027
|
"enum": [
|
|
3002
3028
|
"none",
|
|
3003
3029
|
"minor",
|
|
@@ -3006,7 +3032,7 @@
|
|
|
3006
3032
|
"fatality",
|
|
3007
3033
|
"unknown"
|
|
3008
3034
|
],
|
|
3009
|
-
"ping_safe":
|
|
3035
|
+
"ping_safe": false,
|
|
3010
3036
|
"type": "string"
|
|
3011
3037
|
},
|
|
3012
3038
|
"jurisdiction": {
|
|
@@ -3015,6 +3041,7 @@
|
|
|
3015
3041
|
"type": "string"
|
|
3016
3042
|
},
|
|
3017
3043
|
"medical_treatment": {
|
|
3044
|
+
"description": "Medical treatment is sensitive health data; post-only.",
|
|
3018
3045
|
"enum": [
|
|
3019
3046
|
"none",
|
|
3020
3047
|
"self_treated",
|
|
@@ -3023,20 +3050,22 @@
|
|
|
3023
3050
|
"ongoing",
|
|
3024
3051
|
"unknown"
|
|
3025
3052
|
],
|
|
3026
|
-
"ping_safe":
|
|
3053
|
+
"ping_safe": false,
|
|
3027
3054
|
"type": "string"
|
|
3028
3055
|
},
|
|
3029
3056
|
"other_driver_identified": {
|
|
3030
|
-
"
|
|
3057
|
+
"description": "Other-party identification status is sensitive incident data; post-only.",
|
|
3058
|
+
"ping_safe": false,
|
|
3031
3059
|
"type": "boolean"
|
|
3032
3060
|
},
|
|
3033
3061
|
"other_driver_insured": {
|
|
3062
|
+
"description": "Other-party insurance status is sensitive insurance data; post-only.",
|
|
3034
3063
|
"enum": [
|
|
3035
3064
|
"yes",
|
|
3036
3065
|
"no",
|
|
3037
3066
|
"unknown"
|
|
3038
3067
|
],
|
|
3039
|
-
"ping_safe":
|
|
3068
|
+
"ping_safe": false,
|
|
3040
3069
|
"type": "string"
|
|
3041
3070
|
},
|
|
3042
3071
|
"passenger_count_band": {
|
|
@@ -3051,15 +3080,18 @@
|
|
|
3051
3080
|
"type": "string"
|
|
3052
3081
|
},
|
|
3053
3082
|
"police_report_available": {
|
|
3054
|
-
"
|
|
3083
|
+
"description": "Police-report availability is sensitive incident data; post-only.",
|
|
3084
|
+
"ping_safe": false,
|
|
3055
3085
|
"type": "boolean"
|
|
3056
3086
|
},
|
|
3057
3087
|
"prior_attorney_consultation": {
|
|
3058
|
-
"
|
|
3088
|
+
"description": "Prior legal consultation is sensitive legal data; post-only.",
|
|
3089
|
+
"ping_safe": false,
|
|
3059
3090
|
"type": "boolean"
|
|
3060
3091
|
},
|
|
3061
3092
|
"represented_by_attorney": {
|
|
3062
|
-
"
|
|
3093
|
+
"description": "Attorney-representation status is sensitive legal data; post-only.",
|
|
3094
|
+
"ping_safe": false,
|
|
3063
3095
|
"type": "boolean"
|
|
3064
3096
|
},
|
|
3065
3097
|
"schema_version": {
|
data/lib/schema_validator.rb
CHANGED
|
@@ -30,6 +30,13 @@ module LcpSdk
|
|
|
30
30
|
name = path.delete_prefix("#{root}/")
|
|
31
31
|
documents[name] = JSON.parse(File.read(path))
|
|
32
32
|
end
|
|
33
|
+
if File.basename(root.to_s) == "schemas"
|
|
34
|
+
vertical_root = File.join(File.dirname(root), "verticals")
|
|
35
|
+
Dir.glob(File.join(vertical_root, "**", "*.json")).each do |path|
|
|
36
|
+
name = path.delete_prefix("#{vertical_root}/")
|
|
37
|
+
documents["verticals/#{name}"] = JSON.parse(File.read(path))
|
|
38
|
+
end
|
|
39
|
+
end
|
|
33
40
|
new(documents)
|
|
34
41
|
end
|
|
35
42
|
|
|
@@ -50,7 +57,41 @@ module LcpSdk
|
|
|
50
57
|
validate("schemas/envelope.json", envelope)
|
|
51
58
|
type = envelope.dig("lcp", "message", "type")
|
|
52
59
|
raise SchemaValidationError, "missing lcp.message.type" unless type.is_a?(String)
|
|
53
|
-
|
|
60
|
+
payload = envelope.dig("lcp", "payload")
|
|
61
|
+
validate("schemas/#{type}.json", payload)
|
|
62
|
+
validate_vertical_policy(type, payload)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def validate_vertical_policy(type, payload)
|
|
66
|
+
return unless %w[lead call post ping].include?(type) && payload.is_a?(Hash)
|
|
67
|
+
attributes = payload["attributes"]
|
|
68
|
+
return unless attributes.is_a?(Hash)
|
|
69
|
+
vertical = type == "ping" ? payload["vertical"] : attributes["vertical"]
|
|
70
|
+
return unless vertical.is_a?(String) && !vertical.empty?
|
|
71
|
+
schema = @documents[normalize("verticals/#{vertical}.json")] ||
|
|
72
|
+
@documents["verticals/#{vertical}.json"] ||
|
|
73
|
+
@documents["#{vertical}.json"]
|
|
74
|
+
raise SchemaValidationError, "Vertical schema '#{vertical}' not found" unless schema.is_a?(Hash)
|
|
75
|
+
vertical_attributes = JSON.parse(JSON.generate(attributes))
|
|
76
|
+
if type == "ping"
|
|
77
|
+
vertical_attributes["vertical"] ||= vertical
|
|
78
|
+
vertical_attributes["schema_version"] ||= schema.dig("properties", "schema_version", "const") || "1.0.0"
|
|
79
|
+
end
|
|
80
|
+
validate_vertical(vertical, vertical_attributes)
|
|
81
|
+
validate_ping_safe(vertical, attributes, schema, "attributes") if type == "ping"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def validate_ping_safe(vertical, value, schema, path)
|
|
85
|
+
return unless value.is_a?(Hash)
|
|
86
|
+
properties = schema.fetch("properties", {})
|
|
87
|
+
value.each do |name, child|
|
|
88
|
+
next if path == "attributes" && %w[vertical schema_version].include?(name)
|
|
89
|
+
definition = properties[name]
|
|
90
|
+
unless definition.is_a?(Hash) && definition["ping_safe"] == true
|
|
91
|
+
raise SchemaValidationError, "#{path}.#{name} is not tagged ping_safe: true in vertical '#{vertical}'"
|
|
92
|
+
end
|
|
93
|
+
validate_ping_safe(vertical, child, definition, "#{path}.#{name}") if child.is_a?(Hash) && definition["properties"].is_a?(Hash)
|
|
94
|
+
end
|
|
54
95
|
end
|
|
55
96
|
|
|
56
97
|
def validate_offer(offer)
|