Class: Fastlane::Actions::SqCiToolsSendMaxMessageAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



64
65
66
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb', line 64

def self.authors
  ['Semen Kologrivov']
end

.available_optionsObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb', line 48

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :message,
      description: 'Message for send',
      optional: false,
      type: String
    )
  ] +
    Options::Max.options
end

.descriptionObject



40
41
42
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb', line 40

def self.description
  'Send message via Max'
end

.detailsObject



44
45
46
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb', line 44

def self.details
  ''
end

.is_supported?(_) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb', line 68

def self.is_supported?(_)
  true
end

.return_valueObject



60
61
62
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb', line 60

def self.return_value
  ''
end

.run(params) ⇒ Object



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
36
37
38
# File 'lib/fastlane/plugin/sq_ci_tools/actions/sq_ci_tools_send_max_message_action.rb', line 10

def self.run(params)
  access_token = params[:max_access_token]
  chat_ids = params[:max_chat_ids]
  if access_token.nil? || access_token == "" || chat_ids.nil? || chat_ids == ""
    return
  end
  puts params

  chat_ids.split(',').each do |chat_id|
    uri = URI.parse("https://platform-api.max.ru")

    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.set_debug_output($stdout)

    request = Net::HTTP::Post.new("/messages?chat_id=#{chat_id}")
    request.add_field('Content-Type', 'application/json')
    request.add_field('Authorization', access_token)
    request.body = {
      "text" => params[:message],
      "format" => params[:max_format]
    }.to_json
    response = http.request(request)

    puts response
    puts response.message
    puts response.body
  end
end