parking_ticket 1.0.44 → 1.0.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +0 -72
- data/lib/clients/pay_by_phone/adapter.rb +11 -2
- data/lib/parking_ticket/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de1dded37503f11b5a809b56ca98dec69781e02cf6cd73d1641e9965de3ae257
|
4
|
+
data.tar.gz: 1f6387e3eb9da51dedeb572dfa2671ecf7fc1406fc9d5df1b030c514ee9480a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e198ce49533ab058756a127c17cd3a55e51e9a752689b035453025f214fa774171994db7447979652c244da2722bf9200a5b7fd365936048cd0b446e154c6cf1
|
7
|
+
data.tar.gz: 4e4284028b493807cefcb0c6efbd6d12ec34eb901d5ad085660178899e6b13cae736351cb37bcf022659d9b19bdc0d4a5447f950fff35406e27004ab60d4389f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -19,78 +19,6 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
$ gem install parking_ticket
|
21
21
|
|
22
|
-
## Usage
|
23
|
-
|
24
|
-
To make the gem work above your parking account you need set some environment variables :
|
25
|
-
|
26
|
-
This give you access to a bunch of classes but the most important one is the ParkingTicket::Base.
|
27
|
-
|
28
|
-
This class can be instanciated as follow :
|
29
|
-
|
30
|
-
```
|
31
|
-
parking_ticket = ParkingTicket::Base.new(
|
32
|
-
'pay_by_phone',
|
33
|
-
{
|
34
|
-
username: your_pay_by_phone_username,
|
35
|
-
password: your_pay_by_phone_password,
|
36
|
-
license_plate: your_license_plate,
|
37
|
-
zipcode: the_zipcode_where_you_are_resident,
|
38
|
-
card_number: the_card_number_registered_on_pay_by_phone_you_want_to_use, # must be in the format : xxxxxx------xxxx
|
39
|
-
}
|
40
|
-
)
|
41
|
-
```
|
42
|
-
|
43
|
-
Once instanciated and configured correctly (the methods won't work if the is a missing key in the confguration hash), you can use the two instance methods to do what you have to do :
|
44
|
-
|
45
|
-
- #current_ticket
|
46
|
-
This checks if a ticket is currently running for the license_plate.
|
47
|
-
Returns :
|
48
|
-
```
|
49
|
-
#if a ticket is found :
|
50
|
-
{
|
51
|
-
starts_on: 2023-01-11 15:40:22 UTC,
|
52
|
-
ends_on: 2023-01-18 15:40:22 UTC,
|
53
|
-
cost: 9.0,
|
54
|
-
license_plate: your_license_plate,
|
55
|
-
client: "PayByPhone",
|
56
|
-
client_ticket_id: the_id_returned_by_the_adapter,
|
57
|
-
}
|
58
|
-
|
59
|
-
#if no ticket is found
|
60
|
-
nil
|
61
|
-
```
|
62
|
-
|
63
|
-
- #renew
|
64
|
-
This will trigger the renewal of your ticket, works only if no current_ticket is found
|
65
|
-
|
66
|
-
Then you can create a scrypt like this one :
|
67
|
-
|
68
|
-
```
|
69
|
-
#your_scrypt.rb
|
70
|
-
require 'parking_ticket'
|
71
|
-
|
72
|
-
ticket_client = ParkingTicket::Base.new(
|
73
|
-
'pay_by_phone',
|
74
|
-
{
|
75
|
-
username: your_pay_by_phone_username,
|
76
|
-
password: your_pay_by_phone_password,
|
77
|
-
license_plate: your_license_plate,
|
78
|
-
zipcode: the_zipcode_where_you_are_resident,
|
79
|
-
card_number: the_card_number_registered_on_pay_by_phone_you_want_to_use, # must be in the format : xxxxxx------xxxx
|
80
|
-
}
|
81
|
-
)
|
82
|
-
|
83
|
-
unless ticket_client.current_ticket
|
84
|
-
ticket_client.renew
|
85
|
-
end
|
86
|
-
|
87
|
-
```
|
88
|
-
|
89
|
-
And play it as often as you want to ensure that you always have a ticket for your car.
|
90
|
-
(But this is very HTTP request consuming, a lot of wasted request will be performed, i am sure that you can do better than that.)
|
91
|
-
|
92
|
-
Exemple of application : [parkautomat](https://github.com/troptropcontent/parkautomat)
|
93
|
-
|
94
22
|
|
95
23
|
## License
|
96
24
|
|
@@ -13,6 +13,11 @@ module ParkingTicket
|
|
13
13
|
'Visa' => 'visa'
|
14
14
|
}.freeze
|
15
15
|
|
16
|
+
VEHICLE_TYPE_MAPPER = {
|
17
|
+
'Car' => 'combustion_car',
|
18
|
+
'ElectricMotorcycle' => 'electric_motorcycle'
|
19
|
+
}.freeze
|
20
|
+
|
16
21
|
private
|
17
22
|
|
18
23
|
def fetch_and_map_vehicles
|
@@ -20,7 +25,8 @@ module ParkingTicket
|
|
20
25
|
{
|
21
26
|
client_internal_id: vehicle['vehicleId'],
|
22
27
|
license_plate: vehicle['licensePlate'],
|
23
|
-
|
28
|
+
vehicle_type: VEHICLE_TYPE_MAPPER[vehicle['type']],
|
29
|
+
vehicle_description: vehicle.dig("profile", "description"),
|
24
30
|
}
|
25
31
|
end
|
26
32
|
end
|
@@ -30,11 +36,13 @@ module ParkingTicket
|
|
30
36
|
mapped_time_units = rate_option['acceptedTimeUnits'].map do |accepted_time_unit|
|
31
37
|
ACCEPTED_TIME_UNIT_MAPPER[accepted_time_unit]
|
32
38
|
end
|
39
|
+
time_unit = mapped_time_units.include?('days') ? 'days' : 'hours'
|
33
40
|
{
|
34
41
|
client_internal_id: rate_option['rateOptionId'],
|
35
42
|
name: rate_option['name'],
|
36
43
|
type: rate_option['type'],
|
37
|
-
accepted_time_units: mapped_time_units
|
44
|
+
accepted_time_units: mapped_time_units,
|
45
|
+
free: fetch_and_map_quote(rate_option['rateOptionId'], zipcode, license_plate, 1, time_unit)[:cost].zero?
|
38
46
|
}
|
39
47
|
end
|
40
48
|
end
|
@@ -97,3 +105,4 @@ module ParkingTicket
|
|
97
105
|
end
|
98
106
|
end
|
99
107
|
end
|
108
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parking_ticket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.46
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Ecrepont
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|