class Speedflow::Plugin::Flowdock::Client

Flowdock client

Attributes

config[R]

@return [Speedflow::Plugin::Configuration] Plugin configuration.

flowdock_client[W]

@return [Flowdock::Client] Flowdock client.

prompt[R]

@return [Speedflow::Plugin::Prompt] Plugin prompt.

Public Class Methods

new(config, prompt) click to toggle source

Initialize.

config - <Speedflow::Plugin::Configuration> instance. prompt - <Speedflow::Plugin::Prompt> instance.

Examples

Client.new({}, Speedflow::Plugin::Prompt.new)
# => <Speedflow::Plugin::Flowdock::Client>

Returns nothing.

# File lib/speedflow/plugin/flowdock/client.rb, line 28
def initialize(config, prompt)
  @config = config
  @prompt = prompt
end

Public Instance Methods

flowdock_client() click to toggle source

Public: Flowdock client.

Returns <::Flowdock::Client> instance.

# File lib/speedflow/plugin/flowdock/client.rb, line 61
def flowdock_client
  config = { api_token: @config.by_config('token') }
  @flowdock_client ||= ::Flowdock::Client.new(config)
end
notify(flow_id, message, tags) click to toggle source

Public: Notify.

flow_id - Flow ID. message - String of message. tags - Array of tags / Just add “Speedflow” tags 8-).

Returns nothing.

# File lib/speedflow/plugin/flowdock/client.rb, line 40
def notify(flow_id, message, tags)
  safe do
    tags = ['Speedflow'].concat(tags)
    flowdock_client.chat_message(
      flow: flow_id, content: message, tags: tags)
  end
end
safe() { || ... } click to toggle source

Public: Safe process Flowdock action.

Returns nothing.

# File lib/speedflow/plugin/flowdock/client.rb, line 51
def safe
  yield
rescue ::Flowdock::ApiError => exception
  prompt.errors 'Flowdock', exception
  abort
end