Sha256: b3007e1e5a42277a0fbe3fc75865f78e04b6ed0758475a82cae930acc564d3c5

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

module Fizzy
  module Api
    module Endpoints
      class RenderGraphSynchronous < 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_sync/#{path}", options)
          process_response(response)
        end

        private

        def invalid_response(response)
          case response.code
          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.')
          when 405
            raise Errors::MethodNotAllowedError, select_measurement_text(response,
                                                                         'Current image path not eligible for'\
                                                                         ' synchronous rendering')
          else
            raise Errors::UnexpectedStatusError, "Status code #{response.code} not expected."
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fizzy-api-0.1.1 lib/fizzy/api/endpoints/render_graph_synchronous.rb
fizzy-api-0.1.0 lib/fizzy/api/endpoints/render_graph_synchronous.rb