Class: OrionWholesale::User

Inherits:
Base
  • Object
show all
Defined in:
lib/orion_wholesale/user.rb

Constant Summary collapse

USER_DIR =
'/ammoready'
USER_FILENAME_PREFIX =
'orion_ardy_cust_tab'

Instance Method Summary collapse

Methods inherited from Base

connect

Constructor Details

#initialize(options = {}) ⇒ User

Returns a new instance of User.



7
8
9
10
# File 'lib/orion_wholesale/user.rb', line 7

def initialize(options = {})
  requires!(options, :username, :password, :account_id)
  @options = options
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/orion_wholesale/user.rb', line 12

def authenticated?
  tempfile = get_most_recent_file(USER_FILENAME_PREFIX, USER_DIR)

  File.open(tempfile).each_with_index do |row, i|
    row = row.split("\t")

    return true if row[0].strip.downcase == @options[:account_id].strip.downcase
  end

  false
rescue OrionWholesale::NotAuthenticated
  false
end