Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Jul 22, 2017
1 parent 91e043c commit 518ea31
Show file tree
Hide file tree
Showing 14 changed files with 559 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ python:
# command to install dependencies
install:
- "pip install --upgrade pip"
- "pip install flake8 python-coveralls '.[tests]'"
- "pip install flake8 python-coveralls sphinx '.[tests]'"
# command to run tests
script:
- "flake8 --ignore=E501 ."
- "pytest --cov=itunesiap -vv tests/"
- "python -msphinx -M html docs build"
after_success:
- "coveralls"
- bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
Expand Down
72 changes: 32 additions & 40 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ itunes-iap v2
.. image:: https://coveralls.io/repos/github/youknowone/itunes-iap/badge.svg?branch=master
:target: https://coveralls.io/github/youknowone/itunes-iap?branch=master

Note for v1 users
The quick example
-----------------

There was breaking changes between v1 and v2 APIs.

- Specify version `0.6.6` for latest v1 API when you don't need new APIs.
- Or use `import itunesiap.legacy as itunesiap` instead of `import itunesiap`. (`from itunesiap import xxx` to `from itunesiap.legacy import xxx`)

Quick example
-------------

Create request to create a request to itunes verify api.
Create request to create a request to itunes verifying api.

.. sourcecode:: python

Expand All @@ -28,53 +20,53 @@ Create request to create a request to itunes verify api.
>>> print('invalid receipt')
>>> print response.receipt.last_in_app.product_id # other values are also available as property!

Practical values are: product_id, original_transaction_id, quantity, unique_identifier
Practically useful attributes are:
`product_id`, `original_transaction_id`, `quantity` and `unique_identifier`.

Quick example with password (Apple Shared Secret)
-------------------------------------------------
See the full document in:
- :func:`itunesiap.verify`: The verifying function.
- :class:`itunesiap.receipt.InApp`: The receipt object.

Create request to create a request to itunes verify api.

.. sourcecode:: python
Installation
------------

>>> import itunesiap
>>> try:
>>> response = itunesiap.verify(raw_data, password) # Just add password
>>> except itunesiap.exc.InvalidReceipt as e:
>>> print('invalid receipt')
>>> in_app = response.receipt.last_in_app # Get the latest receipt returned by Apple
PyPI is the recommended way.

.. sourcecode:: shell

Verification policy
-------------------
$ pip install itunesiap

Set verification mode for production or sandbox api. Review mode also available for appstore review.
To browse versions and tarballs, visit:
`<https://pypi.python.org/pypi/itunes-iap/>`_

.. sourcecode:: python

>>> import itunesiap
>>> # `review` enables both production and sandbox for appstore review. `production`, `sandbox` or `review` is available.
>>> response = request.verify(raw_data, env=itunesiap.env.review)
Apple in-review mode
--------------------

In review mode, your actual users who use older versions want to verify in
production server but the reviewers in Apple office want to verify in sandbox
server.

Or
Note: The default env is `production` mode which doesn't allow any sandbox
verifications.

You can change the verifying mode by specifying `env`.

.. sourcecode:: python

>>> import itunesiap
>>> response = itunesiap.verify(raw_data, use_sandbox=True): # additional change for current environment.
>>> # review mode
>>> itunesiap.verify(raw_data, env=itunesiap.env.review)

Proxy
-----

Put `proxy_url` for proxies.
Note for v1 users
-----------------

.. sourcecode:: python
There was breaking changes between v1 and v2 APIs.

- Specify version `0.6.6` for latest v1 API when you don't need new APIs.
- Or use `import itunesiap.legacy as itunesiap` instead of `import itunesiap`. (`from itunesiap import xxx` to `from itunesiap.legacy import xxx`)

>>> import itunesiap
>>> try:
>>> response = itunesiap.verify(raw_data, proxy_url='https://your.proxy.url/')
>>> except itunesiap.exc.InvalidReceipt as e:
>>> ...

Contributors
------------
Expand Down
183 changes: 183 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def get_version():
with open('../itunesiap/version.txt') as f:
return f.read().strip()

#
# itunes-iap documentation build configuration file, created by
# sphinx-quickstart on Sat Jul 22 17:34:06 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# 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('.'))


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

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# 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.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.coverage']

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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'itunes-iap'
copyright = '2017, Jeong YunWon'
author = 'Jeong YunWon'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = get_version()
# The full version, including alpha/beta/rc tags.
release = get_version()

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- 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 = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

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

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'itunesiapdoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'itunes-iap.tex', 'itunes-iap Documentation',
'Jeong YunWon', 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'itunes-iap', 'itunes-iap Documentation',
[author], 1)
]


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'itunes-iap', 'itunes-iap Documentation',
author, 'itunes-iap', 'One line description of project.',
'Miscellaneous'),
]


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
14 changes: 14 additions & 0 deletions docs/environment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Environment
===========

.. automodule:: itunesiap.environment


.. autoclass:: itunesiap.environment.Environment
:members:

.. autodata:: itunesiap.environment.default
.. autodata:: itunesiap.environment.production
.. autodata:: itunesiap.environment.sandbox
.. autodata:: itunesiap.environment.review
.. autodata:: itunesiap.environment.unsafe
25 changes: 25 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. itunes-iap documentation master file, created by
sphinx-quickstart on Sat Jul 22 17:34:06 2017.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
iTunes In-App purchase verification in Python
=============================================

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

quick.rst
request.rst
receipt.rst
environment.rst

.. include:: ../README.rst

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

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Loading

0 comments on commit 518ea31

Please sign in to comment.