Skip to content
thergbway edited this page Feb 24, 2016 · 41 revisions

1. Authentification

1.1 User authentification

Request: POST /auth
Request body:

{
    !"code": STRING,
    !"redirect_uri": STRING,
    !"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,
    !"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[]
}

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:

----boundary
Content-Disposition: form-data; name="item_info"

{
    !"owner_id"; NEGATIVE INTEGER,
    !"name": STRING FROM 4 TO 100 SYMBOLS INCLUSIVE,
    !"description": STRING FROM 10 SYMBOLS,
    !"category_id": INTEGER,
    !"price": DOUBLE MIN 0.01,
    !"deleted": INTEGER 0 OR 1,
    
    /*NOTE. Crop parameters can be presented together either none of them*/
    "main_photo_crop_x": INTEGER UNKNOWN LIMITS,
    "main_photo_crop_y": INTEGER UNKNOWN LIMITS,
    "main_photo_crop_width": INTEGER MIN 200,
    
    !"has_photo_1": BOOLEAN,
    !"has_photo_2": BOOLEAN,
    !"has_photo_3": BOOLEAN,
    !"has_photo_4": BOOLEAN
}
----boundary
Content-Disposition: form-data; name="main_photo_raw"; filename="some_file_name.jpg"
Content-Type: image/jpeg

FILE_DATA
----boundary
Content-Disposition: form-data; name="photo_1_raw"; filename="some_file_name.jpg"
Content-Type: image/jpeg

FILE_DATA
----boundary
Content-Disposition: form-data; name="photo_2_raw"; filename="some_file_name.jpg"
Content-Type: image/jpeg

FILE_DATA
----boundary
Content-Disposition: form-data; name="photo_3_raw"; filename="some_file_name.jpg"
Content-Type: image/jpeg

FILE_DATA
----boundary
Content-Disposition: form-data; name="photo_4_raw"; filename="some_file_name.jpg"
Content-Type: image/jpeg

FILE_DATA
----boundary
Content-Disposition: form-data; name="main_photo_id"

PHOTO_ID_AS_INTEGER
----boundary
Content-Disposition: form-data; name="photo_1_id"

PHOTO_ID_AS_INTEGER
----boundary
Content-Disposition: form-data; name="photo_2_id"

PHOTO_ID_AS_INTEGER
----boundary
Content-Disposition: form-data; name="photo_3_id"

PHOTO_ID_AS_INTEGER
----boundary
Content-Disposition: form-data; name="photo_4_id"

PHOTO_ID_AS_INTEGER

Request body notes: 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

Clone this wiki locally