pantheon-systems/suds-marketo

Name: suds-marketo

Owner: Pantheon

Description: Python wrapper to call the Marketo SOAP Api using SUDS.

Forked from: csmithd/suds-marketo

Created: 2016-11-08 22:24:42.0

Updated: 2016-11-08 22:24:43.0

Pushed: 2016-10-18 19:19:17.0

Homepage:

Size: 21

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

suds-marketo

suds-marketo is a python query client that wraps the Marketo SOAP API. This package is based on https://github.com/segmentio/marketo-python but uses SUDS instead of manual XML requests. Using SUDS makes it easier to update and allows access to unimplemented functions by calling the suds methods directly (client.yourFunction()).

Marketo SOAP Api: https://jira.talendforge.org/secure/attachmentzip/unzip/167201/49761%5B1%5D/Marketo%20Enterprise%20API%202%200.pdf

Get Started
install suds-marketo
ython
rt suds_marketo
nt = suds_marketo.Client(soap_endpoint='https://na-q.marketo.com/soap/mktows/2_0',
                    user_id='bigcorp1_461839624B16E06BA2D663',
                    encryption_key='899756834129871744AAEE88DDCC77CDEEDEC1AAAD66')
See available functions and objects

You can see the list of functions and objects available by printing the suds client object.

int client.suds_types
ivityRecord, ActivityType, ActivityTypeFilter, ArrayOfActivityRecord, ArrayOfActivityType,
yOfAttrib, ArrayOfAttribute, ArrayOfBase64Binary, ArrayOfCampaignRecord, ArrayOfCustomObj,
yOfInteger, ArrayOfKeyList, ArrayOfLeadChangeRecord, ArrayOfLeadKey, ArrayOfLeadRecord,
yOfLeadStatus, ArrayOfMObjAssociation, ArrayOfMObjCriteria, ArrayOfMObjFieldMetadata,
yOfMObjStatus, ArrayOfMObject, ArrayOfString, ArrayOfSyncCustomObjStatus, ArrayOfSyncStatus,
yOfVersionedItem, Attrib, Attribute, AuthenticationHeaderInfo, CampaignRecord,
arisonEnum, CustomObj, ForeignSysType, ImportToListModeEnum, ImportToListStatusEnum,
UpdateAtSelector, LeadActivityList, LeadChangeRecord, LeadKey, LeadKeyRef, LeadKeySelector,
MergeStatusEnum, LeadRecord, LeadSelector, LeadStatus, LeadSyncStatus, ListKey,
KeyType, ListOperationType, MObjAssociation, MObjCriteria, MObjFieldMetadata, MObjStatus,
StatusEnum, MObject, MObjectMetadata, MObjectTypeEnum, MergeStatus,
wsContextHeaderInfo, ParamsDeleteCustomObjects, ParamsDeleteMObjects,
msDescribeMObject, ParamsGetCampaignsForSource, ParamsGetCustomObjects,
msGetImportToListStatus, ParamsGetLead, ParamsGetLeadActivity, ParamsGetLeadChanges,
msGetMObjects, ParamsGetMultipleLeads, ParamsImportToList, ParamsListMObjects,
msListOperation, ParamsMergeLeads, ParamsRequestCampaign, ParamsScheduleCampaign,
msSyncCustomObjects, ParamsSyncLead, ParamsSyncMObjects, ParamsSyncMultipleLeads,
ampSourceType, ResultDeleteCustomObjects, ResultDeleteMObjects, ResultDescribeMObject,
ltGetCampaignsForSource, ResultGetCustomObjects, ResultGetImportToListStatus, ResultGetLead,
ltGetLeadChanges, ResultGetMObjects, ResultGetMultipleLeads, ResultImportToList,
ltListMObjects, ResultListOperation, ResultMergeLeads, ResultRequestCampaign,
ltScheduleCampaign, ResultSyncCustomObjects, ResultSyncLead, ResultSyncMObjects,
ltSyncMultipleLeads, StaticListSelector, StreamPosition, SuccessDeleteCustomObjects,
essDeleteMObjects, SuccessDescribeMObject, SuccessGetCampaignsForSource,
essGetCustomObjects, SuccessGetImportToListStatus, SuccessGetLead, SuccessGetLeadActivity,
essGetLeadChanges, SuccessGetMObjects, SuccessGetMultipleLeads, SuccessImportToList,
essListMObjects, SuccessListOperation, SuccessMergeLeads, SuccessRequestCampaign,
essScheduleCampaign, SuccessSyncCustomObjects, SuccessSyncLead, SuccessSyncMObjects,
essSyncMultipleLeads, SyncCustomObjStatus, SyncOperationEnum, SyncStatus, SyncStatusEnum,
ionedItem]
int client.suds_methods
CampaignsForSource, deleteCustomObjects, syncMultipleLeads, deleteMObjects, describeMObject,
Operation, mergeLeads, getCustomObjects, getLead, getImportToListStatus, importToList,
Lead, getMObjects, getLeadActivity, getLeadChanges, syncMObjects, scheduleCampaign,
MObjects, syncCustomObjects, requestCampaign, getMultipleLeads]

You can access the methods as follow:

ient.getLead(lead_key)

You can access the types as follow:

ient.LeadKey # Simple type
ient.LeadKeyRef.EMAIL # Enumeration
Call functions

If the function is defined in the client class:

ad = client.get_lead('user@gmail.com')

If the function you are looking for is not defined in the client class:

ad_key = client.LeadKey # You need to create the proper object to pass to the function
ad_key.keyType = client.LeadKeyRef.EMAIL
ad_key.keyValue = 'test@punchtab.com'
sp = client.call_service('getLead', lead_key)
Error

An Exception is raised if a Marketo error occurs (caused either by client or server).

om suds import WebFault
y:
 lead = client.get_lead('test@punchtab.com')
cept WebFault as e:
 print e

er raised fault: '20103 - Lead not found'

As described in the Appendix B of the Marketo API, you can access the following error attributes:

int e.fault.faultcode
-ENV:Client

int e.fault.faultstring
3 - Lead not found

int e.fault.detail
ail){
erviceException = 
  (serviceException){
     name = "mktServiceException"
     message = "No lead found with EMAIL = test@punchtab.com (20103)"
     code = "20103"
  }


int e.fault.detail.serviceException
viceException){
ame = "mktServiceException"
essage = "No lead found with EMAIL = test@punchtab.com (20103)"
ode = "20103"


int e.fault.detail.serviceException.name
erviceException

int e.fault.detail.serviceException.message
ead found with EMAIL = test@punchtab.com (20103)

int e.fault.detail.serviceException.code
3
License

The MIT License (MIT)

Copyright (c) 2013 PunchTab, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.