Class: Speedflow::Plugin::Flowdock::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/speedflow/plugin/flowdock/client.rb

Overview

Flowdock client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, prompt) ⇒ Client

Initialize.

config - Speedflow::Plugin::Flowdock::Configuration instance. prompt - Speedflow::Plugin::Flowdock::Prompt instance.

Examples

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

Returns nothing.



25
26
27
28
# File 'lib/speedflow/plugin/flowdock/client.rb', line 25

def initialize(config, prompt)
  @config = config
  @prompt = prompt
end

Instance Attribute Details

#flowdock_clientObject

Public: Flowdock client.

Returns ::Flowdock::Client instance.



58
59
60
# File 'lib/speedflow/plugin/flowdock/client.rb', line 58

def flowdock_client
  @flowdock_client ||= ::Flowdock::Client.new(@config.auth)
end

#promptObject

Public: Prompt.

Returns ::Speedflow::Plugin::Flowdock::Prompt instance.



65
66
67
# File 'lib/speedflow/plugin/flowdock/client.rb', line 65

def prompt
  @prompt ||= ::Speedflow::Plugin::Flowdock::Prompt.new
end

Instance Method Details

#notify(flow_id, message, tags) ⇒ Object

Public: Notify.

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

Returns nothing.



37
38
39
40
41
42
43
# File 'lib/speedflow/plugin/flowdock/client.rb', line 37

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

#safeObject

Public: Safe process Flowdock action.

Returns nothing.



48
49
50
51
52
53
# File 'lib/speedflow/plugin/flowdock/client.rb', line 48

def safe
  yield
rescue ::Flowdock::ApiError => exception
  prompt.errors exception
  abort
end