RIAEvangelist / node-dominos-pizza-api

This is a node.js wrapper for the dominos pizza apis
MIT License
514 stars 126 forks source link

Invalid options format #85

Closed trphelan closed 3 years ago

trphelan commented 4 years ago

Following the example for validating on order like this:

const api = require('dominos');
var order = new api.Order();
order.Phone = 'aphonenumber';
order.addItem(new api.Item({code: '14SCREEN', options:[], quantity: 1}));
order.validate(r => console.log(JSON.stringify(r, null, 2)));

The result is (snipped):

     "Products": [
        {
          "AutoRemove": false,
          "Code": "14SCREEN",
          "Qty": 1,
          "ID": 1,
          "isNew": true,
          "StatusItems": [
            {
              "Code": "InvalidOptionPartRemoved"
            },
            {
              "Code": "Removed"
            }
          ],
          "Status": -1
        }
      ],

It looks like the acceptable options format has changed. Any idea what it is now? Or pointers to some documentation so I can figure it out?

Thanks.

easotelo1 commented 3 years ago

I am also having the same problem. I am commenting to hopefully bump this up for @RIAEvangelist and @madelinecameron to see haha.

Ive tried this with a few different items with my code looking like

var pizzaItem = new pizzapi.Item(
    {
        code: 'PXC_14SCREEN',
        options: {},
        quantity: 2
    }
);

var sodaItem = new pizzapi.Item(
    {
        code: '2LCOKE',
        options: {},
        quantity:1
    }
);

var order = new pizzapi.Order(
    {
        customer: customer,
        storeID: myStore.ID,
        deliveryMethod: this.serviceType
    }
);

order.addItem(pizzaItem);
order.addItem(sodaItem);
order.addCoupon("9003");

and my result is

"Products": [
                {
                    "AutoRemove": false,
                    "Code": "PXC_14SCREEN",
                    "Qty": 2,
                    "ID": 1,
                    "isNew": true,
                    "StatusItems": [
                        {
                            "Code": "InvalidOptionPartRemoved"
                        },
                        {
                            "Code": "Removed"
                        }
                    ],
                    "Status": -1,
                    "CategoryCode": ""
                },
                {
                    "AutoRemove": false,
                    "Code": "2LCOKE",
                    "Qty": 1,
                    "ID": 2,
                    "isNew": true,
                    "StatusItems": [
                        {
                            "Code": "InvalidOptionPartRemoved"
                        }
                    ],
                    "Status": 1,
                    "CategoryCode": "Drinks"
                }
            ],

Apologies if this is not allowed.

RIAEvangelist commented 3 years ago

Interesting, I am just catching back up on all of this now. I ran the tests which seem to show everything passing, but I'll have a look.

Kennygunderman commented 3 years ago

@RIAEvangelist any update on this?

RIAEvangelist commented 3 years ago

Yeah, the options format may have changed. I have a new branch I'm working in where I am exploring this. Not sure if this affects ordering or not. Ideally, I'll be able to order superfluous pizzas again sometime soon to help with the debug process.

RIAEvangelist commented 3 years ago

Also, I'm committing my exploratory code in that branch. It's all ES6 modules, you are welcome to help too. The more people helping, the better.

its the v3.x branch btw

Kennygunderman commented 3 years ago

Also, I'm committing my exploratory code in that branch. It's all ES6 modules, you are welcome to help too. The more people helping, the better.

its the v3.x branch btw

Sweet! I will check it out, Id also love to order me some pizza through unnecessary means :p

RIAEvangelist commented 3 years ago

I'll be getting to the v3.x order process tomorrow. I have completed most everything else.

RIAEvangelist commented 3 years ago

OK, So as I have been rewriting, I can confirm, you guys were forcing empty objects or arrays to the options of the Item.

You cant get a cheese pizza without cheese etc.

Your options were in fact wrong. For basic things, you can just omit the options and allow it to have cheese and sauce. For some items, you will need to update the options according to the product's menu info.

Please log out the product you would like and check its options.

RIAEvangelist commented 3 years ago

Just to confirm the options format has not changed.

RIAEvangelist commented 3 years ago

More specifically the library automatically adds sauce and cheese. So you may need to remove those options.