# newmode-python
## Introduction
This project contains the Python API wrapper for New/Mode API.
## Versions
`newmode-python` uses [Semantic Versioning](https://semver.org) 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](http://www.pip-installer.org/en/latest/), 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)](https://github.com/twilio/twilio-python/zipball/master "twilio-python
source code") 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.
```python
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.
```python
from Newmode import Client
client = Client()
```
### Example usage
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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.
```python
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:
```python
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](https://www.newmode.net/contact).
Raw data
{
"_id": null,
"home_page": "https://github.com/NewMode/python",
"name": "newmode",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "New/Mode",
"author_email": "info@newmode.net",
"download_url": "https://files.pythonhosted.org/packages/7a/71/aa8719e8c0fd84a230d1186f79f33f3480766136c1bd06934408f23031a8/newmode-0.1.6.tar.gz",
"platform": "",
"description": "# newmode-python\n\n## Introduction\n\nThis project contains the Python API wrapper for New/Mode API.\n\n## Versions\n\n`newmode-python` uses [Semantic Versioning](https://semver.org) for all changes.\n\n\n### Supported Python Versions\n\nThis library has been tested in Python version >= 3.7. Other Python 3.x could be supported.\n\n## Installation\n\nInstall from PyPi using [pip](http://www.pip-installer.org/en/latest/), a\npackage manager for Python.\n\n pip install newmode\n\nDon't have pip installed? Try installing it, by running this from the command\nline:\n\n $ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python\n\nOr, you can [download the source code\n(ZIP)](https://github.com/twilio/twilio-python/zipball/master \"twilio-python\nsource code\") for `twilio-python`, and then run:\n\n python setup.py install\n\nYou may need to run the above commands with `sudo`.\n\n## Getting Started\n\nGetting started with the New/Mode API couldn't be easier. Create a\n`Client` and you're ready to go.\n\n### API Credentials\n\nThe `Client` needs your New/Mode credentials. You can either pass these\ndirectly to the constructor (see the code below) or via environment variables.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\n```\n\nAlternately, a `Client` constructor without these parameters will\nlook for `NEWMODE_API_USER` and `NEWMODE_API_PASSWORD` variables inside the\ncurrent environment. API version has a default value of v1.0 so\nit's not required to pass this parameter.\n\nWe suggest storing your credentials as environment variables. Why? You'll never\nhave to worry about committing your credentials and accidentally posting them\nsomewhere public.\n\n\n```python\nfrom Newmode import Client\nclient = Client()\n```\n\n### Example usage\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\n\nresponse = client.getTools()\nprint(response)\n```\n\n### API Functions\n\n#### getTools\n\nReturn all existing tools.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\n\nresponse = client.getTools()\nprint(response)\n```\n\n#### getTool\n\nReturn specific tool.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\ntool_id = \"XX\"\n\nresponse = client.getTool(tool_id)\nprint(response)\n```\n\n#### lookupTargets\n\nLookup for targets for a given tool.\n\nThe search parameter could be:\n\n##### Empty\n\nFor custom target tools, this will return all targets.\n\n##### Postal Code\n\nFor postal code tools, this will return targets matching the postal code.\n\n##### Custom\n\nFor csv tools, where search is a valid search term this will return matching targets.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\ntool_id = \"XX\"\nsearch = \"XXX\"\n\nresponse = client.lookupTargets(tool_id, search)\nprint(response)\n```\n\n#### getAction\n\nReturn action information for given tool.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\ntool_id = \"XX\"\n\nresponse = client.getAction(tool_id)\nprint(response)\n```\n\n#### runAction\n\nRun action for given tool.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\ntool_id = \"XX\"\n\npayload = {\n\t\"first_name\": \"Mark\",\n\t\"last_name\": \"Styles\",\n\t\"email_address\": \"lambic@pm.me\",\n\t\"postal_code\": \"H4E 2Y7\",\n\t\"email_subject\": \"This is my subject\",\n\t\"your_letter\": \"This is my letter\"\n}\n\nresponse = client.runAction(tool_id, payload)\nprint(response)\n```\n\n#### getTarget\n\nGet specific target.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\ntarget_id = \"XXXXXX\"\n\nresponse = client.getTarget(target_id)\nprint(response)\n```\n\n#### getCampaigns\n\nGet existing campaigns.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\n\nresponse = client.getCampaigns()\nprint(response)\n```\n\n#### getCampaign\n\nGet specific campaign.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\ncampaign_id = \"XX\"\n\nresponse = client.getCampaign(campaign_id)\nprint(response)\n```\n\n\n#### getOrganizations\n\nGet existing organizations.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\n\nresponse = client.getOrganizations()\nprint(response)\n```\n\n#### getOrganization\n\nGet specific organization.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\norganization_id = \"XX\"\n\nresponse = client.getOrganization(organization_id)\nprint(response)\n```\n\n#### getServices\n\nGet existing services.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\n\nresponse = client.getServices()\nprint(response)\n```\n\n#### getService\n\nGet specific service.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\nservice_id = \"XX\"\n\nresponse = client.getService(service_id)\nprint(response)\n```\n\n#### getOutreaches\n\nGet existing outreaches for given tool.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\ntool_id = \"XX\"\n\nresponse = client.getOutreaches(tool_id)\nprint(response)\n```\n\n#### getOutreach\n\nGet specific outreach.\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\noutreach_id = \"XX\"\n\nresponse = client.getOutreach(outreach_id)\nprint(response)\n```\n\n### Paging\n\nIn order to get results paginated, you need to send params like this:\n\n```python\nfrom Newmode import Client\n\napi_user = \"XXXXXXXXXXXXXXXXX\"\napi_password = \"YYYYYYYYYYYYYYYYYY\"\napi_version = \"v1.0\"\nclient = Client(api_user, api_password, api_version)\n\nparams = {\n\t'page[size]': 5,\n\t'page[number]': 2\n}\n\nresponse = client.getServices(params = params)\nprint(response)\n```\n\n### Publishing new versions\n\nIn order to publish new versions to Pypi.org, you need to run:\n\n```\npython3 setup.py sdist bdist_wheel\npython3 -m twine upload dist/*\n```\n\n### Getting help\n\nIf you need help installing or using the library, please [contact us](https://www.newmode.net/contact).\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "New/Mode API Wrapper",
"version": "0.1.6",
"project_urls": {
"Homepage": "https://github.com/NewMode/python"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ba9374e88bceebbde8beaf3be0d81b2f93faacdcdf8f9da982f9e19f1b33aa17",
"md5": "ff6a6f21b6fde434ecf518cd7a12071c",
"sha256": "820fad657987e9d510386d32dc3c2012582ded962cac004f411db8458097fc6a"
},
"downloads": -1,
"filename": "newmode-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ff6a6f21b6fde434ecf518cd7a12071c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5457,
"upload_time": "2020-03-27T14:30:07",
"upload_time_iso_8601": "2020-03-27T14:30:07.152797Z",
"url": "https://files.pythonhosted.org/packages/ba/93/74e88bceebbde8beaf3be0d81b2f93faacdcdf8f9da982f9e19f1b33aa17/newmode-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7a71aa8719e8c0fd84a230d1186f79f33f3480766136c1bd06934408f23031a8",
"md5": "8a910e8bb3d5a90d58aeab5bde949ee6",
"sha256": "e5dab1b7a34112c275263e04254def139ff22853aba3f080dac95ee36ed71c51"
},
"downloads": -1,
"filename": "newmode-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "8a910e8bb3d5a90d58aeab5bde949ee6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4848,
"upload_time": "2020-03-27T14:30:14",
"upload_time_iso_8601": "2020-03-27T14:30:14.060375Z",
"url": "https://files.pythonhosted.org/packages/7a/71/aa8719e8c0fd84a230d1186f79f33f3480766136c1bd06934408f23031a8/newmode-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-03-27 14:30:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NewMode",
"github_project": "python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "newmode"
}