Class: Fastlane::Actions::IftttAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/ifttt.rb

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, method_missing, other_action, output, return_value, sh, step_text

Class Method Details

.authorsObject



69
70
71
# File 'lib/fastlane/actions/ifttt.rb', line 69

def self.authors
  ["vpolouchkine"]
end

.available_optionsObject



34
35
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
63
# File 'lib/fastlane/actions/ifttt.rb', line 34

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_key,
                                env_name: "IFTTT_API_KEY",
                                description: "API key",
                                verify_block: proc do |value|
                                  raise UI.error "No API key given, pass using `api_key: 'key'`" if value.to_s.empty?
                                end),
    FastlaneCore::ConfigItem.new(key: :event_name,
                                env_name: "IFTTT_EVENT_NAME",
                                description: "The name of the event that will be triggered",
                                verify_block: proc do |value|
                                  raise UI.error "No event name given, pass using `event_name: 'name'`" if value.to_s.empty?
                                end),
    FastlaneCore::ConfigItem.new(key: :value1,
                                 env_name: "IFTTT_VALUE1",
                                 description: "Extra data sent with the event",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :value2,
                                env_name: "IFTTT_VALUE2",
                                description: "Extra data sent with the event",
                                optional: true,
                                is_string: true),
    FastlaneCore::ConfigItem.new(key: :value3,
                                 env_name: "IFTTT_VALUE3",
                                 description: "Extra data sent with the event",
                                 optional: true,
                                 is_string: true)]
end

.descriptionObject



30
31
32
# File 'lib/fastlane/actions/ifttt.rb', line 30

def self.description
  "Connect to the IFTTT Maker Channel. https://ifttt.com/maker"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/fastlane/actions/ifttt.rb', line 65

def self.is_supported?(platform)
  true
end

.run(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/actions/ifttt.rb', line 4

def self.run(options)
  require "net/http"
  require "uri"

  uri = URI.parse("https://maker.ifttt.com/trigger/#{options[:event_name]}/with/key/#{options[:api_key]}")
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true

  req = Net::HTTP::Post.new(uri.request_uri)

  req.set_form_data({
    "value1" => options[:value1],
    "value2" => options[:value2],
    "value3" => options[:value3]
  })

  response = https.request(req)

  UI.user_error! "Failed to make a request to IFTTT. #{response.message}." unless response.code == "200"
  UI.success "Successfully made a request to IFTTT."
end