项目作者: rahmonov

项目描述 :
Python library for AgileCRM API
高级语言: Python
项目地址: git://github.com/rahmonov/agile-crm-python.git
创建时间: 2017-06-27T06:28:05Z
项目社区:https://github.com/rahmonov/agile-crm-python

开源协议:MIT License

下载


Agile CRM

A Python interface for the Agile CRM API.

Installation

  1. $ pip install agile-crm-python

Usage

  1. In [1]: from agilecrm import AgileCRM
  2. In [2]: EMAIL = 'your_email'
  3. ...: API_KEY = 'agilecrm_api_key'
  4. ...: DOMAIN = 'your_domain'
  5. In [3]: agile_client = AgileCRM(DOMAIN, EMAIL, API_KEY)
  6. In [4]: print(agile_client.contact.fetch('5649050225344512'))
  7. {'data': {'klout_score': '', 'is_duplicate_existed': False, 'properties': [{'type': 'SYSTEM', 'value': 'Baqsssaasdf2', 'name': 'first_name'}, {'type': 'SYSTEM', 'value': 'SomeCompany', 'name': 'company'}, {'type': 'SYSTEM', 'value': '+998934979894', 'name': 'phone'}, {'type': 'CUSTOM', 'value': 'SuperSource', 'name': 'Captured Source'}, {'type': 'SYSTEM', 'value': 'jrahmonov2@gmail.com', 'name': 'email'}], 'star_value': 4, 'created_time': 1498828722, 'lead_status_id': 0, 'last_emailed': 0, 'owner': {'email': 'jahongir@superdispatch.com', 'calendar_url': 'https://jahongir.agilecrm.com/calendar/Jahongir_Rahmonov', 'phone': '', 'id': 4840599839309824, 'calendarURL': 'https://jahongir.agilecrm.com/calendar/Jahongir_Rahmonov', 'name': 'Jahongir Rahmonov', 'pic': 'https://d1gwclp1pmzk26.cloudfront.net/img/gravatar/48.png', 'domain': 'jahongir', 'schedule_id': 'Jahongir_Rahmonov'}, 'entity_type': 'contact_entity', 'lead_score': 34, 'lead_converted_time': 0, 'browserId': [], 'id': 5649050225344512, 'is_lead_converted': False, 'updated_time': 1498854662, 'tags': ['ios', 'awesome'], 'is_client_import': False, 'last_called': 0, 'trashed_time': 0, 'type': 'PERSON', 'source': 'api', 'lead_source_id': 0, 'unsubscribeStatus': [], 'restored_time': 0, 'contact_company_id': '5714163003293696', 'tagsWithTime': [{'entity_type': 'tag', 'availableCount': 0, 'createdTime': 1498829643106, 'tag': 'ios'}, {'entity_type': 'tag', 'availableCount': 0, 'createdTime': 1498830015686, 'tag': 'awesome'}], 'emailBounceStatus': [], 'last_contacted': 0, 'is_duplicate_verification_failed': False, 'viewed': {'viewed_time': 1500654861002, 'viewer_id': 4840599839309824}, 'formId': 0, 'campaignStatus': [], 'viewed_time': 0, 'last_campaign_emaild': 0}, 'text': None, 'ok': True, 'status_code': 200}

Documentation

Table of contents

1 Contact

2 Company

3 Deal

  1. All the following examples assume that you have agile_client configured as shown above

1. Contact

1.1 Create a contact
  1. contact_data = {
  2. "star_value": "4",
  3. "lead_score": "92",
  4. "tags": [
  5. "Lead",
  6. "Likely Buyer"
  7. ],
  8. "properties": [
  9. {
  10. "type": "SYSTEM",
  11. "name": "first_name",
  12. "value": "Los "
  13. },
  14. {
  15. "type": "SYSTEM",
  16. "name": "last_name",
  17. "value": "Bruikheilmer"
  18. },
  19. {
  20. "type": "SYSTEM",
  21. "name": "company",
  22. "value": "steady.inc"
  23. },
  24. {
  25. "type": "SYSTEM",
  26. "name": "email",
  27. "subtype": "work",
  28. "value": "akrambakram@yabba.com"
  29. },
  30. {
  31. "type": "CUSTOM",
  32. "name": "My Custom Field",
  33. "value": "Custom value"
  34. }
  35. ]
  36. }
  37. response = agile_client.contact.create(contact_data)
1.2 Fetch a contact by id
  1. response = agile_client.contact.fetch('5649050225344512')
1.3 Delete a contact by id
  1. response = agile_client.contact.delete('5649050225344512')
1.4 Update a contact by id
  1. new_contact_data = {
  2. "properties": [
  3. {
  4. "type": "SYSTEM",
  5. "name": "last_name",
  6. "value": "Chan"
  7. },
  8. {
  9. "type": "CUSTOM",
  10. "name": "My Custom Field",
  11. "value": "Custom value change"
  12. }
  13. ]
  14. }
  15. response = agile_client.contact.update('5689413791121408', new_contact_data)
1.5 Set a lead score for a contact
  1. response = agile_client.contact.set_lead_score(contact_id='5689413791121408', lead_score=100)
1.6 Set a star value for a contact
  1. response = agile_client.contact.set_star_value(contact_id='5689413791121408', star_value=3)
1.7 Add a tag to a contact
  1. response = agile_client.contact.set_tags(contact_id='5689413791121408', tags=['new_tag'])
1.8 Remove a tag from a contact
  1. response = agile_client.contact.remove_tags(contact_id='5689413791121408', tags_to_remove=['new_tag'])
1.9 Search for a contact
  1. response = agile_client.contact.find(q='los', page_size=15)
1.10 Add a note to a contact
  1. response = agile_client.contact.add_notes(contact_id='5689413791121408', subject='Note Subject', description='Some Note')
1.11 Get notes of a contact
  1. response = agile_client.contact.get_notes(contact_id='5689413791121408')
1.12 Delete a note of a contact
  1. respose = agile_client.contact.delete_note(contact_id='5689413791121408', note_id='5755685136498688')

2. Company

2.1 Create a company
  1. company_data = {
  2. "type": "COMPANY",
  3. "star_value": 4,
  4. "lead_score": 120,
  5. "tags": [
  6. "Permanent",
  7. "USA",
  8. ],
  9. "properties": [
  10. {
  11. "name": "Company Type",
  12. "type": "CUSTOM",
  13. "value": "MNC Inc"
  14. },
  15. {
  16. "type": "SYSTEM",
  17. "name": "name",
  18. "value": "Spicejet"
  19. },
  20. {
  21. "type": "SYSTEM",
  22. "name": "url",
  23. "value": "http://www.spicejet.com/"
  24. },
  25. {
  26. "name": "email",
  27. "value": "care@spicejet.com ",
  28. "subtype": ""
  29. },
  30. {
  31. "name": "phone",
  32. "value": "45500000",
  33. "subtype": ""
  34. },
  35. {
  36. "name": "website",
  37. "value": "http://www.linkedin.com/company/agile-crm",
  38. "subtype": "LINKEDIN"
  39. },
  40. {
  41. "name": "address",
  42. "value": "{\"address\":\"MS 35, 440 N Wolfe Road\",\"city\":\"Sunnyvale\",\"state\":\"CA\",\"zip\":\"94085\",\"country\":\"US\"}",
  43. "subtype": "office"
  44. }
  45. ]
  46. }
  47. response = agile_client.company.create(company_data)
2.2 Fetch a company by id
  1. respose = agile_client.company.fetch('5712536552865792')
2.3 Update a company by id
  1. new_company_data = {
  2. "properties": [
  3. {
  4. "type": "SYSTEM",
  5. "name": "name",
  6. "value": "SPICE JET"
  7. },
  8. {
  9. "type": "SYSTEM",
  10. "name": "url",
  11. "value": "http://www.spicejet.com/"
  12. },
  13. {
  14. "name": "phone",
  15. "value": "45500000",
  16. "subtype": ""
  17. }
  18. ]
  19. }
  20. response = agile_client.company.update('5712536552865792', new_company_data)
2.4 Delete a company by id
  1. response = agile_client.company.delete('5712536552865792')

3. Deal

3.1 Create a deal