Class: SlackProgress::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/slack-progress/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, channel_id, options = {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
# File 'lib/slack-progress/client.rb', line 10

def initialize(token, channel_id, options = {})
  raise ArgumentError, 'Token required' if token.nil?
  raise ArgumentError, 'Channel ID required' if channel_id.nil?

  @token = token
  @channel_id = channel_id
  @parsed_options   = OptionsParser.new(options).parse
end

Instance Attribute Details

#parsed_optionsObject (readonly)

Returns the value of attribute parsed_options.



8
9
10
# File 'lib/slack-progress/client.rb', line 8

def parsed_options
  @parsed_options
end

Instance Method Details

#update_progress(thread_id: nil, current_value:, max_value:) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/slack-progress/client.rb', line 19

def update_progress(thread_id: nil, current_value:, max_value:)
  message_builder = MessageBuilder.new(parsed_options.formatting_options)
  text = message_builder.build_message(current_value, max_value)

  connection = Connection.new(@token, @channel_id)
  connection.send_request(text, thread_id)
end