From 7e8d1e1f5a73a8032b928459254fd427fe97e690 Mon Sep 17 00:00:00 2001 From: Yordy Gelvez Date: Fri, 16 Feb 2018 17:52:04 -0500 Subject: [PATCH 1/6] Update README.md --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c67fec9..2ab7953 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,47 @@ # infusionsoft-python -InfusionSoft API wrapper written in Python. -This library works for the Infusionsoft REST API v1 + +InfusionSoft API wrapper for Infusionsoft written in Python. + +## Installing +``` +git+git://github.com/GearPlug/infusionsoft-python.git +``` + +## Usage +``` +from infusionsoft.client import Client +client = Client('CLIENT_ID', 'CLIENT_SECRET', 'OPTIONAL - access_token') +``` +Get authorization url +``` +url = client..oauth_access("REDIRECT_URL") +``` + +Exchange the code for an access token +``` +token = client.exchange_code('REDIRECT_URL', 'CODE') +``` + +Refresh token +``` +token = client.refresh_token('REFRESH TOKEN') +``` + +Set token +``` +token = client.set_token('TOKEN') +``` + +## Requirements +- requests +- base64 -- b64encode + +## Tests +``` +python test.py +``` + +## TODO Endpoints +- All Appointments Section +- All File Section +- All Tag Section From 782818e6a1042f419707b5b3d925316dea0de181 Mon Sep 17 00:00:00 2001 From: Yordy Gelvez Date: Fri, 16 Feb 2018 17:52:59 -0500 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ab7953..2703a6c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ token = client.set_token('TOKEN') ## Tests ``` -python test.py +infusionsoft/test.py ``` ## TODO Endpoints From d8872294ebeec8d6b2579899898277a38fce29ad Mon Sep 17 00:00:00 2001 From: Yordy Gelvez Date: Fri, 16 Feb 2018 17:53:32 -0500 Subject: [PATCH 3/6] Delete testing.py --- infusionsoft/testing.py | 217 ---------------------------------------- 1 file changed, 217 deletions(-) delete mode 100644 infusionsoft/testing.py diff --git a/infusionsoft/testing.py b/infusionsoft/testing.py deleted file mode 100644 index 6b76a63..0000000 --- a/infusionsoft/testing.py +++ /dev/null @@ -1,217 +0,0 @@ -from infusionsoft.client import Client -import json - -""" -MAIN INSTANCE -here you instance the main class, obligatory send the access token -this library works for the Infusionsoft REST API version 1 -""" -client_id = "kbj7nhv3b7yezsrxck2cc749" -client_secret = "UMtN6PGPud" -access_token = "p2de6mybxsbgs3xu393r7teh" -refresh_token = "v4vvdcuqk7ddwajucjsfk7ra" -callback = "" -petition = Client(access_token) - -""" -OAUTH URL -here you will get the url to do the oauth petition, you have to send the client id and the callback url -""" -# oauth = petition.oauth_access("client_id", "callback") -# print(oauth) - -""" -REFRESH TOKEN -here you can refresh the token, are obligatory the client id, client secret and the refresh token -""" -# refresh_token = petition.refresh_token(client_id, client_secret, refresh_token) -# print(refresh_token) - -""" -GET DATA -call the method get_data and send "endpoint" -Endpoint Examples: "contacts", "contactCustomFields", "campaigns", "opportunities", "products/search", "tasks", "orders", "hooks/event_keys", "hooks" -""" -# data = petition.get_data('contacts', order="id", order_direction="descending", limit=1) -# print(data) - -""" -CREATE DATA -call the method create_data and send "endpoint" and the data -Example: - data = {'email_addresses': [{'email': 'EMAIL@EMAIL.com', 'field': 'EMAIL1'}], 'given_name': 'NAME'} - endpoint = "contacts" - data = petition.create_data(endpoint, **data) -""" - -""" -UPDATE DATA -call the method update_data and send "endpoint", the id of the thing to update, and the data to update -Example: - data = {'email_addresses': [{'email': 'CHANGEEMAIL@EMAIL.com', 'field': 'EMAIL1'}], 'given_name': 'CHANGENAME'} - endpoint = "contacts" - data = petition.update_data(endpoint, 100, **data) -""" - -""" -DELETE DATA -just call the method delete_data, send "endpoint" and the id of the thing to delete -Example: - data = petition.delete_data(endpoint, 100) -""" - -""" -CONTACT TEST -here you can list all the custom fields of the contacts -""" -# custom_fields = petition.get_contact_custom_fields() -# print(custom_fields) - -""" - ***here you create a contact, you must to give a valid email or a phone number and that is send as a kwarg - data = {'email_addresses': [{'email': 'EMAIL@EMAIL.com', 'field': 'EMAIL1'}], 'given_name': 'NAME'} -""" -# create_contact = petition.create_contact(**data) -# print(create_contact) - -""" ***here you delete a contact, is obligatory the id of the contact""" -# delete_contact = petition.delete_contact(180) -# print(delete_contact) - -""" - ***here you can update a contact, is obligatory the id of the contact to update - To update just use this sintaxis: update_contact('YOURID', given_name="name", email_addresses=[{"email":"email@email.com","field":"EMAIL1"}]) -""" -# update_contact = petition.update_contact('184', given_name="Hernan", family_name="Herrera", email_addresses=[{"email":"hernan_herre@gmail.com","field":"EMAIL1"}]) -# print(update_contact) - -""" - ***here you list the contacts, can receive limit, order, and offset. - For filter specific camps use this sintaxis: get_contacts(field="name", order_direction="descending") -""" -# list_contacts = petition.get_contacts(order="id", order_direction="descending") -# print(list_contacts['contacts']) - -""" - ***here you can retrieve a contact, send the ID and the optional_properties values -""" -# retrieve_contact = petition.retrieve_contact(166, optional_properties="custom_fields,preferred_name,opt_in_reason,notes") -# print(retrieve_contact) - -""" -CAMPAIGN TEST -here you list the campaigns, can receive limit and offset -""" -# list_campaigns = petition.get_campaigns() -# print(list_campaigns) - -""" ***here you can retrieve a specific campaign, obligatory the id of the campaign""" -# retrieve_campaign = petition.retrieve_campaign('') -# print(retrieve_campaign) - -""" -EMAIL TEST -here you can get all, or some emails, receive limit or offset -""" -# list_emails = petition.get_emails() -# print(list_emails) - -""" -OPPORTUNITIES TEST -here you can list the opportunities, can receive limit, order, and offset -""" -# list_opportunities = petition.get_opportunities() -# print(list_opportunities) - -""" ***here you can list all t3jpyhrhu2r9ac6cw4uta7sf9he opportunities in pipeline, not receive anyshit""" -# list_all_opportunities = petition.get_opportunities_pipeline() -# print(list_all_opportunities) - -""" ***here you can retrieve a specific opportunity, obligatory send the id""" -# retrieve_opportunity = petition.retrieve_opportunity("") -# print(retrieve_opportunity) - -""" - ***here you can create an opportunity, obligatory opportunity_title, contact, and stage as a json array - data = { - 'contact': { - 'id': '170' - }, - 'stage': { - 'name': 'stage de prueba', - 'id': 66, - 'details': { - 'check_list_items': [ - {'description': 'Esta es una oportunidad de prueba'} - ] - } - }, - 'opportunity_title': 'TestOpportunity4' - } -""" -# create_opportunity = petition.create_opportunity(**data) -# print(create_opportunity) - -""" - ***here you can update an opportunity, obligatory send the id of the opportunity and the data to update as a json array -""" -# update_opportunity = petition.update_opportunity(ID, opportunity_title="NAME") -# print(update_opportunity) - -""" -PRODUCT METHOD TEST -here you can list the products -""" -# get_products = petition.get_products() -# print(get_products) - - -""" -TASK METHOD TEST -here you can list the tasks -""" -# data = {'title': 'TASK DE TEST2', "contact": {"id": 170}} -# create_task = petition.create_task(**data) -# print(create_task) - -# delete_task = petition.delete_task(6) -# print(delete_task) - -# get_tasks = petition.get_tasks() -# print(get_tasks) - - -""" -ORDER METHOD TEST -here you can list the order -""" -# get_orders = petition.get_orders() -# print(get_orders) - -""" -HOOKS METHODS TEST -here you can list the hooks events, just call the method -""" -# get_hook_events = petition.get_hook_events() -# print(get_hook_events) - - -""" ***here you can verify a hook subscription""" -# verify_hook = petition.verify_hook_subscription("74") -# print(verify_hook) - -""" ***here you can create a hook subscription, send the hook event and the url callback""" -# create_hook = petition.create_hook_subscription("opportunity.add", "http://23bc0c82.ngrok.io/api/callback") -# print(create_hook) - -""" ***here you can update a hook, send the hook id, event and url""" -# update_hook = petition.update_hook_subscription() -# print(update_hook) - -""" ***here you can delete a hook subscription, is obligatory to send the hook id""" -# delete_hook = petition.delete_hook_subscription(126) -# print(delete_hook) - -""" ***here you can get all the hook subscriptions, just call the method""" -# get_hook_subscriptions = petition.get_hook_subscriptions() -# print(get_hook_subscriptions) From e6cabdac51fb95f6fd50238a0144a85f881a8696 Mon Sep 17 00:00:00 2001 From: Yordy Gelvez Date: Mon, 19 Feb 2018 10:02:49 -0500 Subject: [PATCH 4/6] Update README.md --- README.md | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 212 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2703a6c..552904f 100644 --- a/README.md +++ b/README.md @@ -12,26 +12,234 @@ git+git://github.com/GearPlug/infusionsoft-python.git from infusionsoft.client import Client client = Client('CLIENT_ID', 'CLIENT_SECRET', 'OPTIONAL - access_token') ``` -Get authorization url +### Get authorization url ``` url = client..oauth_access("REDIRECT_URL") ``` -Exchange the code for an access token +### Exchange the code for an access token ``` token = client.exchange_code('REDIRECT_URL', 'CODE') ``` -Refresh token +### Refresh token ``` token = client.refresh_token('REFRESH TOKEN') ``` -Set token +### Set token ``` token = client.set_token('TOKEN') ``` +### Get Contacts +here you list the contacts, can receive limit, order, order_direction and offset. +for filter specific camps use this sintaxis: get_contacts(field="name", order_direction="descending") +``` +list_contacts = client.get_contacts(order="id", order_direction="descending") +``` + +### Retrieve Contacts +here you can retrieve a contact, send the ID and the optional_properties values +``` +retrieve_contact = client.retrieve_contact(166, optional_properties="custom_fields,preferred_name,opt_in_reason,notes") +``` + +### Create Contact +here you create a contact, you must to give a valid email or a phone number and that is send as a kwarg +data = {'email_addresses': [{'email': 'EMAIL@EMAIL.com', 'field': 'EMAIL1'}], 'given_name': 'NAME'} +``` +create_contact = client.create_contact(**data) +``` + +### Delete Contact +here you delete a contact, is obligatory the id of the contact +``` +delete_contact = client.delete_contact('ID') +``` + +### Update Contact +data = {'email_addresses': [{'email': 'EMAIL@EMAIL.com', 'field': 'EMAIL1'}], 'given_name': 'NAME'} +``` +update_contact = client.update_contact('184', **data) +``` + +### Get Campaign +here you list the campaigns, can receive limit and offset +``` +list_campaigns = client.get_campaigns() +``` + +### Retrieve Campaign +here you can retrieve a specific campaign, obligatory the id of the campaign +``` +retrieve_campaign = client.retrieve_campaign('ID') +``` + +### Get Emails +here you can get all, can receive limit or offset +``` +list_emails = client.get_emails() +``` + +### Get Opportunities +here you can list the opportunities, can receive limit, order, and offset +``` +list_opportunities = client.get_opportunities() +``` + +### Get Opportunities Pipeline +here you can list the pipeline opportunities +``` +list_all_opportunities = client.get_opportunities_pipeline() +``` + +### Retrieve Opportunity +here you can retrieve a specific opportunity, obligatory send the id +``` +retrieve_opportunity = client.retrieve_opportunity('ID') +``` + +### Create Opportunity +here you can create an opportunity, obligatory opportunity_title, contact, and stage +data = { + 'contact': { + 'id': '170' + }, + 'stage': { + 'name': 'Stage Test', + 'id': 10, + 'details': { + 'check_list_items': [ + {'description': 'Test Opportunity'} + ] + } + }, + 'opportunity_title': 'OpportunityTitle' +} +``` +create_opportunity = client.create_opportunity(**data) +``` + +### Update Opportunity +here you can update an opportunity, obligatory send the id of the opportunity and the data to update +data = { + 'contact': { + 'id': '170' + }, + 'stage': { + 'name': 'Stage Test', + 'id': 10, + 'details': { + 'check_list_items': [ + {'description': 'Test Opportunity'} + ] + } + }, + 'opportunity_title': 'OpportunityTitle' +} +``` +update_opportunity = client.update_opportunity('ID', **data) +``` + +### Get Products +here you can list the products +``` +get_products = client.get_products() +``` + +### Retrieve Product +here you can retrieve a specific product, just send the id of the product +``` +retrieve_product = client.retrieve_product('ID') +``` + +### Get Tasks +here you can list the tasks, can receive limit, offset +``` +get_tasks = client.get_tasks() +``` + +### Create Task +here you can list the tasks, can receive limit, offset +data = {'title': 'TASK TITLE', "contact": {"id": 170}} +``` +create_task = client.create_task(**data) +``` + +### Delete Task +here you can delete a tasks, obligatory send the id of the task +``` +delete_task = client.delete_task('ID') +``` + +### Update Task +here you can update a tasks, obligatory send the id of the task to update and the data +data = {'title': 'TASK TITLE', "contact": {"id": 170}} +``` +update_task = client.update_task('ID', **data) +``` + +### Retrieve Task +here you can retrieve a tasks, obligatory send the id of the task +``` +retrieve_task = client.retrieve_task('ID') +``` + +### Replace Task +here you can replace a task, obligatory send the id of the task +``` +replace_task = client.replace_task('ID') +``` + +### Get Orders +here you can get orders, can receive limit, offset +``` +get_orders = client.get_orders() +``` + +### Retrieve Order +here you can retrieve an order, obligatory send the id of the order +``` +retrieve_order = client.retrieve_order('ID') +``` + +### Get Hook Events +here you can list the hooks events, just call the method +``` +get_hook_events = client.get_hook_events() +``` + +### Get Webhooks +here you can get all the hook subscriptions, just call the method +``` +get_hook_subscriptions = client.get_hook_subscriptions() +``` + +### Verify Hook Subscription +here you can verify a hook subscription, send the id of the webhook to verify it +``` +verify_hook = client.verify_hook_subscription('ID') +``` + +### Create Hook Subscription +here you can create a hook subscription, send the hook event and the url callback +``` +create_hook = client.create_hook_subscription("opportunity.add", "URL") +``` + +### Update Hook Subscription +here you can update a hook, send the hook id, event and url +``` +update_hook = petition.update_hook_subscription('ID', 'opportunity.delete', 'URL') +``` + +### Delete Hook Subscription +here you can delete a hook subscription, is obligatory to send the hook id +``` +delete_hook = petition.delete_hook_subscription('ID') +``` + ## Requirements - requests - base64 -- b64encode From 9cf423deae50092263f8866f24942f046b4e9dfb Mon Sep 17 00:00:00 2001 From: Yordy Gelvez Date: Mon, 19 Feb 2018 10:05:42 -0500 Subject: [PATCH 5/6] Update README.md --- README.md | 66 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 552904f..222e024 100644 --- a/README.md +++ b/README.md @@ -12,95 +12,95 @@ git+git://github.com/GearPlug/infusionsoft-python.git from infusionsoft.client import Client client = Client('CLIENT_ID', 'CLIENT_SECRET', 'OPTIONAL - access_token') ``` -### Get authorization url +#### Get authorization url ``` url = client..oauth_access("REDIRECT_URL") ``` -### Exchange the code for an access token +#### Exchange the code for an access token ``` token = client.exchange_code('REDIRECT_URL', 'CODE') ``` -### Refresh token +#### Refresh token ``` token = client.refresh_token('REFRESH TOKEN') ``` -### Set token +#### Set token ``` token = client.set_token('TOKEN') ``` -### Get Contacts +#### Get Contacts here you list the contacts, can receive limit, order, order_direction and offset. for filter specific camps use this sintaxis: get_contacts(field="name", order_direction="descending") ``` list_contacts = client.get_contacts(order="id", order_direction="descending") ``` -### Retrieve Contacts +#### Retrieve Contacts here you can retrieve a contact, send the ID and the optional_properties values ``` retrieve_contact = client.retrieve_contact(166, optional_properties="custom_fields,preferred_name,opt_in_reason,notes") ``` -### Create Contact +#### Create Contact here you create a contact, you must to give a valid email or a phone number and that is send as a kwarg data = {'email_addresses': [{'email': 'EMAIL@EMAIL.com', 'field': 'EMAIL1'}], 'given_name': 'NAME'} ``` create_contact = client.create_contact(**data) ``` -### Delete Contact +#### Delete Contact here you delete a contact, is obligatory the id of the contact ``` delete_contact = client.delete_contact('ID') ``` -### Update Contact +#### Update Contact data = {'email_addresses': [{'email': 'EMAIL@EMAIL.com', 'field': 'EMAIL1'}], 'given_name': 'NAME'} ``` update_contact = client.update_contact('184', **data) ``` -### Get Campaign +#### Get Campaign here you list the campaigns, can receive limit and offset ``` list_campaigns = client.get_campaigns() ``` -### Retrieve Campaign +#### Retrieve Campaign here you can retrieve a specific campaign, obligatory the id of the campaign ``` retrieve_campaign = client.retrieve_campaign('ID') ``` -### Get Emails +#### Get Emails here you can get all, can receive limit or offset ``` list_emails = client.get_emails() ``` -### Get Opportunities +#### Get Opportunities here you can list the opportunities, can receive limit, order, and offset ``` list_opportunities = client.get_opportunities() ``` -### Get Opportunities Pipeline +#### Get Opportunities Pipeline here you can list the pipeline opportunities ``` list_all_opportunities = client.get_opportunities_pipeline() ``` -### Retrieve Opportunity +#### Retrieve Opportunity here you can retrieve a specific opportunity, obligatory send the id ``` retrieve_opportunity = client.retrieve_opportunity('ID') ``` -### Create Opportunity +#### Create Opportunity here you can create an opportunity, obligatory opportunity_title, contact, and stage data = { 'contact': { @@ -121,7 +121,7 @@ data = { create_opportunity = client.create_opportunity(**data) ``` -### Update Opportunity +#### Update Opportunity here you can update an opportunity, obligatory send the id of the opportunity and the data to update data = { 'contact': { @@ -142,99 +142,99 @@ data = { update_opportunity = client.update_opportunity('ID', **data) ``` -### Get Products +#### Get Products here you can list the products ``` get_products = client.get_products() ``` -### Retrieve Product +#### Retrieve Product here you can retrieve a specific product, just send the id of the product ``` retrieve_product = client.retrieve_product('ID') ``` -### Get Tasks +#### Get Tasks here you can list the tasks, can receive limit, offset ``` get_tasks = client.get_tasks() ``` -### Create Task +#### Create Task here you can list the tasks, can receive limit, offset data = {'title': 'TASK TITLE', "contact": {"id": 170}} ``` create_task = client.create_task(**data) ``` -### Delete Task +#### Delete Task here you can delete a tasks, obligatory send the id of the task ``` delete_task = client.delete_task('ID') ``` -### Update Task +#### Update Task here you can update a tasks, obligatory send the id of the task to update and the data data = {'title': 'TASK TITLE', "contact": {"id": 170}} ``` update_task = client.update_task('ID', **data) ``` -### Retrieve Task +#### Retrieve Task here you can retrieve a tasks, obligatory send the id of the task ``` retrieve_task = client.retrieve_task('ID') ``` -### Replace Task +#### Replace Task here you can replace a task, obligatory send the id of the task ``` replace_task = client.replace_task('ID') ``` -### Get Orders +#### Get Orders here you can get orders, can receive limit, offset ``` get_orders = client.get_orders() ``` -### Retrieve Order +#### Retrieve Order here you can retrieve an order, obligatory send the id of the order ``` retrieve_order = client.retrieve_order('ID') ``` -### Get Hook Events +#### Get Hook Events here you can list the hooks events, just call the method ``` get_hook_events = client.get_hook_events() ``` -### Get Webhooks +#### Get Webhooks here you can get all the hook subscriptions, just call the method ``` get_hook_subscriptions = client.get_hook_subscriptions() ``` -### Verify Hook Subscription +#### Verify Hook Subscription here you can verify a hook subscription, send the id of the webhook to verify it ``` verify_hook = client.verify_hook_subscription('ID') ``` -### Create Hook Subscription +#### Create Hook Subscription here you can create a hook subscription, send the hook event and the url callback ``` create_hook = client.create_hook_subscription("opportunity.add", "URL") ``` -### Update Hook Subscription +#### Update Hook Subscription here you can update a hook, send the hook id, event and url ``` update_hook = petition.update_hook_subscription('ID', 'opportunity.delete', 'URL') ``` -### Delete Hook Subscription +#### Delete Hook Subscription here you can delete a hook subscription, is obligatory to send the hook id ``` delete_hook = petition.delete_hook_subscription('ID') From 1ff6136ba1d1703ec8dba20e7ffd5db7708eb5a0 Mon Sep 17 00:00:00 2001 From: Yordy Gelvez Date: Mon, 19 Feb 2018 11:43:35 -0500 Subject: [PATCH 6/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 222e024..fac7b91 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ client = Client('CLIENT_ID', 'CLIENT_SECRET', 'OPTIONAL - access_token') ``` #### Get authorization url ``` -url = client..oauth_access("REDIRECT_URL") +url = client.oauth_access("REDIRECT_URL") ``` #### Exchange the code for an access token