class BOS::User
Attributes
overview_page[R]
password[R]
security_code[R]
security_page[R]
user_id[R]
Public Class Methods
new(user_id, password, security_code)
click to toggle source
# File lib/bos/user.rb, line 5 def initialize(user_id, password, security_code) @user_id = user_id @password = password @security_code = security_code end
Public Instance Methods
inspect()
click to toggle source
# File lib/bos/user.rb, line 14 def inspect "#<BOS::User:0x#{(object_id << 1).to_s(16)}>" end
Private Instance Methods
enter_password()
click to toggle source
Private: Login with the user's id and password
Returns: Security Page
# File lib/bos/user.rb, line 23 def enter_password return if @security_page login_page = BOS.agent.get(LOGIN_PAGE) login_form = login_page.form("frmLogin") login_form["frmLogin:strCustomerLogin_userID"] = user_id login_form["frmLogin:strCustomerLogin_pwd"] = password page = BOS.agent.submit(login_form, login_form.buttons.first) if page.uri.to_s.include? LOGIN_PAGE raise LoginError, "ID OR PASSWORD IS WRONG" else @security_page = page end end
enter_security_code()
click to toggle source
Private: Enter the security code on security information page
Returns: Acccount Overall Page
# File lib/bos/user.rb, line 43 def enter_security_code return if @overview_page security_code_form = security_page.form("frmentermemorableinformation1") number1 = security_page.search("label[for='frmentermemorableinformation1:strEnterMemorableInformation_memInfo1']").text() number1 = security_code[/\d+/.match(number1)[0].to_i - 1] number2 = security_page.search("label[for='frmentermemorableinformation1:strEnterMemorableInformation_memInfo2']").text() number2 = security_code[/\d+/.match(number2)[0].to_i - 1] number3 = security_page.search("label[for='frmentermemorableinformation1:strEnterMemorableInformation_memInfo3']").text() number3 = security_code[/\d+/.match(number3)[0].to_i - 1] security_code_form.field_with(name: "frmentermemorableinformation1:strEnterMemorableInformation_memInfo1") .value = " #{number1}" security_code_form.field_with(name: "frmentermemorableinformation1:strEnterMemorableInformation_memInfo2") .value = " #{number2}" security_code_form.field_with(name: "frmentermemorableinformation1:strEnterMemorableInformation_memInfo3") .value = " #{number3}" page = BOS.agent.submit(security_code_form, security_code_form.buttons.first) if /account_overview_personal/.match page.uri.to_s @overview_page = page else raise LoginError, "SECURE CODE IS WRONG" unless /account_overview_personal/.match page.uri.to_s end end
query()
click to toggle source
# File lib/bos/user.rb, line 72 def query @query ||= begin enter_password enter_security_code Query.new overview_page end end