Last active
January 28, 2017 05:45
-
-
Save j-wilkins/b4c4c2bcfdd428e7242f to your computer and use it in GitHub Desktop.
Order a Favorite Pizza from Papa Johns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mechanize' | |
class PapaOrder | |
SN_URL = 'https://order.papajohns.com/secure/signin/frame.html?destination=' | |
attr_reader :agent, :password, :email | |
def initialize(email, password) | |
@email, @password = email, password | |
@agent = Mechanize.new | |
end | |
def order_fave | |
faves = sign_in.link_with(text: 'Order a Fave').click | |
# This will just pick the first thing, there's actually more than one | |
# You can use `links_with` instead to get all of them, although getting | |
# more details wasn't immediately easy to do. | |
added = faves.link_with(text: 'Add to Order').click | |
checkout = added.link_with(text: 'Checkout').click | |
# NOTE: I never ran any of the steps past this because I don't want a pizza | |
# right now. | |
#agent.submit(checkout.form.tap do |f| | |
# fillout CC info (see below) | |
#end) | |
end | |
def sign_in | |
res = agent.submit(agent.get(SN_URL).form.tap do |f| | |
f.emailAddress = email | |
f.password = password | |
f._rememberEmailAddress = 'off' | |
end) | |
# They try and use JS here to trick us, but we're better than that. | |
if res.title == 'Sign In Success' | |
agent.get('http://order.papajohns.com/order.html') | |
else | |
p res | |
end | |
end | |
end | |
__END__ | |
These are the formy bits that you need for putting in CC info | |
[text:0x3ff80ed8da9c type: text name: paymentSummary.creditCardPayment.cardNumber value: ] | |
[text:0x3ff80ed8d8d0 type: text name: paymentSummary.creditCardPayment.nameOnCard value: ] | |
[text:0x3ff80ed8d6dc type: text name: paymentSummary.creditCardPayment.cvv value: ] | |
[text:0x3ff80ed8d0d8 type: text name: paymentSummary.creditCardPayment.billingAddress.address1 value: ] | |
[text:0x3ff80ed8cef8 type: text name: paymentSummary.creditCardPayment.billingAddress.address2 value: ] | |
[text:0x3ff80ed8cd18 type: text name: paymentSummary.creditCardPayment.billingAddress.city value: ] | |
[text:0x3ff80ed8cb24 type: text name: paymentSummary.creditCardPayment.billingAddress.postalCode value: ] | |
[field:0x3ff80ed8c930 type: tel name: paymentSummary.creditCardPayment.billingAddress.phoneNumber.phone1 value: ] | |
[field:0x3ff80ed8c764 type: tel name: paymentSummary.creditCardPayment.billingAddress.phoneNumber.phone2 value: ] | |
[field:0x3ff80ed8c584 type: tel name: paymentSummary.creditCardPayment.billingAddress.phoneNumber.phone3 value: ] | |
[text:0x3ff80ed8c1ec type: text name: paymentSummary.creditCardPayment.tipAmount value: ] | |
[text:0x3ff80ed89dd4 type: text name: paymentSummary.giftCardPayment.cardNumber value: ] | |
[text:0x3ff80ed89be0 type: text name: paymentSummary.giftCardPayment.pin value: ] | |
[text:0x3ff80ed89a00 type: text name: paymentSummary.giftCardPayment.tipAmount value: ] | |
[text:0x3ff80ed89424 type: text name: planAheadDate value: 05/19/2015] | |
[hidden:0x3ff80ed89258 type: hidden name: customer.over13 value: true] | |
[selectlist:0x3ff80ed88740 type: name: geoAddress.aptCode value: NON] | |
[selectlist:0x3ff80ed85900 type: name: paymentSummary.creditCardPayment.paymentTypeId value: ] | |
[selectlist:0x3ff80ed84e9c type: name: paymentSummary.creditCardPayment.expirationMonth value: ] | |
[selectlist:0x3ff80ed81b48 type: name: paymentSummary.creditCardPayment.expirationYear value: ] | |
[selectlist:0x3ff80ed80928 type: name: paymentSummary.creditCardPayment.billingAddress.state value: ] | |
[selectlist:0x3ff80ed79484 type: name: deliveryHour value: 1] | |
[selectlist:0x3ff80ed78494 type: name: deliveryMinute value: 00] | |
[selectlist:0x3ff80ed75b40 type: name: deliveryAMPM value: AM]} | |
{radiobuttons | |
[radiobutton:0x3ff80e488b40 type: radio name: paymentSummary.paymentMethod value: Cash] | |
[radiobutton:0x3ff80e488834 type: radio name: paymentSummary.paymentMethod value: CreditCard] | |
[radiobutton:0x3ff80ed8d538 type: radio name: paymentSummary.creditCardPayment.billingAddress.sameAddress value: true] | |
[radiobutton:0x3ff80ed8d308 type: radio name: paymentSummary.creditCardPayment.billingAddress.sameAddress value: false] | |
[radiobutton:0x3ff80ed8c020 type: radio name: paymentSummary.paymentMethod value: GiftCard] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment