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
- #get_duns_info(duns: nil) ⇒ Object
- #get_sam_status(duns: nil) ⇒ Object
-
#initialize(api_key: nil, sam_status_key: Samwise::Protocol::SAM_STATUS_KEY) ⇒ Client
constructor
A new instance of Client.
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 12 13 14 |
# 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'] @conn = Faraday.new do |faraday| faraday.adapter :httpclient end @client = HTTPClient.new end |
Instance Method Details
#duns_is_in_sam?(duns: nil) ⇒ Boolean
21 22 23 24 |
# File 'lib/samwise/client.rb', line 21 def duns_is_in_sam?(duns: nil) response = lookup_duns(duns: duns) response.status == 200 end |
#get_duns_info(duns: nil) ⇒ Object
16 17 18 19 |
# File 'lib/samwise/client.rb', line 16 def get_duns_info(duns: nil) response = lookup_duns(duns: duns) JSON.parse(response.body) end |
#get_sam_status(duns: nil) ⇒ Object
26 27 28 29 |
# File 'lib/samwise/client.rb', line 26 def get_sam_status(duns: nil) response = lookup_sam_status(duns: duns) JSON.parse(response.body) end |