Class: DominosJP

Inherits:
Object
  • Object
show all
Defined in:
lib/version.rb,
lib/dominosjp.rb

Constant Summary collapse

VERSION =
"0.2.0".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(login_details = {}) ⇒ DominosJP

Returns a new instance of DominosJP.



24
25
26
27
28
29
30
31
32
33
# File 'lib/dominosjp.rb', line 24

def initialize( = {})
  @email = [:email] || Preferences.instance.email
  @password = [: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

Instance Attribute Details

#order_addressObject

Returns the value of attribute order_address.



20
21
22
# File 'lib/dominosjp.rb', line 20

def order_address
  @order_address
end

#order_couponObject

Returns the value of attribute order_coupon.



22
23
24
# File 'lib/dominosjp.rb', line 22

def order_coupon
  @order_coupon
end

#order_informationObject

Returns the value of attribute order_information.



20
21
22
# File 'lib/dominosjp.rb', line 20

def order_information
  @order_information
end

#order_paymentObject

Returns the value of attribute order_payment.



22
23
24
# File 'lib/dominosjp.rb', line 22

def order_payment
  @order_payment
end

#order_reviewObject

Returns the value of attribute order_review.



21
22
23
# File 'lib/dominosjp.rb', line 21

def order_review
  @order_review
end

Instance Method Details

#loginObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/dominosjp.rb', line 35

def 
  @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

#orderObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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