Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. def parse_contact_data(json_data, results, THINGAMAJIG, API_KEY):
  2. params = { "access_token": API_KEY }
  3. for d in json_data['results']:
  4. if results != []:
  5. results.append([d['person_id'], d['note'], d['path_id'], d['step_id'], d['created_at']])
  6. if json_data['next']:
  7. r = requests.get(endpoint(json_data['next'], THINGAMAJIG), params=params)
  8. next_json_data = json.loads(r.text)
  9. parse_contact_data(next_json_data,results, THINGAMAJIG, API_KEY)
  10. return results
  11.  
  12. def get_contact_notes(THINGAMAJIG, API_KEY, ids_of_those_tagged):
  13. results = []
  14. for each in ids_of_those_tagged:
  15. try:
  16. url = 'https://'+THINGAMAJIG+'.THINGAMAJIGbuilder.com/api/v1/contacts?person_id=' + str(each)
  17. contact_response = requests.get(url, params=params)
  18. #if contact_response.text != []
  19. print(contact_response.json())
  20.  
  21. json_data = json.loads(contact_response.text)
  22.  
  23. full_result = parse_contact_data(json_data, results, THINGAMAJIG, API_KEY)
  24.  
  25. except requests.exceptions.ConnectionError:
  26. print("Error reaching THINGAMAJIGbuilder")
  27. print(results)
  28. return results
  29.  
  30. contact_notes = get_contact_notes(THINGAMAJIG, API_KEY, ids_of_those_tagged)
  31.  
  32. print("done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement