Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ciaranmccormick/hootsweet into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
ciaranmccormick committed Apr 12, 2020
2 parents 69d85e1 + 2d39608 commit 6c8f630
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 164 deletions.
30 changes: 23 additions & 7 deletions CHANGELOG.md → CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
### Future
#########
Changelog
#########

-----
0.6.5
-----

### 0.6.0

- Added method to get outbound messages
- Added method to reject messages
- Added method to get message review history

### 0.5.1
-----
0.5.1
-----

- Bug fix for issue [#11](https://github.com/ciaranmccormick/hootsweet/issues/11)
- Bug fix for issue `#11 <https://github.com/ciaranmccormick/hootsweet/issues/11>`_

### 0.5.0
-----
0.5.0
-----

- Improvements to refresh token callback

### 0.4.0
-----
0.4.0
-----

- Added /messages POST endpoint
- Added /messages/{id}/approve
- Added /messages GET
- Added /messages DELETE

### 0.3.0
-----
0.3.0
-----

- Added OAuth2 workflow for authorization
- Added script to obtain access token

### 0.2.0
-----
0.2.0
-----

- Added basic API access authorizing using an access token
- Endpoints available are;
Expand Down
75 changes: 0 additions & 75 deletions README.md

This file was deleted.

83 changes: 83 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
==========
Hootsweet
==========

.. image:: https://github.com/ciaranmccormick/hootsweet/workflows/HootSweet/badge.svg :alt: HootSweet
.. image:: https://img.shields.io/pypi/v/hootsweet :alt: PyPI
.. image:: https://img.shields.io/pypi/pyversions/hootsweet :alt: PyPI - Python Version
.. image:: https://img.shields.io/pypi/format/hootsweet :alt: PyPI - Format
.. image:: https://requires.io/github/ciaranmccormick/hootsweet/requirements.svg?branch=feature%2Freadme-rst-format-change
:target: https://requires.io/github/ciaranmccormick/hootsweet/requirements/?branch=feature%2Freadme-rst-format-change
:alt: Requirements Status

A python API for the HootSuite REST API.

------------
Installation
------------

.. code-block:: shell
pip install hootsweet
-----
Usage
-----

.. code-block:: python
from hootsweet import HootSweet
client_id = "Your-HootSuite-Client-ID"
client_secret = "Your-HootSuite-Client-Secret"
redirect_uri = "http://redirect.uri/"
def handle_refresh(token):
# callback function to save token to a database or file
save_token_to_db(token)
client = HootSweet(client_id, client_secret, redirect_uri=redirect_uri, refresh_cb=handle_refresh)
# Step 1 get authorization url from HootSuite
url, state = client.authorization_url()
# Step 2 go to url above and get OAuth2 code
token = client.fetch_token(code)
# client.token now contains your authentication token
# Step 3 (optional) refresh token periodically, this automatically calls handle_refresh
token = client.refresh_token()
# retrieve data from https://platform.hootsuite.com/v1/me
me = client.get_me()
# retrieve authenticated members organizations https://platform.hootsuite.com/v1/me/organizations
organizations = client.get_me_organizations()
Messages
=========

.. code-block:: python
token = {
"access_token": "e9a90a81-xf2d-dgh3-cfsd-23jhvn76",
"token_Type": "Bearer",
"expires_in": 2592000,
"refresh_token": "82d82cf4-76gf-gfds-nt3k-lzpo12jg",
"scope": "offline"
}
client = HootSweet("client_id", "client_secret", token=token)
# Schedule a message
text = "A message"
social_profile_ids = ["1234", "12345"]
send_time = datetime(2020, 1, 1, 12, 40, 15)
message = client.schedule_message(text=text, social_profile_ids=social_profile_ids, send_time=send_time)
# Get message
message = client.get_message(message_id="98765")
# Delete message
client.delete_message(message_id="98765")
25 changes: 25 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
SPHINXAPI ?= sphinx-apidoc
SOURCEDIR = .
MODULEDIR = ../hootsweet
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

api: Makefile
@$(SPHINXAPI) -f -o "$(SOURCEDIR)" "$(MODULEDIR)"

# 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)
63 changes: 63 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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

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


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

project = "Hootsweet"
copyright = "2020, Ciaran McCormick"
author = "Ciaran McCormick"

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


# -- 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.napoleon",
"sphinx.ext.coverage",
"sphinx_rtd_theme",
]

# 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"]

# autodoc configuration
autodoc_member_order = "bysource"


# -- 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 = "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"]
25 changes: 25 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Hootsweet
=====================================

.. image:: https://github.com/ciaranmccormick/hootsweet/workflows/HootSweet/badge.svg :alt: HootSweet
.. image:: https://img.shields.io/pypi/v/hootsweet :alt: PyPI
.. image:: https://img.shields.io/pypi/pyversions/hootsweet :alt: PyPI - Python Version
.. image:: https://img.shields.io/pypi/format/hootsweet :alt: PyPI - Format
.. image:: https://requires.io/github/ciaranmccormick/hootsweet/requirements.svg?branch=feature%2Freadme-rst-format-change
:target: https://requires.io/github/ciaranmccormick/hootsweet/requirements/?branch=feature%2Freadme-rst-format-change
:alt: Requirements Status

.. automodule:: hootsweet.api
:members:

.. toctree::
:maxdepth: 2
:caption: Contents:


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd

0 comments on commit 6c8f630

Please sign in to comment.