Agile CRM is a new breed CRM software with sales and marketing automation.
- 1 To create a contact
- 2 To fetch contact data
- 3 To delete a contact
- 4 To update a contact
- 5 To update star value
- 6 To update lead score
- 7 Update tags by contact id
- 8 Delete tags by contact id
- 1 To create a company
- 2 To get a company
- 3 To delete a company
- 4 To update a company
- 5 Search Contacts/Companies
##Intro
-
Fill in your api_key, domain, email in agilecrm.rb.
-
Copy and paste the code from below to agilecrm.rb which you want to test. For test purpose contact's all test case copied in agilecrm.rb file all ready, Just uncomment the code want to test.
-
You need to provide 3 paramaters to the agilecrm.rb function. They are method, api path, content data.
##Requirements
- Install Ruby latest version
- agilecrm.rb file
contact_data = '{
"star_value": "4",
"lead_score": "92",
"tags": [
"Lead",
"Likely Buyer"
],
"properties": [
{
"type": "SYSTEM",
"name": "first_name",
"value": "Los "
},
{
"type": "SYSTEM",
"name": "last_name",
"value": "Bruikheilmer"
},
{
"type": "SYSTEM",
"name": "company",
"value": "steady.inc"
},
{
"type": "SYSTEM",
"name": "title",
"value": "VP Sales"
},
{
"type": "SYSTEM",
"name": "email",
"subtype": "work",
"value": "[email protected] "
},
{
"type": "SYSTEM",
"name": "address",
"value": "{\"address\":\"225 George Street\",\"city\":\"NSW\",\"state\":\"Sydney\",\"zip\":\"2000\",\"country\":\"Australia\"}"
},
{
"type": "CUSTOM",
"name": "My Custom Field",
"value": "Custom value"
}
]
}'
parsed_contact_data = JSON.parse(contact_data)
print(AgileCRM.request :post, "contacts", parsed_contact_data)
print(AgileCRM.request :get, "contacts/5762169748586496", nil)
print(AgileCRM.request :get, "contacts/search/email/[email protected]", nil)
print(AgileCRM.request :delete, "contacts/5748927693324288", nil)
update_contact_data = '{
"id": "5748927693324288",
"properties": [
{
"type": "SYSTEM",
"name": "last_name",
"value": "Lee Chu"
},
{
"type": "CUSTOM",
"name": "My Custom Field",
"value": "Custom value chane"
}
]
}'
parsed_update_contact_data = JSON.parse(update_contact_data)
print(AgileCRM.request :put, "contacts/edit-properties", parsed_update_contact_data)
update_starvalue_data = '{
"id": "5717446287687680",
"star_value": 2
}'
parsed_starvalue_data = JSON.parse(update_starvalue_data)
#print(AgileCRM.request :put, "contacts/edit/add-star", parsed_starvalue_data)
update_leadscore_data = '{
"id": "5717446287687680",
"lead_score": 20
}'
parsed_leadscore_data = JSON.parse(update_leadscore_data)
#print(AgileCRM.request :put, "contacts/edit/lead-score", parsed_leadscore_data)
update_tags_data = '{
"id": "5717446287687680",
"tags": [
"test1",
"test2"
]
}'
parsed_tags_data = JSON.parse(update_tags_data)
#print(AgileCRM.request :put, "contacts/edit/tags", parsed_tags_data)
delete_tags_data = '{
"id": "5717446287687680",
"tags": [
"test1",
"test2"
]
}'
parsed_deletedcontact_data = JSON.parse(delete_tags_data)
#print(AgileCRM.request :put, "contacts/delete/tags", parsed_deletedcontact_data)
company_data = '{
"type": "COMPANY",
"star_value": 4,
"lead_score": 120,
"tags": [
"Permanent",
"USA",
"Hongkong",
"Japan"
],
"properties": [
{
"name": "Company Type",
"type": "CUSTOM",
"value": "MNC Inc"
},
{
"type": "SYSTEM",
"name": "name",
"value": "Spicejet"
},
{
"type": "SYSTEM",
"name": "url",
"value": "http://www.spicejet.com/"
},
{
"name": "email",
"value": "[email protected]",
"subtype": ""
},
{
"name": "phone",
"value": "45500000",
"subtype": ""
},
{
"name": "website",
"value": "http://www.linkedin.com/company/agile-crm",
"subtype": "LINKEDIN"
},
{
"name": "address",
"value": "{\"address\":\"MS 35, 440 N Wolfe Road\",\"city\":\"Sunnyvale\",\"state\":\"CA\",\"zip\":\"94085\",\"country\":\"US\"}",
"subtype": "office"
}
]
}'
parsed_company_data = JSON.parse(company_data)
print(AgileCRM.request :post, "contacts", parsed_company_data)
print(AgileCRM.request :get, "contacts/5762169748586496", nil)
print(AgileCRM.request :delete, "contacts/5748927693324288", nil)
update_company_data = '{
"id":5651082298523648,
"properties": [
{
"type": "SYSTEM",
"name": "name",
"value": "Spicejet"
},
{
"type": "SYSTEM",
"name": "url",
"value": "http://www.spicejet.com/"
},
{
"name": "email",
"value": "[email protected] ",
"subtype": ""
},
{
"name": "phone",
"value": "45500000",
"subtype": ""
},
{
"name": "website",
"value": "http://www.linkedin.com/company/agile-crm",
"subtype": "LINKEDIN"
},
{
"name": "address",
"value": "{\"address\":\"MS 35, 440 N Wolfe Road\",\"city\":\"Sunnyvale\",\"state\":\"CA\",\"zip\":\"94085\",\"country\":\"US\"}",
"subtype": "office"
}
]
}'
parsed_update_company_data = JSON.parse(update_company_data)
print(AgileCRM.request :put, "contacts/edit-properties", parsed_update_company_data)
- 'q' - Search keyword (all contact/company default fields and searchable custom fields will be searched)
- 'page_size' - Number of results to fetch
- 'type' - Should be 'PERSON' for searching Contacts and 'COMPANY' for Companies
print(AgileCRM.request :get, "search?q=Google&page_size=10&type='COMPANY'", nil)
- Note Milestone name is case sensitive. It should be exactly as in your Agile CRM
deal_data = '{
"name": "Deal-Tomato",
"expected_value": "500",
"probability": "75",
"close_date": 1455042600,
"milestone": "Proposal",
"contact_ids": [
"5705059971104768"
],
"custom_data": [
{
"name": "Group Size",
"value": "10"
}
]
}'
parsed_deal_data = JSON.parse(deal_data)
print(AgileCRM.request :post, "opportunity", parsed_deal_data)
print(AgileCRM.request :get, "opportunity/5743182100824064", nil)
print(AgileCRM.request :delete, "opportunity/5743182100824064", nil)
update_deal_data = '{
"id": "5743182100824064",
"name": "Deal-Tomato-changed",
"expected_value": "500",
"probability": "75",
"close_date": 1455042600,
"milestone": "Proposal",
"contact_ids": [
"5705059971104768"
],
"custom_data": [
{
"name": "Group Size",
"value": "10"
}
]
}'
parsed_update_deal_data = JSON.parse(update_deal_data)
print(AgileCRM.request :put, "opportunity/partial-update", parsed_update_deal_data)