Class: SportsSouth::FFL

Inherits:
Base
  • Object
show all
Defined in:
lib/sports_south/ffl.rb

Constant Summary collapse

API_URL =
'http://webservices.theshootingwarehouse.com/smart/orders.asmx'
DATE_REGEX =
/\A\d+\/\d+\/\d+/

Constants inherited from Base

Base::CONTENT_TYPE, Base::TIMEOUT, Base::USER_AGENT

Class Method Summary collapse

Class Method Details

.accepts_transfer(ffl, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sports_south/ffl.rb', line 8

def self.accepts_transfer(ffl, options = {})
  requires!(options, :username, :password)

  http, request = get_http_and_request(API_URL, '/FFLAcceptsTransfer')

  request.set_form_data(form_params(options).merge({ FFL: ffl }))

  response = http.request(request)
  xml_doc  = Nokogiri::XML(sanitize_response(response))

  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)

  # Response returns FFL expiration date (does accept transfer),
  # '0' if they do not accept transfer,
  # or 'UNKNOWN' if SS cannot find the FFL.
  xml_doc.content =~ DATE_REGEX ? true : false
end