Class: WeThePeople::Simple

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

Class Method Summary collapse

Class Method Details

.get(path, params = {}) ⇒ Object



32
33
34
35
# File 'lib/we_the_people/simple.rb', line 32

def get(path, params = {})
  response = WeThePeople::Config.client.get(url(path), :params => params.merge(WeThePeople::Config.default_params))
  WeThePeople::Config.json.parse(response.body)['results']
end

.petition(id) ⇒ Object



8
9
10
# File 'lib/we_the_people/simple.rb', line 8

def petition(id)
  get("petitions/#{id}.json").first
end

.petitions(criteria = {}) ⇒ Object



4
5
6
# File 'lib/we_the_people/simple.rb', line 4

def petitions(criteria = {})
  get("petitions.json", criteria)
end

.signature(petition_id, signature_id) ⇒ Object



16
17
18
# File 'lib/we_the_people/simple.rb', line 16

def signature(petition_id, signature_id)
  get("petitions/#{petition_id}/signatures/#{signature_id}.json").first
end

.signatures(petition_id, criteria = {}) ⇒ Object



12
13
14
# File 'lib/we_the_people/simple.rb', line 12

def signatures(petition_id, criteria = {})
  get("petitions/#{petition_id}/signatures.json", criteria)
end

.url(path) ⇒ Object



28
29
30
# File 'lib/we_the_people/simple.rb', line 28

def url(path)
  "#{WeThePeople::Config.host}/#{path}"
end

.user(id) ⇒ Object



24
25
26
# File 'lib/we_the_people/simple.rb', line 24

def user(id)
  get("users/#{id}.json").first
end

.users(criteria = {}) ⇒ Object



20
21
22
# File 'lib/we_the_people/simple.rb', line 20

def users(criteria = {})
  get("users.json", criteria)
end