Module: Piped

Defined in:
lib/piped.rb,
lib/piped/version.rb

Constant Summary collapse

VERSION =
"0.1.1"
@@api_key =
"SET_YOUR_API_KEY"
@@piped_host =

Optional

nil

Class Method Summary collapse

Class Method Details

.api_key=(key) ⇒ Object



10
11
12
# File 'lib/piped.rb', line 10

def self.api_key=(key)
  @@api_key = key
end

.pipeman_hostObject



18
19
20
# File 'lib/piped.rb', line 18

def self.pipeman_host
  @@pipeman_host ||= "https://pipeman.edmodo.com"
end

.pipeman_host=(host) ⇒ Object



14
15
16
# File 'lib/piped.rb', line 14

def self.pipeman_host=(host)
  @@pipeman_host = host
end

.push(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/piped.rb', line 23

def self.push(options={})
  api_key = options.delete(:api_key) || @@api_key
  response = RestClient.post(
    "#{self.pipeman_host}/events",
    JSON.generate(options),
    {"Authorization" => "Bearer #{api_key}", :content_type => :json, :accept => :json}
  )
  Hashie::Mash.new(JSON.parse(response))
end