Class: TransparencyCorps

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

Constant Summary collapse

COMPLETE_PATH =
'/tasks/complete'
NEW_TASK_PARAMS =
{:new_task => 1}
@@url =
'http://transparencycorps.org'

Class Method Summary collapse

Class Method Details

.complete_task(task_key, reassign = false) ⇒ Object



27
28
29
30
31
# File 'lib/transparency_corps.rb', line 27

def self.complete_task(task_key, reassign = false)
  params = {:task_key => task_key}
  params.merge! NEW_TASK_PARAMS if reassign
  Net::HTTP.post_form URI.join(url, COMPLETE_PATH), params
end

.complete_task_and_reassign(task_key) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/transparency_corps.rb', line 18

def self.complete_task_and_reassign(task_key)
  response = complete_task task_key, true
  if response.body and response.body.strip.any?
    response.body
  else
    false
  end
end

.urlObject



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

def self.url
  @@url
end

.url=(url) ⇒ Object



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

def self.url=(url)
  @@url = url
end