Class: Fastlane::Actions::IftttAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



72
73
74
# File 'fastlane/lib/fastlane/actions/ifttt.rb', line 72

def self.authors
  ["vpolouchkine"]
end

.available_optionsObject



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
64
65
66
# File 'fastlane/lib/fastlane/actions/ifttt.rb', line 38

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_key,
                                env_name: "IFTTT_API_KEY",
                                sensitive: true,
                                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),
    FastlaneCore::ConfigItem.new(key: :value2,
                                env_name: "IFTTT_VALUE2",
                                description: "Extra data sent with the event",
                                optional: true),
    FastlaneCore::ConfigItem.new(key: :value3,
                                 env_name: "IFTTT_VALUE3",
                                 description: "Extra data sent with the event",
                                 optional: true)
  ]
end

.categoryObject



88
89
90
# File 'fastlane/lib/fastlane/actions/ifttt.rb', line 88

def self.category
  :notifications
end

.descriptionObject



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

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

.detailsObject



34
35
36
# File 'fastlane/lib/fastlane/actions/ifttt.rb', line 34

def self.details
  "Connect to the IFTTT [Maker Channel](https://ifttt.com/maker). An IFTTT Recipe has two components: a Trigger and an Action. In this case, the Trigger will fire every time the Maker Channel receives a web request (made by this _fastlane_ action) to notify it of an event. The Action can be anything that IFTTT supports: email, SMS, etc."
end

.example_codeObject



76
77
78
79
80
81
82
83
84
85
86
# File 'fastlane/lib/fastlane/actions/ifttt.rb', line 76

def self.example_code
  [
    'ifttt(
      api_key: "...",
      event_name: "...",
      value1: "foo",
      value2: "bar",
      value3: "baz"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



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

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 'fastlane/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