Skip to content

Commit

Permalink
Adding SDK support for Lead Ads API
Browse files Browse the repository at this point in the history
Summary: Support for leads API

Test Plan:
All unit and integration tests pass:

ritu-mbp:python-ads-sdk ritu$ python -m facebookads.test.unit
............................
----------------------------------------------------------------------
Ran 28 tests in 0.018s

OK
ritu-mbp:python-ads-sdk ritu$ python -m facebookads.test.integration
....................
----------------------------------------------------------------------
Ran 20 tests in 14.488s

OK
  • Loading branch information
Rituparna Mukherjee committed Sep 21, 2015
1 parent f737fec commit 7d428b4
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions facebookads/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,13 @@ class Location(object):
def get_endpoint(cls):
return 'accounts'

def get_leadgen_forms(self, fields=None, params=None):
"""
Returns all leadgen forms on the page
"""
return self.iterate_edge(LeadgenForm, fields, params)


class Activity(AbstractObject):

class Field(object):
Expand Down Expand Up @@ -1474,6 +1481,12 @@ def get_insights(self, fields=None, params=None, async=False):
include_summary=False
)

def get_leads(self, fields=None, params=None):
"""
Returns all the leads associated with the adgroup
"""
return self.iterate_edge(Lead, fields, params)


class AdConversionPixel(AbstractCrudObject):

Expand Down Expand Up @@ -2918,6 +2931,48 @@ def get_endpoint(cls):
return 'adcampaigngroupsbylabels'


class Lead(AbstractCrudObject):

class Field(object):
adgroup_id = 'adgroup_id'
created_time = 'created_time'
field_data = 'field_data'
form_id = 'form_id'
id = 'id'
is_tcpa_compliant = 'is_tcpa_compliant'
tcpa_disclosure = 'tcpa_disclosure'

@classmethod
def get_endpoint(cls):
return 'leads'


class LeadgenForm(AbstractCrudObject):

class Field(object):
created_time = 'created_time'
customized_tcpa_content = 'customized_tcpa_content'
follow_up_action_text = 'follow_up_action_text'
follow_up_action_url = 'follow_up_action_url'
id = 'id'
leadgen_export_csv_url = 'leadgen_export_csv_url'
leads = 'leads'
locale = 'locale'
name = 'name'
privacy_policy_url = 'privacy_policy_url'
tcpa_compliance = 'tcpa_compliance'

@classmethod
def get_endpoint(cls):
return 'leadgen_forms'

def get_leads(self, fields=None, params=None):
"""
Returns all the leads associated with the ad leadgen form
"""
return self.iterate_edge(Lead, fields, params)


class AsyncJob(CannotCreate, AbstractCrudObject):

class Field(object):
Expand Down

0 comments on commit 7d428b4

Please sign in to comment.