mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-22 08:28:35 +00:00
* Updated project set up guide for Mac, added node version and Webpack install steps. * Worked on PR comment i.e Can we change this line to Install Node.js ( version: v14.9.0 ) * Fixed "Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping." * Resolved rubocop comments i.e "Style/FrozenStringLiteralComment: Missing frozen string literal comment." in test folder Co-authored-by: Deepti Kakade <deepti@saeloun.com> Co-authored-by: Deepti Kakade <“deepti@saeloun.com”>
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class SlackQueryService
|
|
attr_accessor :query, :ource, :options, :source_options, :current_user
|
|
|
|
def initialize(data_query, data_source, options, source_options, current_user)
|
|
@query = data_query
|
|
@source = data_source
|
|
@options = options
|
|
@source_options = source_options
|
|
@current_user = current_user
|
|
end
|
|
|
|
def process
|
|
operation = options["operation"]
|
|
access_token = source_options["access_token"]
|
|
data = []
|
|
|
|
if operation === "list_users"
|
|
result = HTTParty.get("https://slack.com/api/users.list",
|
|
headers: { "Authorization": "Bearer #{access_token}" })
|
|
|
|
data = JSON.parse(result.body)
|
|
end
|
|
|
|
if operation === "send_message"
|
|
|
|
body = {
|
|
channel: options["channel"],
|
|
text: options["message"],
|
|
as_user: options["sendAsUser"]
|
|
}.to_json
|
|
|
|
result = HTTParty.post("https://slack.com/api/chat.postMessage",
|
|
body: body,
|
|
headers: { "Content-Type": "application/json", "Authorization": "Bearer #{access_token}" }
|
|
)
|
|
|
|
data = JSON.parse(result.body)
|
|
end
|
|
|
|
{ status: "success", data: data }
|
|
end
|
|
end
|