parent
793162c060
commit
b2438f2981
@ -0,0 +1,13 @@
|
||||
from decimal import Decimal, InvalidOperation
|
||||
|
||||
def getInt(d, key, default):
|
||||
try:
|
||||
return int(d.get(key, default))
|
||||
except ValueError:
|
||||
return default
|
||||
|
||||
def getDecimal(d, key, default):
|
||||
try:
|
||||
return Decimal(d.get(key, default))
|
||||
except InvalidOperation:
|
||||
return default
|
@ -0,0 +1 @@
|
||||
_build/*
|
@ -0,0 +1,134 @@
|
||||
API
|
||||
===
|
||||
- explain a bit how piston/REST works
|
||||
- how to access the read/write/put/create functions
|
||||
- what this api does and what not
|
||||
|
||||
Authentication
|
||||
--------------
|
||||
- how does authentication work
|
||||
- what is the plugin authentication
|
||||
- when does a plugin need an user?
|
||||
- how to change user names
|
||||
|
||||
URLs
|
||||
----
|
||||
For more information about a specific method you can click on the url/method to get
|
||||
to the handler or the responsible method for more documentation or code.
|
||||
|
||||
**buyable/**
|
||||
:class:`item/[itemId]/ <api2.handlers.BuyableItemHandler>`
|
||||
:func:`GET <api2.handlers.BuyableItemHandler.read>`
|
||||
Get a specific item or a full/type item list.
|
||||
|
||||
========= =======================
|
||||
Parameter Description
|
||||
========= =======================
|
||||
type item belonging to type-group
|
||||
========= =======================
|
||||
|
||||
:func:`POST <api2.handlers.BuyableItemHandler.create>`
|
||||
Buy a :class:`Buyable <buyable.models.Buyable>` (requires an ItemId)
|
||||
|
||||
========= =======================================================
|
||||
Parameter Description
|
||||
========= =======================================================
|
||||
deposit Set to > 0 if you want to buy with deposit (default 0)
|
||||
amount amount of items to buy (default 1)
|
||||
========= =======================================================
|
||||
|
||||
:class:`types/ <api2.handlers.BuyableTypeHandler>`
|
||||
:func:`GET <api2.handlers.BuyableTypeHandler.read>`
|
||||
List all types which an item can belong to
|
||||
|
||||
:class:`history/ <api2.handlers.HistoryHandler>`
|
||||
:func:`GET <api2.handlers.HistoryHandler.read>`
|
||||
List the users last orders
|
||||
|
||||
========= =================
|
||||
Parameter Description
|
||||
========= =================
|
||||
num Number of entries
|
||||
========= =================
|
||||
|
||||
**account/**
|
||||
**transactions/** or **transfers/**
|
||||
:class:`transact/ or transfer/ <api2.handlers.TransactionTransactHandler>`
|
||||
:func:`GET <api2.handlers.TransactionTransactHandler.read>`
|
||||
List the users last transactions
|
||||
|
||||
========= =================
|
||||
Parameter Description
|
||||
========= =================
|
||||
num Number of entries
|
||||
========= =================
|
||||
|
||||
:func:`POST <api2.handlers.TransactionTransactHandler.create>`
|
||||
Transact money to an account
|
||||
|
||||
========= =================
|
||||
Parameter Description
|
||||
========= =================
|
||||
amount [required] Amount to add to the users account
|
||||
type [required] Type of transaction (id)
|
||||
========= =================
|
||||
|
||||
:class:`types/ <api2.handlers.TransactionTypeHandler>`
|
||||
:func:`GET <api2.handlers.TransactionTypeHandler.read>`
|
||||
List all available :class:`Transaction Types <buyable.models.TransactionType>`
|
||||
:class:`balance/ <api2.handlers.AccountBalanceHandler>`
|
||||
:func:`GET <api2.handlers.AccountBalanceHandler.read>`
|
||||
Get users account balance
|
||||
|
||||
**auth/**
|
||||
:class:`blob/ <api2.handlers.AuthBlobHandler>`
|
||||
:func:`GET <api2.handlers.AuthBlobHandler.read>`
|
||||
Return authblob if allowed or auth if str given
|
||||
(currentyl only allowed for Plugin users)
|
||||
|
||||
========= =================
|
||||
Parameter Description
|
||||
========= =================
|
||||
blob blob to get user from / auth user with, returns User or NULL
|
||||
========= =================
|
||||
|
||||
:func:`POST <api2.handlers.AuthBlobHandler.create>`
|
||||
Set authblob if allowed
|
||||
:class:`user/ <api2.handlers.AuthUserHandler>`
|
||||
:func:`GET <api2.handlers.AuthUserHandler.read>`
|
||||
get user by authblob string - this function works only when plugin
|
||||
has the :attr:`unique authblob <main.models.Plugin.uniqueAuthblob>` flag set
|
||||
|
||||
========= =================
|
||||
Parameter Description
|
||||
========= =================
|
||||
authblob [required] authblob to sear
|
||||
========= =================
|
||||
|
||||
:class:`config/ <api2.handlers.ConfigHandler>`
|
||||
:func:`GET <api2.handlers.ConfigHandler.read>`
|
||||
Display API configuration variables
|
||||
|
||||
|
||||
Handler
|
||||
-------
|
||||
.. automodule:: api2.handlers
|
||||
:members:
|
||||
|
||||
Examples
|
||||
--------
|
||||
- how to use the api
|
||||
- examples with... wget.. python-rest?
|
||||
|
||||
As normal user
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
.. note:: there will be cat content
|
||||
|
||||
wget
|
||||
""""
|
||||
wget part
|
||||
|
||||
As a plugin
|
||||
^^^^^^^^^^^
|
||||
|
Loading…
Reference in new issue