Class: ParkingTicket::Base

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/parking_ticket.rb

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)

Raises:



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_methodsObject



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 rate_options(zipcode, license_plate)
  @adapter.rate_options(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

#vehiclesObject



66
67
68
# File 'lib/parking_ticket.rb', line 66

def vehicles
  @adapter.vehicles
end