github.com/walkline/GoMastersLunch/pkg/v1/servers/world


Install
go get github.com/walkline/GoMastersLunch/pkg/v1/servers/world

Documentation

MastersLunch APi v2

Root api path (v2): http://api.masterslunch.masterofcode.com/v2

Required authorization header: Authorization: Bearer $token

Login

Authorization

None

  • Data Params

    {"moc_id_token": string, "device_id": string, "device_type": number}

    device_type - 1 is iOS device, 0 is android device

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "token": "KicZ1P0Z6hUZfEGSWnGtEFBFI7tkkTSbdheVUVUSKPomYNFZHwxPDgIBf8TInhkOfT38E0KcUBkTg5zfeDZI1LaIwVYhZYWOWcMaTFNB0LnhZp8P9UOsjohbw6j5YbDr",
            "expiration_time": 1443184317
        }
    }

Get info

Get information about available offices, categories and providers.
  • URL

    /info

  • Method:

    GET

  • URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "offices": [
                "matrosova",
                "paris"
            ],
            "categories": [
                "First",
                "Second",
                "Salads",
                "Deserts"
            ],
            "providers": [
                {
                    "id": 30,
                    "name": "Rostik",
                    "email": "Rostik@test.com",
                    "phone": "",
                    "order_deadline": ""
                },
                {
                    "id": 31,
                    "name": "Natalia Borisovna",
                    "email": "natalia.borisovna@test.com",
                    "phone": "",
                    "order_deadline": "09:00:00"
                }
          ]
        }
    }

Get user profile

Get short information about authorized user
  • URL

    /user

  • Method:

    GET

  • URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        response_code: 200,
        status_msg: "Success.",
        result: 
        {
            name: "admin",
            email: "gershpion@gmail.com",
            role: 7,
            office: "paris"
            "orders_count": 53,
            "fav_count": 16
        }
    }

Get user notifications config

Get user notifications config for each provider
  • URL

    /user/notifications

  • Method:

    GET

  • URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "config": [
                {
                    "provider_id": 12,
                    "menu_create": true,
                    "menu_change": false
                },
                {
                    "provider_id": 13,
                    "menu_create": true,
                    "menu_change": true
                },
                {
                    "provider_id": 14,
                    "menu_create": false,
                    "menu_change": false
                }
            ]
        }
    }

Update user notifications config

Update user notifications config for each provider
  • URL

    /user/notifications

  • Method:

    PUT

  • URL Params

None

  • Data Params
    {
        "config": [
            {
    		    "provider_id": 12,
    		    "menu_create": true,
    		    "menu_change": false
    	    },
    	    {
    		    "provider_id": 13,
    		    "menu_create": true,
    		    "menu_change": true
    	    },
    	    {
    		    "provider_id": 14,
    		    "menu_create": false,
    		    "menu_change": false
    	    }
        ]
    }
  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": null
    }

Get stats

Get user stats for current week, last weeks and last months.
  • URL

    /user/stats

  • Method:

    GET

  • Required URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "",
        "result": {
            "user_id": 9,
            "name": "admin",
            "email": "admin@example.com",
            "role": 1,
            "office": "Paris",
            "orders_count": 53
            "fav_count": 16,
            "stats": {
                "total": [
                    {
                        "total_dish": 256,
                        "total_money": "733.6599979400635",
                        "total_cal": "25334",
                        "total_weight": "10033",
                        "from": "",
                        "to": ""
                    }
                ],
                "months": [
                    {
                        "total_dish": 86,
                        "total_money": "1569.5099849700928",
                        "total_cal": "33128",
                        "total_weight": "23112",
                        "from": "2016-01-01",
                        "to": "2016-02-01"
                    },
                    {
                        "total_dish": 223,
                        "total_money": "4138.279993057251",
                        "total_cal": "181174",
                        "total_weight": "54555",
                        "from": "2016-02-01",
                        "to": "2016-03-01"
                    },
                    {
                        "total_dish": 18,
                        "total_money": "332.0999984741211",
                        "total_cal": "6604",
                        "total_weight": "4739",
                        "from": "2016-03-01",
                        "to": "2016-03-06"
                    }
                    ],
                    "weeks": [
                        {
                            "total_dish": 61,
                            "total_money": "1142.1399993896484",
                            "total_cal": "45675",
                            "total_weight": "14897",
                            "from": "2016-02-08",
                            "to": "2016-02-15"
                        },
                        {
                            "total_dish": 53,
                            "total_money": "938.2399978637695",
                            "total_cal": "30938",
                            "total_weight": "12472",
                            "from": "2016-02-15",
                            "to": "2016-02-22"
                        },
                        {
                            "total_dish": 65,
                            "total_money": "1248.7199974060059",
                            "total_cal": "56835",
                            "total_weight": "16726",
                            "from": "2016-02-22",
                            "to": "2016-02-29"
                        }
                    ]
            }
        }
    }

Update user office

Update user office
  • URL

    /user

  • Method:

    PUT

  • Required URL Params

None

  • Data Params

    {"office": string}

  • Success Response:

    • Code: 200
    • Content:
    { 
        "response_code": 200, 
        "status_msg": "Success.", 
        "result": nil
    }

Get favorites

Get favorite dishes of the user
  • URL

    /user/favorites

  • Method:

    GET

  • Required URL Params

date=integer (unix timestamp)

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": [
            {
                "id": 1,
                "provider_id": 9,
                "name": "sald",
                "description": "afddasd",
                "category": "salads",
                "price": 12,
                "weight": 300,
                "caloric": 450,
                "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/10/dish1.jpg",
                "created_at": 1442917693,
                "is_active": true,
                "is_favorite": true,
                "is_available": true,
                "is_ordered": true
            }
        ]
    }

Add dish to favorites

Add dish to list of the user's favorite dishes
  • URL

    /user/favorites/:dish_id

  • Method:

    PUT

  • Required URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": [
            {
                "id": 1,
                "provider_id": 9,
                "name": "sald",
                "description": "afddasd",
                "category": "salads",
                "price": 12,
                "weight": 300,
                "caloric": 450,
                "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/10/dish1.jpg",
                "created_at": 1442917693,
                "is_active": true,
                "is_favorite": true
            }
        ]
    }

Remove dish from favorites

Remove dish from list of user's favorite dishes
  • URL

    /user/favorites/:dish_id

  • Method:

    DELETE

  • Required URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": [
            {
                "id": 1,
                "provider_id": 9,
                "name": "sald",
                "description": "afddasd",
                "category": "salads",
                "price": 12,
                "weight": 300,
                "caloric": 450,
                "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/10/dish1.jpg",
                "created_at": 1442917693,
                "is_active": true,
                "is_favorite": true
            }
        ]
    }

Get order history

Get orders information for some date(s)
  • URL

    /orders

  • Method:

    GET

  • Required URL Params

from_date=integer (unix timestamp)

to_date=integer (unix timestamp)

or

date=integer (unix timestamp)

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "orders": [
                {
                    "user_id": 16,
                    "date": 1457960876,
                    "office": "Paris",
                    "price": 117.5,
                    "weight": 1710,
                    "caloric": 2900,
                    "dishes": [
                        {
                            "dish": 
                            {
                                "id": 11,
                                "provider_id": 9,
                                "name": "Rice and vegetables",
                                "description": "Rice and vegetables",
                                "category": "First",
                                "price": 15,
                                "weight": 230,
                                "caloric": 200,
                                "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/11/setwalls.ru-87801.jpg",
                                "created_at": 1445965596,
                                "is_active": true,
                                "is_available": false
                            },
                            "count": 2
                        },
                        {
                            "dish": 
                            {
                                "id": 25,
                                "provider_id": 9,
                                "name": "vareniki with cherries",
                                "description": "",
                                "category": "Second",
                                "price": 17.5,
                                "weight": 250,
                                "caloric": 500,
                                "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/11/setwalls.ru-87802.jpg",
                                "created_at": 1447159674,
                                "is_active": true,
                                "is_available": false
                            },
                            "count": 5
                        }
                    ]
                }
            ]
        }
    }

Get orders presence

Get orders presence status between 2 dates
  • URL

    /orders/presence

  • Method:

    GET

  • Required URL Params

from_date=integer (unix timestamp)

to_date=integer (unix timestamp)

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "orders": [
                {
                    "date": "2016-02-20",
                    "present": false
                },
                {
                    "date": "2016-02-21",
                    "present": false
                },
                {
                    "date": "2016-02-22",
                    "present": false
                },
                {
                    "date": "2016-02-23",
                    "present": false
                },
                {
                    "date": "2016-02-24",
                    "present": false
                },
                {
                    "date": "2016-02-25",
                    "present": false
                },
                {
                    "date": "2016-02-26",
                    "present": true
                },
                {
                    "date": "2016-02-27",
                    "present": false
                }
            ]
        }
    }

Get list of dishes

Get menu for provider and date
  • URL

    /dishes/provider/:provider_id/date/:date_timestamp

  • Method:

    GET

  • Required URL Params

None
  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
{
  "response_code": 200,
  "status_msg": "Success.",
  "result": {
    "dishes": [
      {
        "id": 10,
        "provider_id": 9,
        "name": "chicken shashlik",
        "description": "chicken and vegetables",
        "category": "Second",
        "price": 19,
        "weight": 200,
        "caloric": 560,
        "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/10/appp.jpg",
        "created_at": 1445965239,
        "is_active": true,
        "is_available": false,
        "count": 7,
        "is_favorite": false,
        "is_ordered": false
      },
      {
        "id": 25,
        "provider_id": 9,
        "name": "vareniki with cherries",
        "description": "",
        "category": "Deserts",
        "price": 17.5,
        "weight": 250,
        "caloric": 500,
        "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/11/800x600_vareniki-vishnya-lozhka.jpg",
        "created_at": 1447159674,
        "is_active": true,
        "is_available": false,
        "count": 15,
        "is_favorite": false,
        "is_ordered": false
      }
    ]
  }
}

Add dish to order

Add dish to list of the ordered dishes
  • URL

    /order/:order_date/office/:office/dish/:dish_id

  • Method:

    PUT

  • Required URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "order": {
                "id": 40,
                "user_id": 1,
                "date": 1452527853,
                "price": 403.05,
                "weight": 6200,
                "caloric": 6412,
                "dishes": [
                    {
                        "dish": {
                            "id": 30,
                            "provider_id": 10,
                            "name": "borscht",
                            "description": "",
                            "category": "first",
                            "price": 18.55,
                            "weight": 300,
                            "caloric": 300,
                            "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/11/vengerskiy-sup-gulyash-800-h-600.jpg",
                            "created_at": 1451392094,
                            "is_active": true,
                            "is_favorite": false
                        },
                        "count": 11
                    }
                ]
            }
        }
    }

Remove dish from order

Remove dish from list of ordered dishes
  • URL

    /order/:order_date/dish/:dish_id

  • Method:

    DELETE

  • Required URL Params

clear_all=1 (if you want to delete all entities of the dish from the order.)

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "order": {
                "id": 40,
                "user_id": 1,
                "date": 1452527853,
                "price": 403.05,
                "weight": 6200,
                "caloric": 6412,
                "dishes": [
                    {
                        "dish": {
                            "id": 30,
                            "provider_id": 10,
                            "name": "borscht",
                            "description": "",
                            "category": "first",
                            "price": 18.55,
                            "weight": 300,
                            "caloric": 300,
                            "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/11/vengerskiy-sup-gulyash-800-h-600.jpg",
                            "created_at": 1451392094,
                            "is_active": true,
                            "is_favorite": false
                        },
                        "count": 11
                    }
                ]
            }
        }
    }

Update order office

Update order office
  • URL

    /order/:order_date/office/:office

  • Method:

    PUT

  • Required URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": {
            "order": {
                "id": 40,
                "user_id": 1,
                "date": 1452527853,
                "price": 403.05,
                "office": "paris"
                "weight": 6200,
                "caloric": 6412,
                "dishes": [
                    {
                        "dish": {
                            "id": 30,
                            "provider_id": 10,
                            "name": "borscht",
                            "description": "",
                            "category": "first",
                            "price": 18.55,
                            "weight": 300,
                            "caloric": 300,
                            "image_path": "http://masterslunch.masterofcode.com/wp-content/uploads/2015/11/vengerskiy-sup-gulyash-800-h-600.jpg",
                            "created_at": 1451392094,
                            "is_active": true,
                            "is_favorite": false
                        },
                        "count": 11
                    }
                ]
            }
        }
    }

Remove order

Remove user's order
  • URL

    /order/:order_date/clear

  • Method:

    POST

  • Required URL Params

None

  • Data Params

    None

  • Success Response:

    • Code: 200
    • Content:
    { 
        "response_code": 200, 
        "status_msg": "Success.", 
        "result": nil
    }

Push messages (for admins)

Push messages.
Header with '9cdfb439c7876e703e307864c9167a15' token
  • URL

    /push

  • Method:

    POST

  • Required URL Params

    None

  • Data Params

    {message:string, specific_targets:[numbers]}

  • Success Response:

    • Code: 200
    • Content:
    {
        "response_code": 200,
        "status_msg": "Success.",
        "result": null
    }