Class: Samwise::Client
- Inherits:
-
Object
- Object
- Samwise::Client
- Defined in:
- lib/samwise/client.rb
Instance Method Summary collapse
- #duns_is_in_sam?(duns: nil) ⇒ Boolean
- #excluded?(duns: nil) ⇒ Boolean
- #get_duns_info(duns: nil) ⇒ Object
- #get_sam_status(duns: nil) ⇒ Object
- #get_vendor_summary(duns: nil) ⇒ Object
-
#initialize(api_key: nil, sam_status_key: Samwise::Protocol::SAM_STATUS_KEY) ⇒ Client
constructor
A new instance of Client.
- #small_business?(duns: nil) ⇒ Boolean
Constructor Details
#initialize(api_key: nil, sam_status_key: Samwise::Protocol::SAM_STATUS_KEY) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/samwise/client.rb', line 6 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
26 27 28 29 |
# File 'lib/samwise/client.rb', line 26 def duns_is_in_sam?(duns: nil) response = lookup_duns(duns: duns) parse_response_for_sam_status(response) end |
#excluded?(duns: nil) ⇒ Boolean
36 37 38 39 |
# File 'lib/samwise/client.rb', line 36 def excluded?(duns: nil) response = lookup_duns(duns: duns) JSON.parse(response.body)["hasKnownExclusion"] == false end |
#get_duns_info(duns: nil) ⇒ Object
12 13 14 15 |
# File 'lib/samwise/client.rb', line 12 def get_duns_info(duns: nil) response = lookup_duns(duns: duns) JSON.parse(response.body) end |
#get_sam_status(duns: nil) ⇒ Object
31 32 33 34 |
# File 'lib/samwise/client.rb', line 31 def get_sam_status(duns: nil) response = lookup_sam_status(duns: duns) JSON.parse(response.body) end |
#get_vendor_summary(duns: nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/samwise/client.rb', line 17 def get_vendor_summary(duns: nil) response = lookup_duns(duns: duns) { in_sam: parse_response_for_sam_status(response), small_business: parse_response_for_small_business(response) } end |
#small_business?(duns: nil) ⇒ Boolean
41 42 43 44 |
# File 'lib/samwise/client.rb', line 41 def small_business?(duns: nil) response = lookup_duns(duns: duns) parse_response_for_small_business(response) end |