Class: RoboPigeon::Slack::Client
- Inherits:
-
Object
- Object
- RoboPigeon::Slack::Client
- Defined in:
- lib/robopigeon/slack/client.rb
Class Attribute Summary collapse
- .client ⇒ Object
-
.emoji ⇒ Object
Returns the value of attribute emoji.
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Class Attribute Details
.client ⇒ Object
12 13 14 15 16 |
# File 'lib/robopigeon/slack/client.rb', line 12 def client raise 'client requires API key be set' unless @client @client end |
.emoji ⇒ Object
Returns the value of attribute emoji.
10 11 12 |
# File 'lib/robopigeon/slack/client.rb', line 10 def emoji @emoji end |
.enabled ⇒ Object
Returns the value of attribute enabled.
10 11 12 |
# File 'lib/robopigeon/slack/client.rb', line 10 def enabled @enabled end |
.name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/robopigeon/slack/client.rb', line 10 def name @name end |
Class Method Details
.api_key ⇒ Object
20 21 22 23 24 |
# File 'lib/robopigeon/slack/client.rb', line 20 def api_key raise 'api_key requires API key be set' unless client.token client.token end |
.api_key=(api_key) ⇒ Object
26 27 28 |
# File 'lib/robopigeon/slack/client.rb', line 26 def api_key=(api_key) @client = Slack::Web::Client.new(token: api_key) end |
.get_user(search) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/robopigeon/slack/client.rb', line 30 def get_user(search) lookup = search.shift begin users = client.users_search(user: lookup.downcase).try(:members) unless lookup.nil? rescue ::Faraday::Error => e puts "Giving up on slack user lookup because the slack client raised a #{e.class}:\n#{e.}" users = nil end if users.nil? || users.empty? || users.length != 1 return nil if search.empty? get_user(search) else users.try(:first) end end |