Class: Fastlane::Actions::TypetalkAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::TypetalkAction
- Defined in:
- lib/fastlane/actions/typetalk.rb
Class Method Summary collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .check_response(response) ⇒ Object
- .description ⇒ Object
- .post_to_typetalk(message, topicId, typetalk_token) ⇒ Object
- .run(params) ⇒ Object
Methods inherited from Fastlane::Action
Class Method Details
.author ⇒ Object
68 69 70 |
# File 'lib/fastlane/actions/typetalk.rb', line 68 def self. "dataich" end |
.available_options ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/fastlane/actions/typetalk.rb', line 58 def self. [ ['message', 'The message to post'], ['note_path', 'Path to a md file'], ['topicId', ''], ['success', 'Successful build?'], ['typetalk_token', 'API token'] ] end |
.check_response(response) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/fastlane/actions/typetalk.rb', line 45 def self.check_response(response) case response.code.to_i when 200, 204 true else raise "Could not sent Typetalk notification".red end end |
.description ⇒ Object
54 55 56 |
# File 'lib/fastlane/actions/typetalk.rb', line 54 def self.description "Post a message to Typetalk" end |
.post_to_typetalk(message, topicId, typetalk_token) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fastlane/actions/typetalk.rb', line 34 def self.post_to_typetalk(, topicId, typetalk_token) require 'net/http' require 'uri' uri = URI.parse("https://typetalk.in/api/v1/topics/#{topicId}") response = Net::HTTP.post_form(uri, {'message' => , 'typetalkToken' => typetalk_token}) self.check_response(response) end |
.run(params) ⇒ Object
4 5 6 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 |
# File 'lib/fastlane/actions/typetalk.rb', line 4 def self.run(params) = { message: nil, note_path: nil, success: true, topicId: nil, typetalk_token: nil, }.merge(params.first || {}) [:message, :topicId, :typetalk_token].each { |key| raise "No #{key} given.".red unless [key] } emoticon = ([:success] ? ':smile:' : ':rage:') = "#{emoticon} #{[:message].to_s}" note_path = File.([:note_path]) if [:note_path] if note_path and File.exist?(note_path) contents = File.read(note_path) += "\n\n```\n#{contents}\n```" end topicId = [:topicId] typetalk_token = [:typetalk_token] self.post_to_typetalk(, topicId, typetalk_token) Helper.log.info 'Successfully sent Typetalk notification'.green end |