Sha256: 50220d6285f480d732c06bf0547d9393eddecc36243650ff2399089eab84beab

Contents?: true

Size: 812 Bytes

Versions: 2

Compression:

Stored size: 812 Bytes

Contents

module Fizzy
  module Api
    class CalculateOutcome < ActiveInteraction::Base
      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 process_response(response)
        case response.code
        when 200
          response
        when 404
          fail Errors::GraphNotFoundError, 'Participant not found, or graph not supported.'
        else
          fail Errors::UnexpectedStatusError, "Status code #{response.code} not expected."
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fizzy-api-0.0.2.1 lib/fizzy/api/calculate_outcome.rb
fizzy-api-0.0.2 lib/fizzy/api/calculate_outcome.rb