parking_ticket 1.0.41 → 1.0.43
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/Gemfile.lock +2 -2
- data/lib/clients/adapter.rb +15 -3
- data/lib/clients/pay_by_phone/adapter.rb +18 -14
- data/lib/clients/pay_by_phone/client.rb +47 -33
- data/lib/parking_ticket/version.rb +1 -1
- data/lib/parking_ticket.rb +13 -2
- 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: 807243c2565c844ad7894141c7288c61948b666db5d12d420f6cae068f0cb1a9
|
4
|
+
data.tar.gz: d1b652a0e6ac526c0cf0019ed01a6b9b36174b7def77039ca3106b7de1eb28ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e84b00754ab4630a3e5eff2ce837b515496de473d209f3330eae4a9796dac17b758936203a8e78f8150a2312cc2a5320f74f874f13ea7e3353b445ca7489997d
|
7
|
+
data.tar.gz: f7118e429f4300500523e4356b17f15e2abcff7bc031236d3d0ed3217467afff72ec5aad889ec28956630fcd15b4e3b21e2241afd8f3b1635ee39b79b1bf718f
|
data/Gemfile.lock
CHANGED
data/lib/clients/adapter.rb
CHANGED
@@ -38,11 +38,23 @@ module ParkingTicket
|
|
38
38
|
fetch_and_map_payment_methods
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def quote(rate_option_id, zipcode, license_plate, quantity, time_unit)
|
42
42
|
raise_invalid_credentials! unless valid_credentials?
|
43
|
-
|
43
|
+
fetch_and_map_quote(rate_option_id, zipcode, license_plate, quantity, time_unit)
|
44
|
+
end
|
45
|
+
|
46
|
+
def new_ticket(license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, payment_method_id:)
|
47
|
+
raise_invalid_credentials! unless valid_credentials?
|
48
|
+
# return if running_ticket(license_plate, zipcode)
|
44
49
|
|
45
|
-
request_new_ticket(
|
50
|
+
request_new_ticket(
|
51
|
+
license_plate: license_plate,
|
52
|
+
zipcode: zipcode,
|
53
|
+
rate_option_client_internal_id: rate_option_client_internal_id,
|
54
|
+
quantity: quantity,
|
55
|
+
time_unit: time_unit,
|
56
|
+
payment_method_id: payment_method_id
|
57
|
+
)
|
46
58
|
end
|
47
59
|
|
48
60
|
private
|
@@ -54,20 +54,21 @@ module ParkingTicket
|
|
54
54
|
end.first
|
55
55
|
end
|
56
56
|
|
57
|
-
def request_new_ticket(license_plate
|
57
|
+
def request_new_ticket(license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, payment_method_id:)
|
58
58
|
mapped_time_unit = ACCEPTED_TIME_UNIT_MAPPER.key(time_unit)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
|
60
|
+
quote = fetch_and_map_quote(rate_option_client_internal_id, zipcode, license_plate, quantity,
|
61
|
+
time_unit)
|
62
|
+
|
63
63
|
client.new_ticket(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
quote[:starts_on]
|
64
|
+
license_plate: license_plate,
|
65
|
+
zipcode: zipcode,
|
66
|
+
rate_option_client_internal_id: rate_option_client_internal_id,
|
67
|
+
quantity: quantity,
|
68
|
+
time_unit: mapped_time_unit,
|
69
|
+
quote_client_internal_id: quote[:client_internal_id],
|
70
|
+
starts_on: quote[:starts_on],
|
71
|
+
payment_method_id: payment_method_id
|
71
72
|
)
|
72
73
|
end
|
73
74
|
|
@@ -82,11 +83,14 @@ module ParkingTicket
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def fetch_and_map_quote(rate_option_id, zipcode, license_plate, quantity, time_unit)
|
85
|
-
|
86
|
+
mapped_time_unit = ACCEPTED_TIME_UNIT_MAPPER.key(time_unit)
|
87
|
+
fetched_quote = client.quote(rate_option_id, zipcode, license_plate, quantity, mapped_time_unit)
|
88
|
+
|
86
89
|
{
|
87
90
|
client_internal_id: fetched_quote['quoteId'],
|
88
91
|
starts_on: fetched_quote['parkingStartTime'],
|
89
|
-
ends_on: fetched_quote['parkingExpiryTime']
|
92
|
+
ends_on: fetched_quote['parkingExpiryTime'],
|
93
|
+
cost: fetched_quote.dig('totalCost', 'amount')
|
90
94
|
}
|
91
95
|
end
|
92
96
|
end
|
@@ -58,38 +58,45 @@ module ParkingTicket
|
|
58
58
|
).body
|
59
59
|
end
|
60
60
|
|
61
|
-
def new_ticket(token, account_id,
|
62
|
-
|
63
|
-
"
|
64
|
-
{
|
65
|
-
"
|
66
|
-
"
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
61
|
+
def new_ticket(token, account_id, license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, quote_client_internal_id:, starts_on:, payment_method_id:)
|
62
|
+
base_data = {
|
63
|
+
"expireTime": nil,
|
64
|
+
"duration": {
|
65
|
+
"quantity": quantity.to_s,
|
66
|
+
"timeUnit": time_unit
|
67
|
+
},
|
68
|
+
"licensePlate": license_plate,
|
69
|
+
"locationId": zipcode,
|
70
|
+
"rateOptionId": rate_option_client_internal_id,
|
71
|
+
"startTime": starts_on,
|
72
|
+
"quoteId": quote_client_internal_id,
|
73
|
+
"parkingAccountId": account_id
|
74
|
+
}
|
75
|
+
|
76
|
+
payment_data = {
|
77
|
+
"paymentMethod": {
|
78
|
+
"paymentMethodType": 'PaymentAccount',
|
79
|
+
"payload": {
|
80
|
+
"paymentAccountId": payment_method_id,
|
81
|
+
"clientBrowserDetails": {
|
82
|
+
"browserAcceptHeader": 'text/html',
|
83
|
+
"browserColorDepth": '30',
|
84
|
+
"browserJavaEnabled": 'false',
|
85
|
+
"browserLanguage": 'fr-FR',
|
86
|
+
"browserScreenHeight": '900',
|
87
|
+
"browserScreenWidth": '1440',
|
88
|
+
"browserTimeZone": '-60',
|
89
|
+
"browserUserAgent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
|
90
90
|
}
|
91
91
|
}
|
92
|
-
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
byebug
|
95
|
+
final_data = payment_method_id ? base_data.merge(payment_data) : base_data
|
96
|
+
|
97
|
+
connection(token).post(
|
98
|
+
"/parking/accounts/#{account_id}/sessions/",
|
99
|
+
final_data.to_json
|
93
100
|
).body
|
94
101
|
end
|
95
102
|
|
@@ -137,9 +144,16 @@ module ParkingTicket
|
|
137
144
|
self.class.quote(token, account_id, rate_option_id, zipcode, license_plate, quantity, time_unit)
|
138
145
|
end
|
139
146
|
|
140
|
-
def new_ticket(
|
141
|
-
self.class.new_ticket(token, account_id,
|
142
|
-
|
147
|
+
def new_ticket(license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, quote_client_internal_id:, starts_on:, payment_method_id:)
|
148
|
+
self.class.new_ticket(token, account_id,
|
149
|
+
license_plate: license_plate,
|
150
|
+
zipcode: zipcode,
|
151
|
+
rate_option_client_internal_id: rate_option_client_internal_id,
|
152
|
+
quantity: quantity,
|
153
|
+
time_unit: time_unit,
|
154
|
+
quote_client_internal_id: quote_client_internal_id,
|
155
|
+
starts_on: starts_on,
|
156
|
+
payment_method_id: payment_method_id)
|
143
157
|
end
|
144
158
|
|
145
159
|
private
|
data/lib/parking_ticket.rb
CHANGED
@@ -66,8 +66,19 @@ module ParkingTicket
|
|
66
66
|
adapter.payment_methods
|
67
67
|
end
|
68
68
|
|
69
|
-
def new_ticket(license_plate
|
70
|
-
adapter.new_ticket(
|
69
|
+
def new_ticket(license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, payment_method_id:)
|
70
|
+
adapter.new_ticket(
|
71
|
+
license_plate: license_plate,
|
72
|
+
zipcode: zipcode,
|
73
|
+
rate_option_client_internal_id: rate_option_client_internal_id,
|
74
|
+
quantity: 1,
|
75
|
+
time_unit: time_unit,
|
76
|
+
payment_method_id: payment_method_id
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def quote(rate_option_id, zipcode, license_plate, quantity, time_unit)
|
81
|
+
adapter.quote(rate_option_id, zipcode, license_plate, quantity, time_unit)
|
71
82
|
end
|
72
83
|
|
73
84
|
private
|
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.43
|
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-02-
|
11
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|