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



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

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

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

        render json: @query_response.to_json, status: :ok
      else
        json_status = {
          status: "Unprocessable Entity",
          message: result.message,
        }

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

end