class Brutalismbot::Slack::Auth
Public Class Methods
stub(bot_id:nil, channel_id:nil, team_id:nil, user_id:nil)
click to toggle source
# File lib/brutalismbot/slack/stub.rb, line 44 def stub(bot_id:nil, channel_id:nil, team_id:nil, user_id:nil) bot_id ||= "B#{SecureRandom.alphanumeric(8).upcase}" channel_id ||= "C#{SecureRandom.alphanumeric(8).upcase}" team_id ||= "T#{SecureRandom.alphanumeric(8).upcase}" user_id ||= "U#{SecureRandom.alphanumeric(8).upcase}" new( ok: true, access_token: "<token>", scope: "identify,incoming-webhook", user_id: user_id, team_name: "My Team", team_id: team_id, incoming_webhook: { channel: "#brutalism", channel_id: channel_id, configuration_url: "https://my-team.slack.com/services/#{bot_id}", url: "https://hooks.slack.com/services/#{team_id}/#{bot_id}/1234567890abcdef12345678", }, scopes: [ "identify", "incoming-webhook", ], ) end
Public Instance Methods
channel_id()
click to toggle source
# File lib/brutalismbot/slack/auth.rb, line 11 def channel_id @item.dig("incoming_webhook", "channel_id") end
inspect()
click to toggle source
# File lib/brutalismbot/slack/auth.rb, line 15 def inspect "#<#{self.class} #{team_id}/#{channel_id}>" end
path()
click to toggle source
# File lib/brutalismbot/slack/auth.rb, line 19 def path File.join("team=#{team_id}", "channel=#{channel_id}", "oauth.json") end
team_id()
click to toggle source
# File lib/brutalismbot/slack/auth.rb, line 23 def team_id @item["team_id"] || @item.dig("team", "id") end
team_name()
click to toggle source
# File lib/brutalismbot/slack/auth.rb, line 27 def team_name @item["team_name"] || @item.dig("team", "name") end
to_s3(bucket:nil, prefix:nil)
click to toggle source
# File lib/brutalismbot/slack/auth.rb, line 31 def to_s3(bucket:nil, prefix:nil) bucket ||= ENV["SLACK_S3_BUCKET"] || "brutalismbot" prefix ||= ENV["SLACK_S3_PREFIX"] || "data/v1/auths/" { bucket: bucket, key: File.join(*[prefix, path].compact), body: to_json, } end
webhook_url()
click to toggle source
# File lib/brutalismbot/slack/auth.rb, line 41 def webhook_url @item.dig("incoming_webhook", "url") end