Class: Ushahidi

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

Defined Under Namespace

Classes: Incident, Report

Constant Summary collapse

@@api_base =
nil

Class Method Summary collapse

Class Method Details

.api_baseObject



56
57
58
# File 'lib/ushahidi.rb', line 56

def self.api_base
  @@api_base
end

.api_base=(x) ⇒ Object



60
61
62
# File 'lib/ushahidi.rb', line 60

def self.api_base=(x)
  @@api_base = x
end

.post(x) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/ushahidi.rb', line 64

def self.post(x)
  raise "No api base" unless @@api_base
  raise "Can only post report" unless x.is_a? Report

  h = x.to_params_hash

  h["task"] = "report"

  RestClient.post(@@api_base, h)
end

.unapproved_report_idsObject



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/ushahidi.rb', line 75

def self.unapproved_report_ids
  raise "No api base" unless @@api_base

  res = RestClient.post(@@api_base, {
      :task => "reports",
      :by => "unapproved"
    })

  r = JSON.parse(res)

  return r["payload"]["incidents"].map { |x| x["incident"]["incidentid"].to_i }
end