Class: Deadlinez::Api

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/deadlinez/api.rb

Constant Summary collapse

REQUIRED_HEADERS =
{
  'Host' => 'service.afterthedeadline.com',
  'Content-Type' => 'application/x-www-form-urlencoded',
  'User-Agent' => 'AtD/0.1'
}

Class Method Summary collapse

Class Method Details

.proxy(path, params) ⇒ Object

Proxies any URL through to AtD. Useful for the TinyMCE plugin.



15
16
17
18
19
20
21
22
# File 'lib/deadlinez/api.rb', line 15

def self.proxy(path, params)
  proxy_params = Deadlinez::Proxy.strip_params(params)
  response = post(path,
                  :body => proxy_params,
                  :format => nil,
                  :headers => REQUIRED_HEADERS)
  response.body
end

.stats(data) ⇒ Object



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

def self.stats(data)
  response = post('/stats',
                 :body => {
                   :data => data
                 },
                 :headers => REQUIRED_HEADERS)
  response['scores']['metric']
end