class DominosJP

Constants

VERSION

Attributes

order_address[RW]
order_coupon[RW]
order_information[RW]
order_payment[RW]
order_review[RW]

Public Class Methods

new(login_details = {}) click to toggle source
# File lib/dominosjp.rb, line 24
def initialize(login_details = {})
  @email = login_details[:email] || Preferences.instance.email
  @password = login_details[:password]

  self.order_address = OrderAddress.new
  self.order_information = OrderInformation.new
  self.order_review = OrderReview.new
  self.order_coupon = OrderCoupon.new
  self.order_payment = OrderPayment.new
end

Public Instance Methods

login() click to toggle source
# File lib/dominosjp.rb, line 35
def login
  @email ||= Ask.input("Email")
  @password ||= HighLine.new.ask("Password: ") { |q| q.echo = "*" }

  Request.post(
    "https://order.dominos.jp/eng/login/login/",
    { "emailAccount" => @email, "webPwd" => @password },
    expect: :redirect, failure: "Couldn't log in successfully"
  )
end
order() click to toggle source
# File lib/dominosjp.rb, line 46
def order
  order_address.input
  order_address.validate

  order_information.input
  order_information.validate
  order_information.display
  order_information.confirm

  PizzaSelector.select_pizzas
  SideSelector.select_sides

  order_review.display

  order_coupon.total_price_without_tax = order_review.total_price_without_tax
  order_coupon.input
  order_coupon.validate

  order_review.display

  order_payment.default_name = order_information.name
  order_payment.input
  order_payment.validate
  order_payment.display

  order_review.page = order_payment.page
  order_review.display

  order_payment.confirm
end