Skip to main content

django-s-store-api is a simple store rest api of django.

Project description

django-s-store-api

django-s-store-api is a simple store rest api of django.

Installation

To install django-s-store-api like this:

pip install django-s-store-api 

Configuration

We need to hook django-s-store-api into our project.

  1. Put s_store_api into your INSTALLED_APPS at settings module:

    INSTALLED_APPS = (
        ...,
        's_store_api',
    )
    
  2. Create s_store_api database table by running:

    python manage.py migrate
    
  3. Add url patterns at project.urls module:

    from s_store_api import urls as s_store_api_urls
    
    urlpatterns = [
        ...,
        path(r'api/stores/', include(s_store_api_urls))
    ]
    

API

List stores

Show list stores which are allowed to access by login user.

method: GET
url: /api/stores/
name: s-stores:stores-list
view: StoreViewSet

Detail store

Show detail of target store.
Show detail with store items, if items parameter is true.

method: GET
url: /api/stores/<pk>/[?items=true]
name: s-stores:stores-detail
view: StoreViewSet

Open store

Open your store.
Invite user to allow access store, when set true at is_limited_access

method: POST
url: /api/stores/
parameters: 
{
    'name': 'store name', 
    'is_limited_access': True
}
name: s-stores:stores-list
view: StoreViewSet

Close store

Close your store.

method: DELETE
url: /api/stores/<pk>/
name: s-stores:stores-detail
view: StoreViewSet

Update store's info

Update your store's information

method: PUT/PATCH
url: /api/stores/<pk>/
parameters: 
{
    'name': 'changed store name', 
    'is_limited_access': False
}
name: s-stores:stores-detail
view: StoreViewSet

Hire staff

Hire staff.

method: PUT
url: /api/stores/<pk>/hire_staff/
parameters: 
{
    'staff': 2 (user's id)
}
name: s-stores:stores-hire-staff
view: StoreViewSet

Dismiss staff

Dismiss staff.

method: PUT
url: /api/stores/<pk>/dismiss_staff/
parameters: 
{
    'staff': 2 (user's id)
}
name: s-stores:stores-dismiss-staff
view: StoreViewSet

Invite user

Invite user to limited access store
Request parameter's format should be json.

method: PUT
url: /api/stores/<pk>/invite_user_to_limited_access/
parameters: 
{
    'users': [
        2 (user's id),
        4
    ]
}
name: s-stores:stores-invite-user-to-limited-access
view: StoreViewSet

List items

List items at store

method: GET
url: /api/stores/<store>/items/
name: s-stores:items-list
view: ItemViewSet

Detail item

Detail item at store

method: GET
url: /api/stores/<store>/items/<pk>/
name: s-stores:items-detail
view: ItemViewSet

Buy item

Buy item from store. You received item in bag and receipt.

method: POST
url: /api/stores/<store>/items/{pk}/buy/
parameters: 
{
    'price': 2 (item.price.pk)
}
name: s-stores:items-buy
view: ItemViewSet

Sell item

Sell item to store. Request parameter's format should be json.

method: POST
url: /api/stores/<store>/items/
parameters: 
{
    'name': 'new_item',
    'prices_set': [
        {'coin_id': 2 (coin.pk), 'value': 100},
        {'coin_id': 3 (coin.pk), 'value': 10},
    ]
}
name: stores:items-list
view: ItemViewSet

Set prices

Set prices to exists item. Request parameter's format should be json.

method: POST
url: /api/stores/items/<item>/prices
parameters: 
[
    {'coin_id': 4 (coin.pk), 'value': 1000},
    {'coin_id': 5 (coin.pk), 'value': 11},
]
name: s-stores:prices-list
view: PriceViewSet

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-s-store-api-1.0.0.tar.gz (16.5 kB view hashes)

Uploaded source

Built Distribution

django_s_store_api-1.0.0-py3-none-any.whl (33.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page