Module: Piped
- Defined in:
- lib/piped.rb,
lib/piped/version.rb
Constant Summary collapse
- REQUEST_TIMEOUT =
60
- OPEN_TIMEOUT =
5
- VERSION =
"0.1.4"
- @@api_key =
"SET_YOUR_API_KEY"
- @@piped_host =
Optional
nil
Class Method Summary collapse
- .api_key=(key) ⇒ Object
- .pipeman_host ⇒ Object
- .pipeman_host=(host) ⇒ Object
- .push(options = {}) ⇒ Object
Class Method Details
.api_key=(key) ⇒ Object
12 13 14 |
# File 'lib/piped.rb', line 12 def self.api_key=(key) @@api_key = key end |
.pipeman_host ⇒ Object
20 21 22 |
# File 'lib/piped.rb', line 20 def self.pipeman_host @@pipeman_host ||= "https://pipeman.edmodo.com" end |
.pipeman_host=(host) ⇒ Object
16 17 18 |
# File 'lib/piped.rb', line 16 def self.pipeman_host=(host) @@pipeman_host = host end |
.push(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/piped.rb', line 25 def self.push(={}) api_key = .delete(:api_key) || @@api_key host = .delete(:pipeman_host) || self.pipeman_host response = RestClient::Request.execute( method: :post, url: "#{host}/events", payload: JSON.generate(), headers: {"Authorization" => "Bearer #{api_key}", :content_type => :json, :accept => :json}, timeout: REQUEST_TIMEOUT, open_timeout: OPEN_TIMEOUT ) Hashie::Mash.new(JSON.parse(response)) end |