Skip to content

Commit

Permalink
Merge pull request #207 from eltinMeli/bugfix/service_update_card_not…
Browse files Browse the repository at this point in the history
…_found

Adjust card update endpoint according to Mercado Pago API specification
  • Loading branch information
Nicholas Pedroso authored Jun 15, 2021
2 parents 6e8d038 + 7e51eb5 commit 89f0dde
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/resources/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var cardModel = require('../models/cardModel');
/**
* The cards class is the way to store card data of your customers safely to improve the shopping experience.
* This will allow your customers to complete their purchases much faster and easily, since they will not have to complete their card data again.
* This class must be used in conjunction with the [Customer class.]{@link https://www.mercadopago.com.br/developers/en/guides/online-payments/web-tokenize-checkout/customers-and-cards}
* This class must be used in conjunction with the [Customer class.]{@link https://www.mercadopago.com/developers/en/guides/online-payments/web-tokenize-checkout/customers-and-cards}
* @namespace card
*/
var card = module.exports = {
Expand All @@ -25,7 +25,7 @@ card.all = requestManager.describe({

/**
* Get card from card's id and customer's id
* [Click here for more infos]{@link https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/get/}
* [Click here for more infos]{@link https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/get}
* @function get
* @param {string} customer_id Customer ID
* @param {string} id Card ID
Expand All @@ -38,6 +38,7 @@ card.get = requestManager.describe({

/**
* Get card from card's id and customer's id
* [Click here for more infos]{@link https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/get/}
* @function findById
* @param {string} customer_id Customer ID
* @param {string} id Card ID
Expand Down Expand Up @@ -71,10 +72,11 @@ card.save = card.create;
* [Click here for more infos]{@link https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/put/}
* @function update
* @param {string} customer_id Customer ID
* @param {string} id Card ID
* @memberof card
*/
card.update = requestManager.describe({
path: '/v1/customers/:customer_id/cards',
path: '/v1/customers/:customer_id/cards/:id',
method: 'PUT'
});

Expand All @@ -83,6 +85,7 @@ card.update = requestManager.describe({
* [Click here for more infos]{@link https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/delete/}
* @function delete
* @param {string} customer_id Customer ID
* @param {string} id Card ID
* @memberof card
*/
card.delete = requestManager.describe({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mercadopago",
"version": "1.5.7",
"version": "1.5.8",
"description": "Mercadopago SDK for Node.js",
"main": "index.js",
"scripts": {
Expand Down
27 changes: 27 additions & 0 deletions test/card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-env node, mocha */
var chai = require('chai');
var chaiAsPromised = require("chai-as-promised");

chai.use(chaiAsPromised);
var expect = chai.expect;
var cardModule = require('../lib/resources/card.js');

describe('Card Resource', function () {

it('Check card update without card id', function () {

return cardModule.update(undefined, {customer_id: "123"}, undefined).catch(error => {
expect(error.message).to.equal("The JSON is missing the following properties: id")
});

});

it('Check card update without customer id', function () {

return cardModule.update(undefined, {id: "123"}, undefined).catch(error => {
expect(error.message).to.equal("The JSON is missing the following properties: customer_id")
});

});

});

0 comments on commit 89f0dde

Please sign in to comment.