Class: StellarFederation::Api::V1::QueriesController

Inherits:
StellarFederation::ApplicationController show all
Defined in:
app/controllers/stellar_federation/api/v1/queries_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/stellar_federation/api/v1/queries_controller.rb', line 7

def index
  result = Queries::ProcessQuery.(query_params: query_params)

  respond_to do |format|
    format.json do
      if result.success?
        @query_response = result.query_response

        if @query_response.present?
          render json: @query_response.to_json, status: :ok
        else
          render json: @query_response.to_json, status: :not_found
        end
      else
        json_status = { details: result.message }

        render json: json_status, status: :unprocessable_entity
      end
    end
  end

end