Class: Samwise::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/samwise/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, sam_status_key: Samwise::Protocol::SAM_STATUS_KEY) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/samwise/client.rb', line 7

def initialize(api_key: nil, sam_status_key: Samwise::Protocol::SAM_STATUS_KEY)
  @api_key        = api_key        || ENV['DATA_DOT_GOV_API_KEY']
  @sam_status_key = sam_status_key || ENV['SAM_STATUS_KEY']
  @client = HTTPClient.new
end

Instance Method Details

#duns_is_in_sam?(duns: nil) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/samwise/client.rb', line 27

def duns_is_in_sam?(duns: nil)
  response = lookup_duns(duns: duns)
  parse_response_for_sam_status(response)
end

#excluded?(duns: nil) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/samwise/client.rb', line 37

def excluded?(duns: nil)
  response = lookup_duns(duns: duns)
  JSON.parse(response.body)["hasKnownExclusion"] == false
end

#get_duns_info(duns: nil) ⇒ Object



13
14
15
16
# File 'lib/samwise/client.rb', line 13

def get_duns_info(duns: nil)
  response = lookup_duns(duns: duns)
  JSON.parse(response.body)
end

#get_sam_status(duns: nil) ⇒ Object



32
33
34
35
# File 'lib/samwise/client.rb', line 32

def get_sam_status(duns: nil)
  response = lookup_sam_status(duns: duns)
  JSON.parse(response.body)
end

#get_vendor_summary(duns: nil) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/samwise/client.rb', line 18

def get_vendor_summary(duns: nil)
  response = lookup_duns(duns: duns)

  {
    in_sam: parse_response_for_sam_status(response),
    small_business: small_business?(response)
  }
end