Sha256: cd736dfb06d75a750111a9d7986685fc80cd19bd3e32056f97de0547b6ab651e

Contents?: true

Size: 623 Bytes

Versions: 1

Compression:

Stored size: 623 Bytes

Contents

# frozen_string_literal: true

module Fizzy
  module Api
    module Endpoints
      class Endpoint < ActiveInteraction::Base
        protected

        def process_response(response)
          case response.code
          when 200
            response
          else
            invalid_response(response)
          end
        end

        def invalid_response(response)
          raise Errors::UnexpectedStatusError, "Status code #{response.code} not expected."
        end

        def select_measurement_text(response, default_message)
          response.body || default_message
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fizzy-api-0.1.5 lib/fizzy/api/endpoints/endpoint.rb