forked from IntelliSOFT-Consulting/RapidPro-connector
-
Notifications
You must be signed in to change notification settings - Fork 1
/
api_requests.py
29 lines (25 loc) · 867 Bytes
/
api_requests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#API calls to the rapidpro server
import json
from abstract_request import AbstractSimpleRequest
from api_urls import CONTACTS_URL, BROADCASTS_URL, GROUPS_URL
def get_all_contacts():
""" Get all contacts from rapid pro"""
request = AbstractSimpleRequest(CONTACTS_URL)
response = request.get()
json_text = json.loads(response.text)
print json_text.get('results')
print len(json_text)
return json_text
def get_all_broadcasts():
""" Obtain broadcast json list from rapid Pro """
request = AbstractSimpleRequest(BROADCASTS_URL)
response = request.get()
json_text = json.loads(response.text)
print json_text
return json_text
def get_all_groups():
""" Obtain all groups"""
request = AbstractSimpleRequest(GROUPS_URL)
response = request.get()
json_text = json.loads(response.text)
return json_text