class Samwise::DunsLookup

Attributes

response[R]

Public Class Methods

new(response) click to toggle source
# File lib/samwise/duns_lookup.rb, line 5
def initialize(response)
  @response = response
end

Public Instance Methods

small_business?() click to toggle source
# File lib/samwise/duns_lookup.rb, line 9
def small_business?
  if response.status == 200
    small_business_response
  else
    false
  end
end

Private Instance Methods

certifications() click to toggle source
# File lib/samwise/duns_lookup.rb, line 59
def certifications
  registration_data['certifications']
end
far_responses() click to toggle source
# File lib/samwise/duns_lookup.rb, line 55
def far_responses
  certifications['farResponses']
end
naics_answers() click to toggle source
# File lib/samwise/duns_lookup.rb, line 39
def naics_answers
  small_business_answers.find do |answer|
    answer.has_key?('naics')
  end['naics']
end
registration_data() click to toggle source
# File lib/samwise/duns_lookup.rb, line 63
def registration_data
  @_data ||= JSON.parse(response.body)["sam_data"]["registration"]
end
response_to_small_business_questions() click to toggle source
# File lib/samwise/duns_lookup.rb, line 49
def response_to_small_business_questions
  far_responses.find do |far_response|
    far_response['id'] == Samwise::Protocol::FAR_SMALL_BIZ_CITATION
  end
end
small_business_answers() click to toggle source
# File lib/samwise/duns_lookup.rb, line 45
def small_business_answers
  response_to_small_business_questions['answers']
end
small_business_naics_answers() click to toggle source
# File lib/samwise/duns_lookup.rb, line 33
def small_business_naics_answers
  naics_answers.select do |answer|
    Samwise::Protocol::NAICS_WHITELIST.include?(answer['naicsCode'])
  end
end
small_business_response() click to toggle source
# File lib/samwise/duns_lookup.rb, line 19
def small_business_response
  if registration_data && certifications && far_responses
    small_business_response?
  else
    false
  end
end
small_business_response?() click to toggle source
# File lib/samwise/duns_lookup.rb, line 27
def small_business_response?
  !small_business_naics_answers.detect do |answer|
    answer['isSmallBusiness'] == 'Y'
  end.nil?
end