Class: Firebell::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/firebell/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token = Firebell.configuration.token) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/firebell/client.rb', line 6

def initialize(token = Firebell.configuration.token)
  @token = token
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/firebell/client.rb', line 4

def token
  @token
end

Instance Method Details

#notify(tag, body_or_params = nil, body = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/firebell/client.rb', line 10

def notify(tag, body_or_params = nil, body = nil)
  if body_or_params
    if body_or_params.is_a?(Hash)
      attributes = { "tag" => tag, "parameters" => body_or_params }
      attributes.merge!("body" => body) if body
    else
      attributes = { "tag" => tag, "body" => body_or_params }
    end
  else
    attributes = { "tag" => tag }
  end

  send_request attributes if requestable?
end