Class: SportsSouth::User
Constant Summary collapse
- API_URL =
'http://webservices.theshootingwarehouse.com/smart/users.asmx'
Constants inherited from Base
Base::CONTENT_TYPE, Base::TIMEOUT, Base::USER_AGENT
Instance Attribute Summary collapse
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
Instance Method Summary collapse
- #authenticated? ⇒ Boolean
- #email_preferences ⇒ Object
-
#initialize(options = {}) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(options = {}) ⇒ User
Returns a new instance of User.
8 9 10 11 12 |
# File 'lib/sports_south/user.rb', line 8 def initialize( = {}) requires!(, :username, :password) @options = end |
Instance Attribute Details
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
6 7 8 |
# File 'lib/sports_south/user.rb', line 6 def response_body @response_body end |
Instance Method Details
#authenticated? ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'lib/sports_south/user.rb', line 14 def authenticated? # Use #email_preferences as a check, since there's no official way of just testing credentials. email_preferences true rescue SportsSouth::NotAuthenticated false end |
#email_preferences ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sports_south/user.rb', line 22 def email_preferences http, request = get_http_and_request(API_URL, '/GetEmailPrefs') request.set_form_data(form_params(@options)) response = http.request(request) body = sanitize_response(response) xml_doc = Nokogiri::XML(body) raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc) @response_body = body @email_preferences = { default_email: content_for(xml_doc, 'CUEML'), statement_email: content_for(xml_doc, 'STMNTS'), marketing_email: content_for(xml_doc, 'MKTG'), email_statements: (content_for(xml_doc, 'EMLSTM') == 'E'), email_invoices: (content_for(xml_doc, 'EMLINV') == 'E'), } end |