diff --git a/api/v1/account.js b/api/v1/account.js index 83be562..d51cbb1 100644 --- a/api/v1/account.js +++ b/api/v1/account.js @@ -213,7 +213,14 @@ account.recoverEmail = (schema, req) => { email: req.body.email }).then(result => { if (!result) { - return; + return { + errors: { + email: { + code: 'REQUIRED', + message: 'Invalid email address entered' + } + } + }; } return schema.put('/accounts/{id}', { @@ -360,6 +367,16 @@ account.getAddresses = (schema, req) => { }); }; +//Get account address by ID +account.getAddressById = (schema, req) => { + const query = req.query || {}; + return schema.get('/accounts/{id}/addresses/{address_id}', { + id: req.session.account_id, + address_id: req.params.id, + fields: query.fields + }); +}; + // Remove an account address account.removeAddress = (schema, req) => { return schema.put('/accounts/{id}/addresses/{address_id}', { @@ -386,6 +403,16 @@ account.getCards = (schema, req) => { }); }; +//Get account card by ID +account.getCardById = (schema, req) => { + const query = req.query || {}; + return schema.get('/accounts/{id}/cards/{card_id}', { + id: req.session.account_id, + card_id: req.params.id, + fields: query.fields + }); +}; + // Remove an account card account.removeCard = (schema, req) => { return schema.put('/accounts/{id}/cards/{card_id}', { diff --git a/api/v1/cart.js b/api/v1/cart.js index 1e5c880..de0228d 100644 --- a/api/v1/cart.js +++ b/api/v1/cart.js @@ -368,10 +368,10 @@ cart.validateProduct = (schema, data) => { var productId = product.id; var variantId = product.variant && product.variant.id; if (!product.id) { - throw new util.error(400, 'Product not found'); + throw util.error(400, 'Product not found'); } if (product.delivery === 'subscription') { - throw new util.error(400, 'Subscription products cannot be added to a cart'); + throw util.error(400, 'Subscription products cannot be added to a cart'); } if (product.variable && !data.variant_id) { // Return first variant @@ -386,10 +386,10 @@ cart.validateProduct = (schema, data) => { }); } if (data.variant_id && !product.variant) { - throw new util.error(400, 'Variant not found for this product (' + product.name + ')'); + throw util.error(400, 'Variant not found for this product (' + product.name + ')'); } if (data.variant_id && !product.variable) { - throw new util.error(400, 'Product is not variable (' + product.name + ')'); + throw util.error(400, 'Product is not variable (' + product.name + ')'); } // Valid data.product_id = productId;