parent
ad792b6747
commit
c7ad4be6e4
@ -0,0 +1,72 @@
|
||||
API
|
||||
kaufen
|
||||
produkte
|
||||
auflisten
|
||||
alle, nach gruppe
|
||||
produktgruppen auflisten
|
||||
suchen nach namen
|
||||
hasDeposit falls kein attribut
|
||||
beliebteste produkte (allgemein, nur vom user)
|
||||
kaufen eines items (mit oder ohne deposit)
|
||||
pfand zurückgeben
|
||||
letzte einkäufe
|
||||
|
||||
|
||||
transaction
|
||||
auflisten zahlarten (bar, ueberweisung, ...)
|
||||
einzahlen
|
||||
auszahlen
|
||||
letzte einzahlungen
|
||||
|
||||
api auth stuff
|
||||
if plugin identifies by authblob
|
||||
getUsersByAuthBlob (oderso)
|
||||
else
|
||||
authenticateUser(user, authblob)
|
||||
listAuthBlobs (fuer alle user, die das plugin erlaubt haben)
|
||||
canSuAsUser (noch ordentlich zu benennen)
|
||||
|
||||
|
||||
|
||||
cool wäre:
|
||||
irgendwann letzte Änderung der produktliste speichern
|
||||
|
||||
=== REST LIKE API STARTS HERE ===
|
||||
|
||||
buyable/
|
||||
item/
|
||||
GET (=list)
|
||||
""" get a specific item or a full (group) item list """
|
||||
group item belonging to group
|
||||
id item with id
|
||||
POST (=buy)
|
||||
""" buy an item"
|
||||
id [REQ] buy item with id
|
||||
deposit
|
||||
types/
|
||||
GET (=list)
|
||||
""" list all types (groups) which an item can belong to """
|
||||
|
||||
transaction/
|
||||
transact/
|
||||
GET (=list)
|
||||
""" list your transactions """
|
||||
num list $num entries
|
||||
POST (=pay)
|
||||
""" actually transact money """
|
||||
amount [REQ] amount to add to your account
|
||||
type [REQ] type of transaction (id)
|
||||
types/
|
||||
GET (=list)
|
||||
""" list all available transaction types"
|
||||
auth/
|
||||
blob/
|
||||
GET (=get)
|
||||
""" return authblob if allowed or auth if str given """
|
||||
blob blob to get user from / auth user with, returns User or NULL
|
||||
POST
|
||||
""" set authblob if allowed """
|
||||
|
||||
|
||||
|
||||
wget -q -O- --auth-no-challenge --http-user=seba -http-password=foobar23 http://devcat.someserver.de:13805/api2/buyable/item/foo
|
@ -0,0 +1,27 @@
|
||||
from piston.handler import BaseHandler
|
||||
from k4ever.buyable.models import *
|
||||
from k4ever.transaction.models import *
|
||||
|
||||
class BuyableItemHandler(BaseHandler):
|
||||
allowed_methods = ('GET', 'POST')
|
||||
#fields = ('id', 'description')
|
||||
model = Buyable
|
||||
exclude = ('_state',)
|
||||
|
||||
#def read(self, request):
|
||||
# return Buyable.objects.get(id=1)
|
||||
|
||||
class BuyableTypeHandler(BaseHandler):
|
||||
allowed_methods = ('GET',)
|
||||
model = BuyableType
|
||||
|
||||
class TransactionTransactHandler(BaseHandler):
|
||||
allowed_methods = ('GET', 'POST')
|
||||
model = Transaction
|
||||
|
||||
class TransactionTypeHandler(BaseHandler):
|
||||
allowed_methods = ('GET',)
|
||||
model = TransactionType
|
||||
|
||||
class AuthBlobHandler(BaseHandler):
|
||||
pass
|
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
@ -0,0 +1,23 @@
|
||||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
|
||||
Replace these with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.failUnlessEqual(1 + 1, 2)
|
||||
|
||||
__test__ = {"doctest": """
|
||||
Another way to test that 1 + 1 is equal to 2.
|
||||
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
|
@ -0,0 +1,26 @@
|
||||
from django.conf.urls.defaults import *
|
||||
from piston.resource import Resource
|
||||
from piston.authentication import HttpBasicAuthentication
|
||||
from api2.handlers import *
|
||||
|
||||
auth = HttpBasicAuthentication(realm="Freitagsrundenkassensystemapi")
|
||||
ad = {'authentication': auth}
|
||||
|
||||
buyableItemRes = Resource(handler=BuyableItemHandler, **ad)
|
||||
buyableTypeRes = Resource(handler=BuyableTypeHandler, **ad)
|
||||
|
||||
transactionTransactRes = Resource(handler=TransactionTransactHandler, **ad)
|
||||
transactionTypeRes = Resource(handler=TransactionTypeHandler, **ad)
|
||||
|
||||
authBlobRes = Resource(handler=AuthBlobHandler, **ad)
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'buyable/item/', buyableItemRes),
|
||||
url(r'buyable/types/', buyableTypeRes),
|
||||
|
||||
url(r'transaction/transact/', transactionTransactRes),
|
||||
url(r'transaction/types/', transactionTypeRes),
|
||||
|
||||
url(r'auth/blob/', authBlobRes),
|
||||
)
|
||||
|
@ -0,0 +1 @@
|
||||
# Create your views here.
|
Loading…
Reference in new issue