Skip to content
thergbway edited this page Mar 26, 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
}

Exceptions: INVALID_EXTERNAL_APP_CREDENTIALS

2 Orders

2.1 Add order

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

{
    !"title": STRING,
    "description": STRING,
    !"status": ENUM("WAITING", "PAID", "DONE", "CANCELLED"),
    "deadline_timestamp": LONG or NULL,
    !"customer": {
        !"name": STRING,
        !"phone": STRING,
        "vk_id": INTEGER or NULL
    },
    "shipment": {
        !"address": STRING,
        !"cost": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99"
    },
    "discount": {
        !"title": STRING,
        !"description": STRING,
        !"thumb_photo": URL e.g. "http://google.com/pic1",
        !"cost": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99"
    },
    !"item_replicas": [
        {
            !"title": STRING,
            !"description": STRING,
            !"thumb_photo": URL e.g. "http://google.com/pic1",
            !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
            !"amount": INTEGER    
        },
        ...        
    ],
    !"vk_item_replicas": [
        {
            !"title": STRING,
            !"description": STRING,
            !"thumb_photo": URL e.g. "http://google.com/pic1",
            !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
            !"amount": INTEGER,
            !"vk_id": INTEGER,
            !"vk_owner_id": INTEGER    
        },
        ...        
    ]
}

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

2.2 Get order by id

Request: GET /orders/{id}
Request params: !access_token
Request headers: Accept=application/json
Response:

{
    !"id": INTEGER,
    !"title": STRING,
    "description": STRING,
    !"status": ENUM("WAITING", "PAID", "DONE", "CANCELLED"),
    !"created_timestamp": LONG,
    !"deadline_timestamp": LONG or NULL,
    !"customer": {
        !"name": STRING,
        !"phone": STRING,
        !"vk_id": INTEGER or NULL
    },
    !"shipment": NULL or {
        !"address": STRING,
        !"cost": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99"
    },
    !"discount": NULL or {
        !"title": STRING,
        !"description": STRING,
        !"thumb_photo": URL e.g. "http://google.com/pic1",
        !"cost": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99"
    },
    !"item_replicas": [
        {
            !"id": INTEGER,
            !"title": STRING,
            !"description": STRING,
            !"thumb_photo": URL e.g. "http://google.com/pic1",
            !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
            !"amount": INTEGER    
        },
        ...        
    ],
    !"vk_item_replicas": [
        {
            !"id": INTEGER,
            !"title": STRING,
            !"description": STRING,
            !"thumb_photo": URL e.g. "http://google.com/pic1",
            !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
            !"amount": INTEGER,
            !"vk_id": INTEGER,
            !"vk_owner_id": INTEGER    
        },
        ...        
    ]
}

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

2.3 Get orders

Request: GET /orders
Request params: !access_token
Request headers: Accept=application/json
Response:

[
    {
        !"id": INTEGER,
        !"title": STRING,
        !"description": STRING,
        !"status":  ENUM("WAITING", "PAID", "DONE", "CANCELLED"),
        !"order_positions": INTEGER,
        !"pinned_items": INTEGER
    },
    ...
]

Exceptions: INVALID_ACCESS_TOKEN

2.4 Edit order

Request: PUT /orders/{id}
Request params: !access_token
Request headers: Content-Type=application/json
Request body:

{
    "title": STRING,
    "description": STRING,
    "status": ENUM("WAITING", "PAID", "DONE", "CANCELLED"),
    "deadline_timestamp": LONG or NULL,
    "discount": NULL or {
        "title": STRING,
        "description": STRING,
        "thumb_photo": URL e.g. "http://google.com/pic1",
        "cost": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99"
    },
    "shipment": NULL or {
        "address": STRING,
        "cost": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99"
    },
    "customer": {
        "name": STRING,
        "phone": STRING,
        "vk_id": INTEGER or NULL
    }
}

Response status: 200 OK
Exceptions: INVALID_ACCESS_TOKEN, INVALID_REQUEST_JSON, NO_SUCH_ORDER, NOT_ENOUGH_ARGUMENTS if you try to create(not update) discount or shipment or deadline_timestamp but not specified some fields.

3 Order positions

3.1 Item replicas

3.1.1 Get item replica by id

Request: GET /orders/{order_id}/item_replicas/{replica_id}
Request params: !access_token
Request headers: Accept=application/json
Response body:

{
    !"id": INTEGER,
    !"title": STRING,
    !"description": STRING,
    !"thumb_photo": URL e.g. "http://google.com/pic1",
    !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
    !"amount": INTEGER
}

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_ORDER_POSITION

3.1.2 Get item replicas

Request: GET /orders/{order_id}/item_replicas
Request params: !access_token
Request headers: Accept=application/json
Response body:

[
    {
        !"id": INTEGER,
        !"title": STRING,
        !"description": STRING,
        !"thumb_photo": URL e.g. "http://google.com/pic1",
        !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
        !"amount": INTEGER
    },
    ...
]

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

3.1.3 Delete item replica

Request: DELETE /orders/{order_id}/item_replicas/{replica_id}
Request params: !access_token
Request headers: -
Response status: 204 NO CONTENT
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_ORDER_POSITION

3.1.4 Add item replica

Request: POST /orders/{order_id}/item_replicas
Request params: !access_token
Request headers: Content-Type=application/json
Request body:

{
    !"title": STRING,
    !"description": STRING,
    !"thumb_photo": URL e.g. "http://google.com/pic1",
    !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
    !"amount": INTEGER
}

Response status: 201 CREATED
Response headers: Location: http://185.12.95.60:8081/ruber/orders/11/item_replicas/14
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

3.2 Vk Item replicas

3.2.1 Get vk item replica by id

Request: GET /orders/{order_id}/vk_item_replicas/{replica_id}
Request params: !access_token
Request headers: Accept=application/json
Response body:

{
    !"id": INTEGER,
    !"title": STRING,
    !"description": STRING,
    !"thumb_photo": URL e.g. "http://google.com/pic1",
    !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
    !"amount": INTEGER,
    !"vk_id": INTEGER,
    !"vk_owner_id": INTEGER
}

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_ORDER_POSITION

3.2.2 Get vk item replicas

Request: GET /orders/{order_id}/vk_item_replicas
Request params: !access_token
Request headers: Accept=application/json
Response body:

[
    {
        !"id": INTEGER,
        !"title": STRING,
        !"description": STRING,
        !"thumb_photo": URL e.g. "http://google.com/pic1",
        !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
        !"amount": INTEGER,
        !"vk_id": INTEGER,
        !"vk_owner_id": INTEGER
    },
    ...
]

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

3.2.3 Delete vk item replica

Request: DELETE /orders/{order_id}/vk_item_replicas/{replica_id}
Request params: !access_token
Request headers: -
Response status: 204 NO CONTENT
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_ORDER_POSITION

3.2.4 Add vk item replica

Request: POST /orders/{order_id}/vk_item_replicas
Request params: !access_token
Request headers: Content-Type=application/json
Request body:

{
    !"title": STRING,
    !"description": STRING,
    !"thumb_photo": URL e.g. "http://google.com/pic1",
    !"price": POSITIVE BIGDECIMAL(scale = 2) e.g. "14.99",
    !"amount": INTEGER,
    !"vk_id": INTEGER,
    !"vk_owner_id": INTEGER
}

Response status: 201 CREATED
Response headers: Location: http://185.12.95.60:8081/ruber/orders/11/vk_item_replicas/14
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

4 Pinned messages for Order

4.1 Get pinned message by id

Request: GET /orders/{order_id}/pinned_messages/{message_id}
Request params: !access_token
Request headers: Accept=application/json
Response body:

{
    !"id": INTEGER,
    !"position": INTEGER,
    !"vk_message_id": LONG,
    !"created_timestamp": LONG
}

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_PINNED_ITEM

4.2 Get pinned messages

Request: GET /orders/{order_id}/pinned_messages
Request params: !access_token
Request headers: Accept=application/json
Response body:

[
    {
        !"id": INTEGER,
        !"position": INTEGER,
        !"vk_message_id": LONG,
        !"created_timestamp": LONG
    },
    ...
]

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

4.3 Delete pinned message

Request: DELETE /orders/{order_id}/pinned_messages/{message_id}
Request params: !access_token
Request headers: -
Response status: 204 NO CONTENT
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_PINNED_ITEM

4.4 Add pinned message

Request: POST /orders/{order_id}/pinned_messages
Request params: !access_token
Request headers: Content-Type=application/json
Request body:

{
    !"position": INTEGER,
    !"vk_message_id": LONG
}

Response status: 201 CREATED
Response headers: Location: http://185.12.95.60:8081/ruber/orders/11/pinned_messages/14
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

5 Pinned texts for Order

5.1 Get pinned text by id

Request: GET /orders/{order_id}/pinned_texts/{text_id}
Request params: !access_token
Request headers: Accept=application/json
Response body:

{
    !"id": INTEGER,
    !"position": INTEGER,
    !"text": STRING,
    !"created_timestamp": LONG
}

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_PINNED_ITEM

5.2 Get pinned texts

Request: GET /orders/{order_id}/pinned_texts
Request params: !access_token
Request headers: Accept=application/json
Response body:

[
    {
        !"id": INTEGER,
        !"position": INTEGER,
        !"text": STRING,
        !"created_timestamp": LONG
    },
    ...
]

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

5.3 Delete pinned text

Request: DELETE /orders/{order_id}/pinned_texts/{text_id}
Request params: !access_token
Request headers: -
Response status: 204 NO CONTENT
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_PINNED_ITEM

5.4 Add pinned text

Request: POST /orders/{order_id}/pinned_texts
Request params: !access_token
Request headers: Content-Type=application/json
Request body:

{
    !"position": INTEGER,
    !"text": STRING
}

Response status: 201 CREATED
Response headers: Location: http://185.12.95.60:8081/ruber/orders/11/pinned_texts/14
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

6 Pinned files for Order

6.1 Get pinned file by id

Request: GET /orders/{order_id}/pinned_files/{file_id}
Request params: !access_token
Request headers: Accept=application/json
Response body:

{
    !"id": INTEGER,
    !"position": INTEGER,
    !"file_name": STRING,
    !"created_timestamp": LONG
}

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_PINNED_ITEM

6.2 Get pinned files

Request: GET /orders/{order_id}/pinned_files
Request params: !access_token
Request headers: Accept=application/json
Response body:

[
    {
        !"id": INTEGER,
        !"position": INTEGER,
        !"file_name": STRING,
        !"created_timestamp": LONG
    },
    ...
]

Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER

6.3 Download pinned file content by id

Request: GET /orders/{order_id}/pinned_files/{file_id}/content
Request params: !access_token
Request headers: Accept=application/octet-stream
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_PINNED_ITEM

6.4 Delete pinned file

Request: DELETE /orders/{order_id}/pinned_files/{file_id}
Request params: !access_token
Request headers: -
Response status: 204 NO CONTENT
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, NO_SUCH_PINNED_ITEM

6.5 Add pinned file

NOTE! This is a multipart request. You must follow the appropriate standart
Request: POST /orders/{order_id}/pinned_files/{file_id}
Request params: !access_token
Request headers: Accept=application/json, Content-Type=multipart/form-data; boundary={boundary}
Request body: link
Request notes: do not forget about the boundary in Content-Type=multipart/form-data header. You must set the position parameter for this pinned file in requeset body. See the request body link.
Response status: 201 CREATED
Response headers: Location: http://185.12.95.60:8081/ruber/orders/12/pinned_files/43
Exceptions: INVALID_ACCESS_TOKEN, NO_SUCH_ORDER, MULTIPART_IO_EXCEPTION

7 Connected Vk groups

7.1 Get connected vk groups

Request: GET /connected_groups
Request params: !access_token
Request headers: Accept=application/json
Response body:

[
    INTEGER,
    INTEGER,
    INTEGER,
    ...
]

Exceptions: INVALID_ACCESS_TOKEN

7.2 Add connected vk group

Request: POST /connected_groups
Request params: !access_token
Request headers: Content-Type=application/json
Request body:

{
    !"vk_group_id": INTEGER
}

Response status: 201 CREATED
Exceptions: INVALID_ACCESS_TOKEN, INVALID_REQUEST_JSON if vk_group_id is missed or null

7.3 Delete connected vk group

Request: DELETE /connected_groups/{vk_group_id}
Request params: !access_token
Request headers: -
Response status: 204 NO CONTENT
Exceptions: INVALID_ACCESS_TOKEN

Clone this wiki locally