Class: AnswerLayer::QueryResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/answerlayer/resources/query.rb

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from AnswerLayer::Resource

Instance Method Details

#execute(connection_id:, query:, params: nil, row_limit: nil, timeout: nil) ⇒ Object



5
6
7
# File 'lib/answerlayer/resources/query.rb', line 5

def execute(connection_id:, query:, params: nil, row_limit: nil, timeout: nil)
  request(method: :post, path: "/query/#{connection_id}", body: compact(query: query, params: params, row_limit: row_limit, timeout: timeout))
end

#export(connection_id:, query:, format: :csv, params: nil, row_limit: nil, timeout: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/answerlayer/resources/query.rb', line 13

def export(connection_id:, query:, format: :csv, params: nil, row_limit: nil, timeout: nil)
  request(
    method: :post,
    path: "/query/#{connection_id}/export",
    params: { format: format },
    body: compact(query: query, params: params, row_limit: row_limit, timeout: timeout),
    download: true
  )
end

#validate(connection_id:, query:) ⇒ Object



9
10
11
# File 'lib/answerlayer/resources/query.rb', line 9

def validate(connection_id:, query:)
  to_api_response(request(method: :post, path: "/query/#{connection_id}/validate", body: { query: query }))
end