New/Mode API Wrapper
Project description
newmode-python
Introduction
This project contains the Python API wrapper for New/Mode API.
Versions
newmode-python
uses Semantic Versioning for all changes.
Supported Python Versions
This library has been tested in Python version >= 3.7. Other Python 3.x could be supported.
Installation
Install from PyPi using pip, a package manager for Python.
pip install newmode
Don't have pip installed? Try installing it, by running this from the command line:
$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
Or, you can download the source code
(ZIP) for twilio-python
, and then run:
python setup.py install
You may need to run the above commands with sudo
.
Getting Started
Getting started with the New/Mode API couldn't be easier. Create a
Client
and you're ready to go.
API Credentials
The Client
needs your New/Mode credentials. You can either pass these
directly to the constructor (see the code below) or via environment variables.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
Alternately, a Client
constructor without these parameters will
look for NEWMODE_API_USER
and NEWMODE_API_PASSWORD
variables inside the
current environment. API version has a default value of v1.0 so
it's not required to pass this parameter.
We suggest storing your credentials as environment variables. Why? You'll never have to worry about committing your credentials and accidentally posting them somewhere public.
from Newmode import Client
client = Client()
Example usage
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
response = client.getTools()
print(response)
API Functions
getTools
Return all existing tools.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
response = client.getTools()
print(response)
getTool
Return specific tool.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"
response = client.getTool(tool_id)
print(response)
lookupTargets
Lookup for targets for a given tool.
The search parameter could be:
Empty
For custom target tools, this will return all targets.
Postal Code
For postal code tools, this will return targets matching the postal code.
Custom
For csv tools, where search is a valid search term this will return matching targets.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"
search = "XXX"
response = client.lookupTargets(tool_id, search)
print(response)
getAction
Return action information for given tool.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"
response = client.getAction(tool_id)
print(response)
runAction
Run action for given tool.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"
payload = {
"first_name": "Mark",
"last_name": "Styles",
"email_address": "lambic@pm.me",
"postal_code": "H4E 2Y7",
"email_subject": "This is my subject",
"your_letter": "This is my letter"
}
response = client.runAction(tool_id, payload)
print(response)
getTarget
Get specific target.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
target_id = "XXXXXX"
response = client.getTarget(target_id)
print(response)
getCampaigns
Get existing campaigns.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
response = client.getCampaigns()
print(response)
getCampaign
Get specific campaign.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
campaign_id = "XX"
response = client.getCampaign(campaign_id)
print(response)
getOrganizations
Get existing organizations.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
response = client.getOrganizations()
print(response)
getOrganization
Get specific organization.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
organization_id = "XX"
response = client.getOrganization(organization_id)
print(response)
getServices
Get existing services.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
response = client.getServices()
print(response)
getService
Get specific service.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
service_id = "XX"
response = client.getService(service_id)
print(response)
getOutreaches
Get existing outreaches for given tool.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
tool_id = "XX"
response = client.getOutreaches(tool_id)
print(response)
getOutreach
Get specific outreach.
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
outreach_id = "XX"
response = client.getOutreach(outreach_id)
print(response)
Paging
In order to get results paginated, you need to send params like this:
from Newmode import Client
api_user = "XXXXXXXXXXXXXXXXX"
api_password = "YYYYYYYYYYYYYYYYYY"
api_version = "v1.0"
client = Client(api_user, api_password, api_version)
params = {
'page[size]': 5,
'page[number]': 2
}
response = client.getServices(params = params)
print(response)
Publishing new versions
In order to publish new versions to Pypi.org, you need to run:
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*
Getting help
If you need help installing or using the library, please contact us.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file newmode-0.1.6.tar.gz
.
File metadata
- Download URL: newmode-0.1.6.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5dab1b7a34112c275263e04254def139ff22853aba3f080dac95ee36ed71c51 |
|
MD5 | 8a910e8bb3d5a90d58aeab5bde949ee6 |
|
BLAKE2b-256 | 7a71aa8719e8c0fd84a230d1186f79f33f3480766136c1bd06934408f23031a8 |
File details
Details for the file newmode-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: newmode-0.1.6-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 820fad657987e9d510386d32dc3c2012582ded962cac004f411db8458097fc6a |
|
MD5 | ff6a6f21b6fde434ecf518cd7a12071c |
|
BLAKE2b-256 | ba9374e88bceebbde8beaf3be0d81b2f93faacdcdf8f9da982f9e19f1b33aa17 |