Sha256: 7e78d2b88362a656e74e90d5c259de3a8bfe9734971223c403bbd94edba6b6f9

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

module Fizzy
  module Api
    module Endpoints
      class CalculateOutcome < Endpoint
        string :dossier_id
        string :protocol_subscription_id

        def execute
          response = Api.basic_auth_session.post("/dossier/#{dossier_id}"\
                                                 "/protocol_subscriptions/#{protocol_subscription_id}"\
                                                 '/calculate')
          process_response(response)
        end

        private

        def invalid_response(response)
          case response.code
          when 202
            raise(Errors::OutcomeNotAvailableError,
                  select_measurement_text(response, 'The results are currently being calculated.'))
          when 404
            raise Errors::GraphNotFoundError, select_measurement_text(response,
                                                                      'Participant not found, or graph not supported.')
          else
            raise Errors::UnexpectedStatusError, "Status code #{response.code} not expected."
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fizzy-api-0.1.4 lib/fizzy/api/endpoints/calculate_outcome.rb
fizzy-api-0.1.3 lib/fizzy/api/endpoints/calculate_outcome.rb
fizzy-api-0.1.2 lib/fizzy/api/endpoints/calculate_outcome.rb
fizzy-api-0.1.1 lib/fizzy/api/endpoints/calculate_outcome.rb