Skip to content

Commit

Permalink
initialize radar-python
Browse files Browse the repository at this point in the history
  • Loading branch information
corypisano committed Mar 16, 2020
1 parent c1162cf commit dd79959
Show file tree
Hide file tree
Showing 63 changed files with 3,067 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,24 @@
version: 2
jobs:
build:
docker:
- image: circleci/python:3.7.6
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}
- run:
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements-dev.txt
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}
paths:
- "venv"
- run:
name: Lint
command: make lint
- run:
name: Run tests
command: make test
130 changes: 130 additions & 0 deletions .gitignore
@@ -0,0 +1,130 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
.vscode/
47 changes: 47 additions & 0 deletions Makefile
@@ -0,0 +1,47 @@
.PHONY: lint fmt test docs clean package

VENV_NAME?=venv

default:
@echo "Makefile for $(PACKAGE_NAME)"
@echo
@echo 'Usage:'
@echo
@echo ' make venv setup virtual environment for development'
@echo ' make lint check lint output with black'
@echo ' make fmt auto format code with black'
@echo ' make test run the tests on all Python versions'
@echo ' make docs update documentation using Sphinx'
@echo ' make clean cleanup all temporary files'
@echo ' make package build and setup for packaging'
@echo

venv: . $(VENV_NAME)/bin/activate
$(VENV_NAME)/bin/activate: requirements-dev.txt
pip install --upgrade pip virtualenv
@test -d $(VENV_NAME) || python -m virtualenv --clear $(VENV_NAME)
$(VENV_NAME)/bin/pip install -Ur requirements-dev.txt
@touch $(VENV_NAME)/bin/activate

lint: venv
${VENV_NAME}/bin/black . --check --diff

fmt: venv
${VENV_NAME}/bin/black .

test: venv
${VENV_NAME}/bin/tox .

docs: venv
$(VENV_NAME)/bin/pip install -Ur requirements-docs.txt
cd docs && sphinx-build -nb html -d build/doctrees . build/html

clean:
@rm -rf $(VENV_NAME) build/ dist/ docs/build/
find . -name \*.pyc -delete

package: venv
pip install --quiet twine
rm -rf dist/*
python setup.py sdist bdist_wheel
twine upload dist/*
92 changes: 92 additions & 0 deletions README.md
@@ -0,0 +1,92 @@
# radar-python
Python library for the Radar API https://radar.io/documentation/api

The Radar Python library provides convenient access to Radar's APIs from
your python applications or command line.

[![CircleCI](https://circleci.com/gh/radarlabs/server.svg?style=svg)](https://circleci.com/gh/radarlabs/server)

# Installation

You don't need this source code unless you want to modify the package. If you just want to use the package, just run:

```sh
pip install radar-python
```

## Requirements
Python 3.4+ (PyPy supported)

# Documentation
See the [Python API docs](https://readthedocs.org).

# Usage

The radar client needs to be initialized with your project’s secret key which is available in your [Radar Dashboard](https://radar.io/dashboard/settings).

```python
import os
from radar import RadarClient

# initialize client
radar = RadarClient(os.environ["RADAR_SECRET_KEY"])

# get a geofence by id
geofence = radar.geofences.get(id='123')

# list geofences
radar.geofences.list()
```


# Full Endpoint List:
### Users:
```
radar.users.list
radar.users.get(id='1')
radar.users.delete(id='1')
```

### Geofences
```
radar.geofences.list()
radar.geofences.get(id=’123’)
radar.geofences.get(tag=’store’, externalId=’123’)
radar.geofences.list_users(id='123')
radar.geofences.create({ 'type': 'circle', ... })
radar.geofences.delete(id='123')
radar.geofences.delete(tag=’store’, externalId=’123’)
```

### Events
```
radar.events.list()
radar.events.get(id='123')
radar.events.delete(id='123')
radar.events.verify(id='123', 'accept')
```

### Context
```
radar.context.get(coordinates=(40.7041895, -73.9867797))
```

### Geocoding
```
radar.geocode.forward(query=’20 jay st brooklyn’)
radar.geocode.reverse(coordinates=(40.7041895, -73.9867797))
radar.geocode.ip(ip=’107.77.199.117’)
```

### Search
```
radar.search.users(near=[lat,long])
radar.search.geofences(near=[lat,long])
radar.search.places(near=[lat,long])
radar.search.autocomplete(query=’20 jay st’, near=[lat, long])
```

### Routing
```
radar.route.distance(origin=[lat,lng], destination=[lat,lng], modes=’car’, units=’metric’)
```
20 changes: 20 additions & 0 deletions docs/Makefile
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
67 changes: 67 additions & 0 deletions docs/conf.py
@@ -0,0 +1,67 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys
import sphinx_rtd_theme

sys.path.insert(0, os.path.abspath(".."))

from radar.version import VERSION
import radar
import examples

# -- Project information -----------------------------------------------------

project = "radar-python"
copyright = "2020, Radar"
author = "Radar"

# The full version, including alpha/beta/rc tags
release = VERSION


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
]


# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


pygments_style = "sphinx"

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = "classic"
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

0 comments on commit dd79959

Please sign in to comment.