Class: ParkingTicket::Base
- Inherits:
-
Object
- Object
- ParkingTicket::Base
- Extended by:
- T::Sig
- Defined in:
- lib/parking_ticket.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(adapter_name, username, password) ⇒ Base
constructor
A new instance of Base.
- #new_ticket(license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, payment_method_id:) ⇒ Object
- #payment_methods ⇒ Object
- #quote(rate_option_id, zipcode, license_plate, quantity, time_unit) ⇒ Object
- #rate_options(zipcode, license_plate) ⇒ Object
- #running_ticket(license_plate, zipcode) ⇒ Object
- #vehicles ⇒ Object
Constructor Details
#initialize(adapter_name, username, password) ⇒ Base
Returns a new instance of Base.
59 60 61 62 63 |
# File 'lib/parking_ticket.rb', line 59 def initialize(adapter_name, username, password) @username = username @password = password @adapter = T.let(load_adapter!(adapter_name), ParkingTicket::Clients::PayByPhone::Adapter) end |
Class Method Details
.valid_credentials?(adapter_name, username, password) ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/parking_ticket.rb', line 39 def valid_credentials?(adapter_name, username, password) adapter_class = Clients::PayByPhone::Adapter if adapter_name == 'pay_by_phone' raise Error, 'EasyPark will be handled in the next major release' if adapter_name == 'easy_park' raise Error, "Unhandled adapter : #{adapter_name}" unless adapter_class adapter_class.valid_credentials?(username, password) end |
Instance Method Details
#new_ticket(license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, payment_method_id:) ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/parking_ticket.rb', line 109 def new_ticket(license_plate:, zipcode:, rate_option_client_internal_id:, quantity:, time_unit:, payment_method_id:) @adapter.new_ticket( license_plate: license_plate, zipcode: zipcode, rate_option_client_internal_id: rate_option_client_internal_id, quantity: 1, time_unit: time_unit, payment_method_id: payment_method_id ) end |
#payment_methods ⇒ Object
81 82 83 |
# File 'lib/parking_ticket.rb', line 81 def payment_methods @adapter.payment_methods end |
#quote(rate_option_id, zipcode, license_plate, quantity, time_unit) ⇒ Object
95 96 97 |
# File 'lib/parking_ticket.rb', line 95 def quote(rate_option_id, zipcode, license_plate, quantity, time_unit) @adapter.quote(rate_option_id, zipcode, license_plate, quantity, time_unit) end |
#rate_options(zipcode, license_plate) ⇒ Object
71 72 73 |
# File 'lib/parking_ticket.rb', line 71 def (zipcode, license_plate) @adapter.(zipcode, license_plate) end |
#running_ticket(license_plate, zipcode) ⇒ Object
76 77 78 |
# File 'lib/parking_ticket.rb', line 76 def running_ticket(license_plate, zipcode) @adapter.running_ticket(license_plate, zipcode) end |
#vehicles ⇒ Object
66 67 68 |
# File 'lib/parking_ticket.rb', line 66 def vehicles @adapter.vehicles end |