diff --git a/lib/apiMethods.js b/lib/apiMethods.js index a9d795d..a7066e8 100644 --- a/lib/apiMethods.js +++ b/lib/apiMethods.js @@ -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"], diff --git a/lib/models/Report.js b/lib/models/Report.js index e1a6c8c..bc3ae80 100644 --- a/lib/models/Report.js +++ b/lib/models/Report.js @@ -21,7 +21,7 @@ var Report = EntityBase.extend({ */ DownloadFormat: null, /** - * Report type {TRANSACTION} + * Report type {TRANSACTIONS, WALLETS} */ ReportType: null, /** diff --git a/lib/services/Reports.js b/lib/services/Reports.js index b49bab2..5c72f98 100644 --- a/lib/services/Reports.js +++ b/lib/services/Reports.js @@ -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(); diff --git a/test/services/Reports.js b/test/services/Reports.js index 6fb5a1f..0421235 100644 --- a/test/services/Reports.js +++ b/test/services/Reports.js @@ -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(); }); }); @@ -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(); }); @@ -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(); @@ -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(); }); diff --git a/typings/mangopay2-nodejs-sdk-tests.ts b/typings/mangopay2-nodejs-sdk-tests.ts index a420e36..982707f 100644 --- a/typings/mangopay2-nodejs-sdk-tests.ts +++ b/typings/mangopay2-nodejs-sdk-tests.ts @@ -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 }); diff --git a/typings/models/report.d.ts b/typings/models/report.d.ts index 4a91a0c..70e11c4 100644 --- a/typings/models/report.d.ts +++ b/typings/models/report.d.ts @@ -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 = @@ -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 `:` diff --git a/typings/types.d.ts b/typings/types.d.ts index d5da3b4..c12d349 100644 --- a/typings/types.d.ts +++ b/typings/types.d.ts @@ -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"