Skip to content
thergbway edited this page Mar 14, 2016 · 41 revisions

1. Authentification

1.1 User authentification

Request: POST /auth
Request body:

{
    !"vk_access_token": STRING,
    !"vk_user_id": INTEGER,
    !"ruber_app_id": INT,
    !"ruber_app_secret": STRING
}

Request headers:
Accept=application/json
Content-Type=application/json
Response:

{
    !"ruber_access_token": STRING,
    !"id": INT
}

2. Groups

Object Group

{
    !"id": INT,  
    !"name": STRING,
    !"photo_50": STRING URL,
    !"photo_100": STRING URL,
    !"photo_200": STRING URL,
    !"market": Market
}

Object Market

{
    !"enabled": BOOLEAN,
    "items_count": INT
}
2.1 Get user groups

Request: GET /groups
Request params: count, offset, !access_token
Request headers: Accept=application/json
Response:

{
    !"count": INT,
    !"groups": Group[]
}
2.2 Edit group

Request: PUT /groups/:id where id is a POSITIVE INTEGER (group id)
Request headers:
Accept=application/json
Content-Type=application/json
Request params: !access_token
Request body:

{
    !"market": INTEGER 1 or 0,
    !"messages": INTEGER 1 or 0,
    !"market_contact": INTEGER user_id or 0(community messages)
}

Request body notes: Set messages = 1 with market_contact = user_id then make another request with market_contact = 0 if you want to set the group as a market contact.
Response status: 200 OK

3. Items

Object Item

{
    !"id": INT,
    !"owner_id": NEGATIVE_INT,
    !"title": STRING,
    !"description": STRING,
    !"price": {
           !"amount": INT,
           !"currency":{
                !"id": INT,
                !"name": STRING
           },
           !"text": STRING
    },
    !"category": {
        !"id": INT,
        !"name": STRING,
        !"section": {
            !"id": INT,
            !"name": STRING
        }
    },
    !"thumb_photo": STRING,
    !"date": INT,
    !"availability": INT
}
3.1 Get all items

Request: GET /items
Request params: !owner_id - negative integer(vk group id), count, offset, !access_token
Request headers: Accept=application/json
Response:

{
    !"count": INT,
    !"items": Item[]
}
3.2 Get item

Request: GET /items/:id, where id is item id
Request params: !owner_id - negative integer(vk group id), !access_token
Request headers: Accept=application/json
Response:

{
    !"item": Item
}
3.3 Delete item

Request: DELETE /items/:id, where id is item id
Request params: !owner_id - negative integer(vk group id), !access_token
Request headers: Accept=application/json
Response status: 204 NO CONTENT

3.4 Create new item

NOTE! This is a multipart request. You must follow the appropriate standart
Request: POST /items
Request params: !access_token
Request headers: Accept=application/json, Content-Type=multipart/form-data
Request body: link
Request body notes: item_info json part is required only. If has_photo_X param set to true in item_info json then photo_X_id or photo_X_raw should be presented. Also main_photo_id or main_photo_raw should be presented but only one of them. JPG, PNG and GIF pictures formats are supported. Min picture size is 400x400 px.
Response status: 201 CREATED
Response headers: Location: http://185.12.95.60:8081/ruber/items/128229

3.5 Edit item

NOTE! This is a multipart request. You must follow the appropriate standart
Request: PUT /items/:id where id is item id
Request params: !access_token
Request headers: Accept=application/json, Content-Type=multipart/form-data
Request body: link
Request body notes: item_info json part is required only. If has_photo_X param set to true in item_info json then photo_X_id or photo_X_raw should be presented. Also main_photo_id or main_photo_raw should be presented but only one of them. JPG, PNG and GIF pictures formats are supported. Min picture size is 400x400 px.
Response status: 200 OK

4 Orders

4.1 Add order

Request: POST /orders
Request params: !access_token
Request headers: Accept=application/json, Content-Type=application/json
Request body:

{
    !"title": STRING,
    !"customer_id": INT,
    !"created_timestamp": LONG,
    "deadline_timestamp": LONG,
    !"shipment_cost": INT,
    !"status": ENUM(WAITING, PAID, DONE, CANCELLED),
    "order_positions":[
        {
            "vk_id" : INT,
            "vk_owner_id": INT,
            !"title": STRING,
            !"description": STRING,
            !"price": INT,
            !"amount": INT,
            !"thumb_photo": STRING_URL
        },
        ...
        ]
}

Response status: 201 CREATED
Response headers: Location: http://185.12.95.60:8081/ruber/orders/11

4.2 Get order

Request: GET /orders/:id, where id is order id

Clone this wiki locally