Skip to content

Commit d49ae26

Browse files
committed
Add rate_applies_when policy example
As a bonus also includes an inclusive_maximum example.
1 parent 35d45ab commit d49ae26

2 files changed

Lines changed: 136 additions & 0 deletions

File tree

policy/examples/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,16 @@ This policy states parking fees as such:
456456
- Parking every hour onwards costs $10
457457

458458
For example, say a vehicle is parked for 6.5 hours. It will be charged `$2 (0-1hr) + $4 (1-2hr) + $10 (2-3hr) + $10 (3-4hr) + $10 (4-5hr) + $10 (5-6hr) + $10 (6-6.5hr) = $56`
459+
460+
This policy may be specified different ways using the `rate_applies_when` field.
461+
Both examples are shown here.
462+
463+
### With default `rate_applies_when = "out_of_bounds"`
464+
465+
By default the `rate_applies_when` field has the value `out_of_bounds`,
466+
meaning the rate should take effect when an event is outside the bounds
467+
of a rule's `minimum` and `maximum` values.
468+
459469
File: [`tiered-parking-fees-per-hour.json`](tiered-parking-fees-per-hour.json)
460470

461471
```json
@@ -510,6 +520,75 @@ File: [`tiered-parking-fees-per-hour.json`](tiered-parking-fees-per-hour.json)
510520
}
511521
```
512522

523+
### With `rate_applies_when = "in_bounds"`
524+
525+
When the `rate_applies_when` field has the value `in_bounds`,
526+
the rate takes effect when an event is within a rule's `minimum` and
527+
`maximum` values. Note that this also uses the `inclusive_minimum` and
528+
`inclusive_maximum` fields to create non-overlapping ranges for the rules.
529+
530+
File: [`tiered-parking-fees-per-hour-in-bounds.json`](tiered-parking-fees-per-hour-in-bounds.json)
531+
532+
```json
533+
{
534+
"name": "Tiered Dwell Time Example",
535+
"description": "First hour $2, second hour $4, every hour onwards $10",
536+
"policy_id": "2800cd0a-7827-4110-9713-b9e5bf29e9a1",
537+
"start_date": 1558389669540,
538+
"publish_date": 1558389669540,
539+
"end_date": null,
540+
"prev_policies": null,
541+
"provider_ids": [],
542+
"currency": "USD",
543+
"rules": [
544+
{
545+
"name": "0-1 Hour",
546+
"rule_id": "6b6fe61b-dbe5-4367-8e35-84fb14d23c54",
547+
"rule_type": "time",
548+
"rule_units": "hours",
549+
"geographies": ["0c77c813-bece-4e8a-84fd-f99af777d198"],
550+
"statuses": { "available": [], "non_operational": [] },
551+
"vehicle_types": ["bicycle", "scooter"],
552+
"maximum": 1,
553+
"inclusive_maximum": false,
554+
"rate_applies_when": "in_bounds",
555+
"rate_amount": 200,
556+
"rate_recurrence": "each_time_unit"
557+
},
558+
{
559+
"name": "1-2 Hours",
560+
"rule_id": "edd6a195-bb30-4eb5-a2cc-44e5a18798a2",
561+
"rule_type": "time",
562+
"rule_units": "hours",
563+
"geographies": ["0c77c813-bece-4e8a-84fd-f99af777d198"],
564+
"statuses": { "available": [], "non_operational": [] },
565+
"vehicle_types": ["bicycle", "scooter"],
566+
"minimum": 1,
567+
"maximum": 2,
568+
"inclusive_minimum": true,
569+
"inclusive_maximum": false,
570+
"rate_applies_when": "in_bounds",
571+
"rate_amount": 400,
572+
"rate_recurrence": "each_time_unit"
573+
},
574+
{
575+
"name": "> 2 hours",
576+
"rule_id": "9cd1768c-ab9e-484c-93f8-72a7078aa7b9",
577+
"rule_type": "time",
578+
"rule_units": "hours",
579+
"geographies": ["0c77c813-bece-4e8a-84fd-f99af777d198"],
580+
"statuses": { "available": [], "non_operational": [] },
581+
"vehicle_types": ["bicycle", "scooter"],
582+
"minimum": 2,
583+
"inclusive_minimum": true,
584+
"rate_applies_when": "in_bounds",
585+
"rate_amount": 1000,
586+
"rate_recurrence": "each_time_unit"
587+
}
588+
]
589+
}
590+
```
591+
513592
## Tiered Parking Fees Total
514593
This policy states parking fees as such:
515594
- If parked for less than an hour, $2 on exit
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "Tiered Dwell Time Example",
3+
"description": "First hour $2, second hour $4, every hour onwards $10",
4+
"policy_id": "2800cd0a-7827-4110-9713-b9e5bf29e9a1",
5+
"start_date": 1558389669540,
6+
"publish_date": 1558389669540,
7+
"end_date": null,
8+
"prev_policies": null,
9+
"provider_ids": [],
10+
"currency": "USD",
11+
"rules": [
12+
{
13+
"name": "0-1 Hour",
14+
"rule_id": "6b6fe61b-dbe5-4367-8e35-84fb14d23c54",
15+
"rule_type": "time",
16+
"rule_units": "hours",
17+
"geographies": ["0c77c813-bece-4e8a-84fd-f99af777d198"],
18+
"statuses": { "available": [], "non_operational": [] },
19+
"vehicle_types": ["bicycle", "scooter"],
20+
"maximum": 1,
21+
"inclusive_maximum": false,
22+
"rate_applies_when": "in_bounds",
23+
"rate_amount": 200,
24+
"rate_recurrence": "each_time_unit"
25+
},
26+
{
27+
"name": "1-2 Hours",
28+
"rule_id": "edd6a195-bb30-4eb5-a2cc-44e5a18798a2",
29+
"rule_type": "time",
30+
"rule_units": "hours",
31+
"geographies": ["0c77c813-bece-4e8a-84fd-f99af777d198"],
32+
"statuses": { "available": [], "non_operational": [] },
33+
"vehicle_types": ["bicycle", "scooter"],
34+
"minimum": 1,
35+
"maximum": 2,
36+
"inclusive_minimum": true,
37+
"inclusive_maximum": false,
38+
"rate_applies_when": "in_bounds",
39+
"rate_amount": 400,
40+
"rate_recurrence": "each_time_unit"
41+
},
42+
{
43+
"name": "> 2 hours",
44+
"rule_id": "9cd1768c-ab9e-484c-93f8-72a7078aa7b9",
45+
"rule_type": "time",
46+
"rule_units": "hours",
47+
"geographies": ["0c77c813-bece-4e8a-84fd-f99af777d198"],
48+
"statuses": { "available": [], "non_operational": [] },
49+
"vehicle_types": ["bicycle", "scooter"],
50+
"minimum": 2,
51+
"inclusive_minimum": true,
52+
"rate_applies_when": "in_bounds",
53+
"rate_amount": 1000,
54+
"rate_recurrence": "each_time_unit"
55+
}
56+
]
57+
}

0 commit comments

Comments
 (0)