Sha256: 08f879733f2b6494ecf1d92655c8e7d6e3ee5ca08bc973c9189a9269286e2453

Contents?: true

Size: 777 Bytes

Versions: 4

Compression:

Stored size: 777 Bytes

Contents

module LifenFhir

  class AppAuthenticatedClient < Client

    private

      def handle_errors(response, params)
        super(response, params)

        case response.status
        when 400
          raise_error("400 Error, Unknown error", response, params)
        when 401
          raise_error("401 Error, Invalid app bearer", response, params)
        when 404
          raise_error("404 Error, Record not found", response, params)
        when 422
          json = JSON.parse response.body

          diagnostic = json["issue"][0]["diagnostics"]

          raise_error("422 Error, Unprocessable Entity, Diagnostic: '#{diagnostic}'", response, params)
        end

      end

      def bearer
        LifenFhir.configuration.application_access_token
      end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lifen_fhir-0.7.1 lib/lifen_fhir/app_authenticated_client.rb
lifen_fhir-0.7.0 lib/lifen_fhir/app_authenticated_client.rb
lifen_fhir-0.6.1 lib/lifen_fhir/app_authenticated_client.rb
lifen_fhir-0.6.0 lib/lifen_fhir/app_authenticated_client.rb