Skip to content
This repository was archived by the owner on Dec 8, 2017. It is now read-only.
This repository was archived by the owner on Dec 8, 2017. It is now read-only.

Show error messages to end user #32

@jessieay

Description

@jessieay

Was having an issue where my API key was always returning false

@client.get_vendor_summary(duns: '1234567')
=> {:in_sam=>false, :small_business=>false}

this would happen for any duns number.

when I went deeper and ran this:

HTTPClient.new.get Samwise::Protocol.duns_url(duns: '1234567', api_key: MY_API_KEY)
=> #<HTTP::Message:0x00564c5c248ea8 @http_header=#<HTTP::Message::Headers:0x00564c5c248e30 @http_version="1.1", @body_size=0, @chunked=false, @request_method="GET", @request_uri=#<Addressable::URI:0x2b262e124f74 URI:https://api.data.gov/sam/v4/registrations/1234567?api_key=MGPzhnEylwtQAjZYBx5pFIq02C9JPSSAe4uKzRIN>, @request_query=nil, @request_absolute_uri=nil, @status_code=403, @reason_phrase="Forbidden", @body_type=nil, @body_charset=nil, @body_date=nil, @body_encoding=#<Encoding:ASCII-8BIT>, @is_request=false, @header_item=[["Server", "openresty"], ["Date", "Fri, 16 Sep 2016 18:29:58 GMT"], ["Content-Type", "application/json"], ["Transfer-Encoding", "chunked"], ["Connection", "keep-alive"], ["Vary", "Accept-Encoding"], ["Access-Control-Allow-Origin", "*"], ["X-Cache", "MISS"]], @dumped=false>, @peer_cert=#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x00564c5c1ee4d0>, issuer=#<OpenSSL::X509::Name:0x00564c5c1ee4f8>, serial=#<OpenSSL::BN:0x00564c5c1ee520>, not_before=2016-08-01 00:37:00 UTC, not_after=2016-10-30 00:37:00 UTC>, @http_body=#<HTTP::Message::Body:0x00564c5c248cf0 @body="{\n  \"error\": {\n    \"code\": \"API_KEY_DISABLED\",\n    \"message\": \"The api_key supplied has been disabled. Contact us at https://api.data.gov/contact/ for assistance\"\n  }\n}", @size=0, @positions=nil, @chunk_size=nil>, @previous=nil>

we should filter this error message up to the end user rather than returning false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions