class Fastlane::Actions::FeishuBotAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 55 def self.available_options [ # FastlaneCore::ConfigItem.new(key: :your_option, # env_name: "FEISHU_BOT_YOUR_OPTION", # description: "A description of your option", # optional: false, # type: String) ] end
check_response(response)
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 29 def self.check_response(response) case response.code.to_i when 200, 204 true else UI.user_error!("Could not sent Feishu notification, code: #{response.code.to_i}") end end
description()
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 38 def self.description "A fastlane plugin to customize your automation workflow(s) with a Feishu Bot" end
details()
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 50 def self.details # Optional: "A fastlane plugin to customize your automation workflow(s) with a Feishu Bot" end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 65 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform # # [:ios, :mac, :android].include?(platform) true end
post_to_feishu(token, title, content)
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 15 def self.post_to_feishu(token, title, content) require 'uri' require 'json' require 'net/http' uri = URI.parse("https://open.feishu.cn/open-apis/bot/hook/#{token}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.to_s, 'Content-Type' => 'application/json') request.body = {title: title, text: content}.to_json response = http.request(request) UI.message "Api token: #{uri}" self.check_response(response) end
return_value()
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 46 def self.return_value # If your method provides a return value, you can describe here what it does end
run(params)
click to toggle source
# File lib/fastlane/plugin/feishu_bot/actions/feishu_bot_action.rb, line 7 def self.run(params) UI.message("The feishu_bot plugin is working!") UI.message "Api token: #{params[:api_token]}" UI.message "Notification title: #{params[:title]}" UI.message "Notification content: #{params[:content]}" self.post_to_feishu(params[:api_token], params[:title], params[:content]) end