Class: Codebot::Options::Integration

Inherits:
Thor
  • Object
show all
Defined in:
lib/codebot/options/integration.rb

Overview

A class that handles the codebot integration command.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Ensures that thor uses the correct exit code.

Returns:

  • (Boolean)

    true



84
85
86
# File 'lib/codebot/options/integration.rb', line 84

def self.exit_on_failure?
  true
end

.shared_propery_optionsObject

Sets shared options for specifying properties belonging to the Integration class.



13
14
15
16
17
18
# File 'lib/codebot/options/integration.rb', line 13

def self.shared_propery_options
  option :endpoint, aliases: '-e',
                    desc: 'Set the endpoint for incoming webhooks'
  option :secret, aliases: '-s',
                  desc: 'Set the secret for verifying webhook payloads'
end

Instance Method Details

#create(name) ⇒ Object

Creates a new integration with the specified name.

Parameters:

  • name (String)

    the name of the new integration



28
29
30
31
32
33
# File 'lib/codebot/options/integration.rb', line 28

def create(name)
  Options.with_core(parent_options, true) do |core|
    map_channels!(options, :channels)
    IntegrationManager.new(core.config).create(options.merge(name: name))
  end
end

#destroy(name) ⇒ Object

Destroys the integration with the specified name.

Parameters:

  • name (String)

    the name of the integration



63
64
65
66
67
# File 'lib/codebot/options/integration.rb', line 63

def destroy(name)
  Options.with_core(parent_options, true) do |core|
    IntegrationManager.new(core.config).destroy(name, options)
  end
end

#list(search = nil) ⇒ Object

Lists all integrations, or integrations with names containing the given search term.

Parameters:

  • search (String, nil) (defaults to: nil)

    an optional search term



75
76
77
78
79
# File 'lib/codebot/options/integration.rb', line 75

def list(search = nil)
  Options.with_core(parent_options, true) do |core|
    IntegrationManager.new(core.config).list(search)
  end
end

#update(name) ⇒ Object

Updates the integration with the specified name.

Parameters:

  • name (String)

    the name of the integration



51
52
53
54
55
56
# File 'lib/codebot/options/integration.rb', line 51

def update(name)
  Options.with_core(parent_options, true) do |core|
    map_channels!(options, :add_channel)
    IntegrationManager.new(core.config).update(name, options)
  end
end