API Integration - how hard is it?

Hi guys,

I’m currently trying to use gloriafood.com to offer an online ordering system for my restaurant. At the moment they use an android app to process the order and then print to a limited number of thermal printers on a network. I have asked for other ways of trying to get the orders printed and one option was to integrate their API into sambapos. Can someone advise how difficult this may be as I’ve not got any experience doing this. Their link to the api is as follows:

https://github.com/GloriaFood/pos_docs/tree/master/version%202

I was wondering if someone can take a look at this for me and see where we go from there.

Thanks

Looks of it they are push POST’ing the order to your own website.
That’s great but unfortunately pretty sure this would currently work to POST directly in to Samba - @QMcKay can probably confirm that as have only ever delt with POSTing out of Samba, know he as recently been working on something which might help.

My guess you would need to get them to post to a middle man ie back end of your own website and have samba routinely/regularly check that for new orders.

Wow, that is great. We need Add Order Action in JSON/XML format. One action that can loop thru JSON/XML to add orders and order tags all at once. :heart_eyes:

I think you could fashion a loop as is by generating the loop list using one script which counts and lists Json array indexes for loop list and then second script to add each order based on that Json index loop value.

1 Like

I have got no experience in programming so i think this is going to be too much for me. The Gloria food online ordering seems good so i may just have to buy a compatible thermal printer and use their app. If someone can get this working it would be great and may be a way of integrating online ordering into Sambapos

Thanks

I think maybe SambaPOS should partner with Gloria Food. There online order is excellent. Seamlessly integrate with them may boost SambaPOS present.

It doesn’t look too complicated. They have 2 methods:

  • Push : they push data to your own HTTPS server/website which would handle the orders. SambaPOS would then need to “talk” to your website to process the orders in some manner. Perhaps simply reading your website’s Database. This option appears to require a more complex setup, since your site would be a middle-man

  • Poll : SambaPOS polls periodically (docs say every minute) to request new Order data, and Gloria responds with JSON or XML formatted order data. We then deconstruct the data and “insert” the Order(s) into SambaPOS. In this case, we don’t need a website (HTTPS server) so it is less complex. It would be helpful to have SambaPOS API helpers for Ticket and Order creation so we can script the Ticket/Order directly in JScript… but even without API helpers, we do have Actions that can accomplish the task (Create Ticket, Add Order, Tag Order, etc).

I think the second option (Poll) would work best at this time since it does not require having a website middle-man. I do not think it will require any “new features” be added to SambaPOS just yet… I believe we already have the tools at our disposal. Need data…

Found sample payload in JSON format … https://github.com/GloriaFood/pos_docs/blob/master/version%202/payload/orders.json

{
    "count": 1,
    "orders": [
        {
            "coupons": [],
            "id": 776113,
            "restaurant_id": 4172,
            "client_id": 188995,
            "type": "delivery",
            "sub_total_price": 47.88,
            "tax_value": 4.13,
            "total_price": 62.41,
            "client_first_name": "Donald",
            "client_last_name": "Draper",
            "client_email": "don.draper@gloriafood.com",
            "client_phone": "+15551234567",
            "restaurant_name": "John's Excellent Pizza",
            "instructions": null,
            "currency": "USD",
            "latitude": "37.79448725889753",
            "longitude": "-122.395311680426",
            "tax_type": "NET",
            "tax_name": "Sales Tax",
            "fulfill_at": "2016-02-03T17:19:32.000Z",
            "pos_system_id": 1,
            "restaurant_key": "8yCPCvb3dDo1k",
            "api_version": 2,
            "payment": "ONLINE",
            "client_address": "21 Market Street, San Francisco",
            "items": [
                {
                    "id": 1678316,
                    "name": "DELIVERY_FEE",
                    "total_item_price": 5,
                    "price": 5,
                    "quantity": 1,
                    "instructions": null,
                    "type_id": null,
                    "type": "delivery_fee",
                    "tax_rate": 0.1,
                    "tax_value": 0.5,
                    "parent_id": null,
                    "cart_discount_rate": 0,
                    "cart_discount": 0,
                    "tax_type": "NET",
                    "item_discount": 0,
                    "options": []
                },
                {
                    "id": 1678317,
                    "name": "TIP",
                    "total_item_price": 5.67,
                    "price": 5.67,
                    "quantity": 1,
                    "instructions": null,
                    "type_id": null,
                    "type": "tip",
                    "tax_rate": 0.05,
                    "tax_value": 0.2702,
                    "parent_id": null,
                    "cart_discount_rate": 0,
                    "cart_discount": 0,
                    "tax_type": "GROSS",
                    "item_discount": 0,
                    "options": []
                },
                {
                    "id": 1678322,
                    "name": "Pizza Margherita",
                    "total_item_price": 8.2,
                    "price": 7,
                    "quantity": 1,
                    "instructions": "",
                    "type_id": 58424,
                    "type": "item",
                    "tax_rate": 0.07,
                    "tax_value": 0,
                    "parent_id": 1678332,
                    "cart_discount_rate": 0,
                    "cart_discount": 0,
                    "tax_type": "NET",
                    "item_discount": 8.2,
                    "options": [
                        {
                            "id": 1771325,
                            "name": "Small",
                            "price": 0,
                            "group_name": "Size",
                            "quantity": 1,
                            "type": "size"
                        },
                        {
                            "id": 1771326,
                            "name": "Crispy",
                            "price": 0,
                            "group_name": "Crust",
                            "quantity": 1,
                            "type": "option"
                        },
                        {
                            "id": 1771327,
                            "name": "Extra mozzarella",
                            "price": 1.2,
                            "group_name": "Extra Toppings (Small)",
                            "quantity": 1,
                            "type": "option"
                        }
                    ]
                },
                {
                    "id": 1678324,
                    "name": "Pizza Prosciutto",
                    "total_item_price": 11.7,
                    "price": 8,
                    "quantity": 1,
                    "instructions": "",
                    "type_id": 58425,
                    "type": "item",
                    "tax_rate": 0.07,
                    "tax_value": 0.819,
                    "parent_id": 1678332,
                    "cart_discount_rate": 0,
                    "cart_discount": 0,
                    "tax_type": "NET",
                    "item_discount": 0,
                    "options": [
                        {
                            "id": 1771331,
                            "name": "Large",
                            "price": 2,
                            "group_name": "Size",
                            "quantity": 1,
                            "type": "size"
                        },
                        {
                            "id": 1771332,
                            "name": "Crispy",
                            "price": 0,
                            "group_name": "Crust",
                            "quantity": 1,
                            "type": "option"
                        },
                        {
                            "id": 1771333,
                            "name": "Extra mozzarella",
                            "price": 1.7,
                            "group_name": "Extra Toppings (Large)",
                            "quantity": 1,
                            "type": "option"
                        }
                    ]
                },
                {
                    "id": 1678331,
                    "name": "Pizza Prosciutto",
                    "total_item_price": 8.7,
                    "price": 8,
                    "quantity": 1,
                    "instructions": "",
                    "type_id": 58425,
                    "type": "item",
                    "tax_rate": 0.07,
                    "tax_value": 0.609,
                    "parent_id": 1678332,
                    "cart_discount_rate": 0,
                    "cart_discount": 0,
                    "tax_type": "NET",
                    "item_discount": 0,
                    "options": [
                        {
                            "id": 1771343,
                            "name": "Small",
                            "price": 0,
                            "group_name": "Size",
                            "quantity": 1,
                            "type": "size"
                        },
                        {
                            "id": 1771344,
                            "name": "Fluffy",
                            "price": 0,
                            "group_name": "Crust",
                            "quantity": 1,
                            "type": "option"
                        },
                        {
                            "id": 1771345,
                            "name": "Corn",
                            "price": 0.7,
                            "group_name": "Extra Toppings (Small)",
                            "quantity": 1,
                            "type": "option"
                        }
                    ]
                },
                {
                    "id": 1678332,
                    "name": "2 + 1 Pizza Special",
                    "total_item_price": 28.6,
                    "price": 0,
                    "quantity": 1,
                    "instructions": null,
                    "type_id": 251,
                    "type": "promo_item",
                    "tax_rate": 0.07,
                    "tax_value": 1.3566,
                    "parent_id": null,
                    "cart_discount_rate": 0.05,
                    "cart_discount": 1.02,
                    "tax_type": "NET",
                    "item_discount": 8.2,
                    "options": []
                },
                {
                    "id": 1678334,
                    "name": "Spaghetti Bolognese",
                    "total_item_price": 18,
                    "price": 9,
                    "quantity": 2,
                    "instructions": "",
                    "type_id": 58426,
                    "type": "item",
                    "tax_rate": 0.07,
                    "tax_value": 1.197,
                    "parent_id": null,
                    "cart_discount_rate": 0.05,
                    "cart_discount": 0.9,
                    "tax_type": "NET",
                    "item_discount": 0,
                    "options": []
                },
                {
                    "id": 1678335,
                    "name": "Spaghetti Frutti di Mare",
                    "total_item_price": 12,
                    "price": 12,
                    "quantity": 1,
                    "instructions": "",
                    "type_id": 58427,
                    "type": "item",
                    "tax_rate": 0.07,
                    "tax_value": 0.798,
                    "parent_id": null,
                    "cart_discount_rate": 0.05,
                    "cart_discount": 0.6,
                    "tax_type": "NET",
                    "item_discount": 0,
                    "options": []
                },
                {
                    "id": 1678336,
                    "name": "5% off total larger than 40$",
                    "total_item_price": 0,
                    "price": 0,
                    "quantity": 1,
                    "instructions": null,
                    "type_id": 250,
                    "type": "promo_cart",
                    "tax_rate": 0.07,
                    "tax_value": 0,
                    "parent_id": null,
                    "cart_discount_rate": 0.05,
                    "cart_discount": -2.52,
                    "tax_type": "NET",
                    "item_discount": 2.52,
                    "options": []
                }
            ]
        }
    ]
}

@JTRTech, get to work :stuck_out_tongue_winking_eye:

Sounds like a challange.
If I wasnt flat out for next 3 weeks with refurb at hotel looks like something right up my street… :frowning:

2 Likes

@QMcKay do you know if we can use curl in script? Or do we have any equivalent command to request?

curl "https://pos.gloriafood.com/pos/order/pop" \
   -X POST \
   -H "Authorization: 8yCPCvb3dDo1k" \
   -H "Accept: application/json" \
   -H "Glf-Api-Version: 2"

We don’t have curl. But your example is the equivalent of SambaPOS helper method:

web.PostJson(url,jsondata ,username,password);

See this topic where we use that method to post JSON to a remote server and process the request server-side using PHP …

2 Likes

All of this makes little sense to me, but I would like to integrate gloriafood into our Samba pos system.

If none of that makes sense to you then you are either going to need to learn so it does make sense or pay someone to setup something for you.

As it stands you probably won’t get much interest as it would be a chalanging job at the moment.
There is potential that update coming to v5 might make this easier but as above if you didn’t understand that your likely to still need to pay someone.

Alternativly just do as you mentioned before and get compatable printer, and ring in to samba when the order comes in manually.