Skip to content

Commit

Permalink
Merge pull request #373 from Mangopay/bugfix/error-while-creating-a-t…
Browse files Browse the repository at this point in the history
…ransaction-report

bugfix / Error while creating a transaction report
  • Loading branch information
iulian03 authored Nov 2, 2023
2 parents e4ff32f + a3d5f8c commit fe657f3
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lib/apiMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ module.exports = {
"disputes_repudiation_get_settlement": ["/${apiVersion}/${clientId}/settlements/${id}", "GET"],
"disputes_pending_settlement": ["/${apiVersion}/${clientId}/disputes/pendingsettlement", "GET"],

"reports_transaction_create": ["/${apiVersion}/${clientId}/reports/transactions/", "POST"],
"reports_wallet_create": ["/${apiVersion}/${clientId}/reports/wallets/", "POST"],
"reports_transactions_create": ["/${apiVersion}/${clientId}/reports/transactions/", "POST"],
"reports_wallets_create": ["/${apiVersion}/${clientId}/reports/wallets/", "POST"],
"reports_get": ["/${apiVersion}/${clientId}/reports/${id}", "GET"],
"reports_all": ["/${apiVersion}/${clientId}/reports", "GET"],

Expand Down
2 changes: 1 addition & 1 deletion lib/models/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var Report = EntityBase.extend({
*/
DownloadFormat: null,
/**
* Report type {TRANSACTION}
* Report type {TRANSACTIONS, WALLETS}
*/
ReportType: null,
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/services/Reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var Reports = Service.extend({
});

if (!report.ReportType) {
throw new Error('Please specify ReportType in the report data (ex: "TRANSACTION", "WALLET")')
throw new Error('Please specify ReportType in the report data (ex: "TRANSACTIONS", "WALLETS")')
}

var reportType = report.ReportType.toLowerCase();
Expand Down
68 changes: 57 additions & 11 deletions test/services/Reports.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,60 @@
var expect = require('chai').expect;
var helpers = require('../helpers');
var api = require('../main');

describe('Reports - Transaction', function() {
describe('Reports - Transactions', function () {
var report;

before(function(done) {
before(function (done) {
report = {
ReportType: "TRANSACTION"
ReportType: "TRANSACTIONS",
Tag: 'Created with Mangopay NodeJs SDK',
DownloadFormat: 'CSV',
CallbackURL: 'https://mangopay.com/docs/please-ignore',
Sort: 'CreationDate:ASC',
Preview: false,
Filters:
{
BeforeDate: 1658838931,
AfterDate: 1658838931,
Type: ['PAYIN'],
ResultCode: ['000000'],
Status: ['SUCCEEDED'],
Nature: ['REGULAR'],
WalletId: null,
AuthorId: null,
MinDebitedFundsAmount: 10,
MinDebitedFundsCurrency: 'EUR',
MaxDebitedFundsAmount: 12000,
MaxDebitedFundsCurrency: 'EUR',
MinFeesAmount: 10,
MinFeesCurrency: 'EUR',
MaxFeesAmount: 150000,
MaxFeesCurrency: 'EUR',
},
Columns: [
'Id',
'Tag',
'CreationDate',
'ExecutionDate',
'AuthorId',
'CreditedUserId',
'DebitedFundsAmount',
'DebitedFundsCurrency',
'CreditedFundsAmount',
'CreditedFundsCurrency',
'FeesAmount',
'FeesCurrency',
'Status',
'ResultCode',
'ResultMessage',
'Type',
'Nature',
'CreditedWalletId',
'DebitedWalletId',
]
};
api.Reports.create(report).then(function () {
api.Reports.create(report).then(function (data) {
done();
});
});
Expand All @@ -20,8 +66,8 @@ describe('Reports - Transaction', function() {
describe('Getting created report', function () {
var getReport;

before(function(done){
api.Reports.get(report.Id).then(function(data){
before(function (done) {
api.Reports.get(report.Id).then(function (data) {
getReport = data;
done();
});
Expand All @@ -34,12 +80,12 @@ describe('Reports - Transaction', function() {
});
});

describe('Reports - Wallet', function() {
describe('Reports - Wallets', function () {
var report;

before(function(done) {
before(function (done) {
report = {
ReportType: "WALLET"
ReportType: "WALLETS"
};
api.Reports.create(report).then(function () {
done();
Expand All @@ -53,8 +99,8 @@ describe('Reports - Wallet', function() {
describe('Getting created report', function () {
var getReport;

before(function(done){
api.Reports.get(report.Id).then(function(data){
before(function (done) {
api.Reports.get(report.Id).then(function (data) {
getReport = data;
done();
});
Expand Down
2 changes: 1 addition & 1 deletion typings/mangopay2-nodejs-sdk-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ api.Hooks.getAll().then(data => {

/* Reports */

api.Reports.create({Columns: ["Alias", "AuthorId"], ReportType: "WALLET"}).then(data => {
api.Reports.create({Columns: ["Alias", "AuthorId"], ReportType: "WALLETS"}).then(data => {
const d = data; // $ExpectType ReportData
});

Expand Down
8 changes: 4 additions & 4 deletions typings/models/report.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CurrencyISO, PickPartial, Timestamp } from "../types";
import { transaction } from "./transaction";
import { entityBase } from "./entityBase";
import {CurrencyISO, PickPartial, Timestamp} from "../types";
import {transaction} from "./transaction";
import {entityBase} from "./entityBase";

export namespace report {
type Column =
Expand Down Expand Up @@ -141,7 +141,7 @@ export namespace report {
/**
* The type of report
*/
ReportType: "TRANSACTION" | "WALLET";
ReportType: "TRANSACTIONS" | "WALLETS";

/**
* The column to sort against and direction separated by a `:`
Expand Down
4 changes: 2 additions & 2 deletions typings/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export type ApiMethod =
| "disputes_repudiation_create_settlement"
| "disputes_repudiation_get_settlement"
| "disputes_pending_settlement"
| "reports_transaction_create"
| "reports_wallet_create"
| "reports_transactions_create"
| "reports_wallets_create"
| "reports_get"
| "reports_all"
| "mandates_directdebit-web_create"
Expand Down

0 comments on commit fe657f3

Please sign in to comment.