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::Configuration> instance. prompt - <Speedflow::Plugin::Prompt> instance.

Examples

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

Returns nothing.



28
29
30
31
# File 'lib/speedflow/plugin/flowdock/client.rb', line 28

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

Instance Attribute Details

#configSpeedflow::Plugin::Configuration (readonly)

Returns Plugin configuration.

Returns:

  • (Speedflow::Plugin::Configuration)

    Plugin configuration.



9
10
11
# File 'lib/speedflow/plugin/flowdock/client.rb', line 9

def config
  @config
end

#flowdock_clientObject

Public: Flowdock client.

Returns <::Flowdock::Client> instance.



61
62
63
64
# 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

#promptSpeedflow::Plugin::Prompt (readonly)

Returns Plugin prompt.

Returns:

  • (Speedflow::Plugin::Prompt)

    Plugin prompt.



12
13
14
# File 'lib/speedflow/plugin/flowdock/client.rb', line 12

def prompt
  @prompt
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.



40
41
42
43
44
45
46
# 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

#safeObject

Public: Safe process Flowdock action.

Returns nothing.



51
52
53
54
55
56
# File 'lib/speedflow/plugin/flowdock/client.rb', line 51

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