Class: Fastlane::Actions::HallAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::HallAction
- Defined in:
- lib/fastlane/actions/hall.rb
Documentation collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
Class Method Summary collapse
Methods inherited from Fastlane::Action
Class Method Details
.author ⇒ Object
89 90 91 |
# File 'lib/fastlane/actions/hall.rb', line 89 def self. 'eytanbiala' end |
.available_options ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fastlane/actions/hall.rb', line 58 def self. [ FastlaneCore::ConfigItem.new(key: :title, env_name: "FL_HALL_TITLE", description: "The title for the message. Plain text, HTML tags will be stripped", default_value: 'fastlane'), FastlaneCore::ConfigItem.new(key: :message, env_name: "FL_HALL_MESSAGE", description: "The message to post on the Hall group. May contain a restricted set of HTML tags (https://hall.com/docs/integrations/generic)", default_value: ''), FastlaneCore::ConfigItem.new(key: :picture, env_name: "FL_HALL_PICTURE", description: "URL to an image file, which will be displayed next to your notification message", default_value: 'https://s3-eu-west-1.amazonaws.com/fastlane.tools/fastlane.png'), FastlaneCore::ConfigItem.new(key: :group_api_token, env_name: "HALL_GROUP_API_TOKEN", description: "Hall Group API Token", verify_block: Proc.new do |value| unless value.to_s.length > 0 Helper.log.fatal "Please add 'ENV[\"HALL_GROUP_API_TOKEN\"] = \"your token\"' to your Fastfile's `before_all` section.".red raise 'No HALL_GROUP_API_TOKEN given.'.red end end) ] end |
.check_response_code(response) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fastlane/actions/hall.rb', line 37 def self.check_response_code(response) case response.code.to_i when 200, 201, 204 true when 404 raise "Not found".red when 401 raise "Access denied".red else raise "Unexpected #{response.code}".red end end |
.description ⇒ Object
54 55 56 |
# File 'lib/fastlane/actions/hall.rb', line 54 def self.description "Post a message to Hall (https://hall.com/)" end |
.is_supported?(platform) ⇒ Boolean
93 94 95 |
# File 'lib/fastlane/actions/hall.rb', line 93 def self.is_supported?(platform) true end |
.output ⇒ Object
84 85 86 87 |
# File 'lib/fastlane/actions/hall.rb', line 84 def self.output [ ] end |
.run(options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fastlane/actions/hall.rb', line 7 def self.run() require 'net/http' require 'uri' group_api_token = [:group_api_token] title = [:title] = [:message] picture = [:picture] body = {"title" => title, "message" => , "picture" => picture} uri = URI.parse("https://hall.com/api/1/services/generic/#{group_api_token}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true req = Net::HTTP::Post.new(uri.path, initheader = {"Content-Type" =>"application/json", "Accept" => "application/json"}) req.body = body.to_json return [uri.to_s, body] if Helper.is_test? # tests will verify the url and body res = http.request(req) check_response_code(res) Helper.log.info "Posted message to Hall 🎯." end |