Sha256: cd6d66e6c374de527b0f6e7087b3982b1257e5c2f027396c92066f194133f879

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

module Fizzy
  module Api
    module Endpoints
      class RenderGraph < Endpoint
        string :dossier_id
        string :protocol_subscription_id
        string :path
        hash :options, default: {}

        def execute
          response = Api.basic_auth_session.get("/dossier/#{dossier_id}"\
                                                "/protocol_subscriptions/#{protocol_subscription_id}" \
                                                "/render/#{path}", options)
          process_response(response)
        end

        private

        def invalid_response(response)
          case response.code
          when 202
            raise Errors::OutcomeNotAvailableError, select_measurement_text(response,
                                                                            'The results have not yet been calculated.')
          when 204
            raise Errors::TooFewMeasurementsError, select_measurement_text(response,
                                                                           'Not enough measurements available.')
          when 404
            raise Errors::GraphNotFoundError, select_measurement_text(response,
                                                                      'Graph not found.')
          else
            raise Errors::UnexpectedStatusError, "Status code #{response.code} not expected."
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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