Class: Fastlane::Actions::FetchFilesSlackAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::FetchFilesSlackAction
- Defined in:
- lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(options) ⇒ Object
Class Method Details
.authors ⇒ Object
64 65 66 |
# File 'lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb', line 64 def self. ["crazymanish"] end |
.available_options ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb', line 36 def self. [ FastlaneCore::ConfigItem.new(key: :api_token, env_name: "FL_FETCH_FILES_SLACK_BOT_TOKEN", description: "Slack bot Token", sensitive: true, code_gen_sensitive: true, is_string: true, default_value: ENV["SLACK_API_TOKEN"], default_value_dynamic: true, optional: false), FastlaneCore::ConfigItem.new(key: :channel, env_name: "FL_FETCH_FILES_SLACK_CHANNEL", description: "slack #channel ID", optional: false), FastlaneCore::ConfigItem.new(key: :count, env_name: "FL_FETCH_FILES_SLACK_COUNT", description: "Number of items to return per page, default value: 100", default_value: "100", optional: true), FastlaneCore::ConfigItem.new(key: :page, env_name: "FL_FETCH_FILES_SLACK_PAGE", description: "Page number of results to return, default value: 1", default_value: "1", optional: true) ] end |
.description ⇒ Object
32 33 34 |
# File 'lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb', line 32 def self.description "List files of any #channel using Slack bot `files.list` api." end |
.example_code ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb', line 68 def self.example_code [ 'fetch_files_slack(channel: "CHXYMXXXX")', 'fetch_files_slack(channel: "CHXYMXXXX", count: "10")', 'fetch_files_slack(channel: "CHXYMXXXX", count: "10", page: "2")' ] end |
.is_supported?(platform) ⇒ Boolean
76 77 78 |
# File 'lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb', line 76 def self.is_supported?(platform) true end |
.run(options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb', line 10 def self.run() require 'excon' require 'json' api_url = "https://slack.com/api/files.list" headers = { "Content-Type": "application/json", "Authorization": "Bearer #{[:api_token]}" } query = { channel: [:channel], count: [:count], page: [:page] } response = Excon.get(api_url, headers: headers, query: query) status_code = response[:status] UI.user_error!("Response body is nil, status code: #{status_code} 💥") if response.body.nil? result = { status: status_code, body: response.body, json: JSON.parse(response.body) } Actions.lane_context[SharedValues::FETCH_FILES_SLACK_RESULT] = result return result end |