Package: salesmanago-python-api
salesmanago-python-apiPython API for SalesManago integration.InstallationInstall this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions. With virtualenv, it's possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.Mac/Linuxpip install virtualenv
virtualenv 
source /bin/activate
/bin/pip install salesmanago_python_apiWindowspip install virtualenv
virtualenv 
\Scripts\activate
\Scripts\pip.exe install salesmanago_python_apiSupported Python VersionsPython 3.7, and 3.8 are fully supported and tested. This library may work on later versions of 3, but we do not currently run tests against those versionsDeprecated Python Versions
Python <= 3.7Third Party Libraries and DependenciesThe following libraries will be installed when you install the client library:requestsServicesCurrently client service is supported PARTIALLY, event service is supported only for inserts.
I've needed only a few methods and those were implemented.SalesManagoClientServicehandles:insertupsertupdatedeleteSalesManagoClientServicehandles:addContactExtEventbatchAddContactExtEventUsage of Client ServiceStart with import ;)from salesmanago_python_api.services import SalesManagoClientServiceSince SalesManago has different data requirements for all supported methods, it's required to interface with the client service usingSalesManagoClientDataclass.
It will handle all the required formatting for you.clientServiceClass=SalesManagoClientService(apiKey=API_KEY,clientId=CLIENT_ID,apiSecret=API_SECRET,serverDomain=SERVER_DOMAIN)clientDataClass=clientServiceClass.ClientDataclientData=clientDataClass(email='unittest@salesmanagopythonapi.pl',owner=REAL_OWNER)response=clientServiceClass.insert(clientData)response.raise_for_status()response_json=response.json()SalesManagoClientServiceneeds to be initialized only once, it setups requests Session and handles the request build process.clientServiceClass=SalesManagoClientService(apiKey=API_KEY,clientId=CLIENT_ID,apiSecret=API_SECRET,serverDomain=SERVER_DOMAIN)#insert new client into SM database.clientDataClass=clientServiceClass.ClientDataclientData=clientDataClass(email='client@salesmanagopythonapi.pl',owner='owner@company.com')clientServiceClass.insert(clientData)#update SM client with newMail and stateclientUpdateData=clientDataClass(email='client@salesmanagopythonapi.pl',owner='owner@company.com',state='CUSTOMER',newMail='newmail@salesmanagopythonapi.pl')clientServiceClass.update(clientUpdateData)#delete himclientDeleteData=clientDataClass(email='newmail@salesmanagopythonapi.pl',owner='owner@company.com')clientServiceClass.delete(clientData)Properties on SalesManagoClientDataemail: str - Required Contact E-mailowner: str - Required Owner E-mailstate: str - one of ['CUSTOMER', 'PROSPECT', 'PARTNER', 'OTHER', 'UNKNOWN]name: Optional[str]phone: Optional[str]fax: Optional[str]company: Optional[str]externalId: Optional[str]newEmail: Optional[str]birthday: Optional[datetime.date]address_streetAddress: Optional[str]address_zipCode: Optional[str]address_city: Optional[str]address_country: Optional[str]lang: Optional[str]tags: list = field(default_factory=list)removeTags: list = field(default_factory=list)forceOptOut: boolforceOptIn: boolforcePhoneOptOut: boolforcePhoneOptIn: booluseApiDoubleOptIn: boolproperties: dict = field(default_factory=dict)province: strTags / removeTags and propertiesTags and removeTags have nice methods:clientData.add_tag('XXX')clientData.remove_tag('XXX')clientData.add_removeTags('XXX')clientData.remove_removeTags('XXX')Properties have those too :)clientData.add_property('key','value')clientData.remove_property('key')Running tests VS real APITo run real tests vs REAL API some enviroment variables need to be set:TEST_REAL_API -> TrueREAL_API_KEYREAL_API_SECRETREAL_CLIENT_IDREAL_OWNERREAL_SERVER_DOMAINTo set enviroment variables usesetin Linux orexportin Windows.