Skip to content

Commit

Permalink
Add datetime validation to 'created' and 'updated' fields
Browse files Browse the repository at this point in the history
  • Loading branch information
massaru-stark committed Nov 12, 2021
1 parent 3637462 commit cb3c404
Show file tree
Hide file tree
Showing 26 changed files with 47 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Given a version number MAJOR.MINOR.PATCH, increment:
### Added
- 'transactionIds' property to BoletoPayment and TaxPayment resources
- 'fee', 'transactionIds', 'created' and 'updated' properties to DarfPayment resource
- datetime validation to 'created' and 'updated' fields

## [2.9.2] - 2021-11-10
### Changed
Expand Down
3 changes: 2 additions & 1 deletion sdk/balance/balance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../utils/rest.js');
const check = require('../utils/check.js');
const Resource = require('../utils/resource.js').Resource


Expand All @@ -23,7 +24,7 @@ class Balance extends Resource {
super(id);
this.amount = amount;
this.currency = currency;
this.updated = updated;
this.updated = check.datetime(updated);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/boleto/boleto.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Boleto extends Resource {
this.barCode = barCode;
this.status = status;
this.transactionIds = transactionIds;
this.created = created;
this.created = check.datetime(created);
this.ourNumber = ourNumber;
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/boleto/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Log extends Resource {
*/
constructor({ created, type, errors, boleto, id }) {
super(id);
this.created = check.date(created);
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.boleto = boleto;
Expand Down
5 changes: 3 additions & 2 deletions sdk/boletoHolmes/boletoHolmes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../utils/rest.js');
const check = require('../utils/check.js');
const Resource = require('../utils/resource.js').Resource


Expand Down Expand Up @@ -33,8 +34,8 @@ class BoletoHolmes extends Resource {
this.tags = tags;
this.result = result;
this.status = status;
this.created = created;
this.updated = updated;
this.created = check.datetime(created);
this.updated = check.datetime(updated);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/boletoHolmes/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Log extends Resource {
*/
constructor({ created, type, holmes, id }) {
super(id);
this.created = check.date(created);
this.created = check.datetime(created);
this.type = type;
this.holmes = holmes;
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/boletoPayment/boletoPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BoletoPayment extends Resource {
this.amount = amount;
this.transactionIds = transactionIds;
this.fee = fee;
this.created = check.date(created);
this.created = check.datetime(created);
}
}

Expand Down
3 changes: 2 additions & 1 deletion sdk/boletoPayment/log/log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../../utils/rest.js');
const check = require('../../utils/check.js');
const Resource = require('../../utils/resource.js').Resource


Expand All @@ -22,7 +23,7 @@ class Log extends Resource {
*/
constructor({ created, type, errors, payment, id }) {
super(id);
this.created = created;
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.payment = payment;
Expand Down
4 changes: 2 additions & 2 deletions sdk/brcodePayment/brcodePayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class BrcodePayment extends Resource {
this.status = status;
this.type = type;
this.fee = fee;
this.updated = check.date(updated);
this.created = check.date(created);
this.updated = check.datetime(updated);
this.created = check.datetime(created);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/brcodePayment/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Log extends Resource {
*/
constructor({ created, type, errors, payment, id }) {
super(id);
this.created = check.date(created);
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.payment = payment;
Expand Down
4 changes: 2 additions & 2 deletions sdk/darfPayment/darfPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class DarfPayment extends Resource {
this.nominalAmount = nominalAmount;
this.transactionIds = transactionIds;
this.fee = fee;
this.updated = check.date(updated);
this.created = check.date(created);
this.updated = check.datetime(updated);
this.created = check.datetime(created);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/darfPayment/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Log extends Resource {
*/
constructor({ created, type, errors, payment, id }) {
super(id);
this.created = check.date(created);
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.payment = payment;
Expand Down
5 changes: 3 additions & 2 deletions sdk/deposit/deposit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../utils/rest.js');
const check = require('../utils/check.js');
const Resource = require('../utils/resource.js').Resource;


Expand Down Expand Up @@ -43,8 +44,8 @@ class Deposit extends Resource {
this.tags = tags;
this.fee = fee;
this.transactionIds = transactionIds;
this.created = created;
this.updated = updated;
this.created = check.datetime(created);
this.updated = check.datetime(updated);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/deposit/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Log extends Resource {
*/
constructor({ created, type, errors, boleto, id }) {
super(id);
this.created = check.date(created);
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.boleto = boleto;
Expand Down
3 changes: 2 additions & 1 deletion sdk/event/attempt/attempt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Resource = require('../../utils/resource.js').Resource;
const check = require('../../utils/check.js');
const rest = require('../../utils/rest.js');


Expand All @@ -10,7 +11,7 @@ class Attempt extends Resource {
this.message = message;
this.webhookId = webhookId;
this.eventId = eventId;
this.created = created;
this.created = check.datetime(created);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/event/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Event extends Resource {
constructor({created, isDelivered, subscription, log, id, workspaceId} = {}) {
super(id);
this.log = log;
this.created = created;
this.created = check.datetime(created);
this.isDelivered = isDelivered;
this.subscription = subscription;
this.workspaceId = workspaceId;
Expand Down
4 changes: 2 additions & 2 deletions sdk/invoice/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class Invoice extends Resource {
this.brcode = brcode;
this.status = status;
this.transactionIds = transactionIds;
this.created = check.date(created);
this.updated = check.date(updated);
this.created = check.datetime(created);
this.updated = check.datetime(updated);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/invoice/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Log extends Resource {
*/
constructor({ created, type, errors, invoice, id }) {
super(id);
this.created = check.date(created);
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.invoice = invoice;
Expand Down
7 changes: 4 additions & 3 deletions sdk/paymentRequest/paymentRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const { Transfer } = require('../transfer/transfer.js');
const { UtilityPayment } = require('../utilityPayment/utilityPayment.js');
const { BrcodePayment } = require('../brcodePayment/brcodePayment.js');
const rest = require('../utils/rest.js');
const check = require('../utils/check.js');
const Resource = require('../utils/resource.js').Resource


class PaymentRequest extends Resource {

/**
/**
* PaymentRequest constructor
*
* A PaymentRequest is an indirect request to access a specific cash-out service
Expand Down Expand Up @@ -48,8 +49,8 @@ class PaymentRequest extends Resource {
this.amount = amount;
this.status = status;
this.actions = actions;
this.updated = updated;
this.created = created;
this.updated = check.datetime(updated);
this.created = check.datetime(created);
let parsePaymentObject = parsePayment(payment, type);
this.payment = parsePaymentObject['payment'];
this.type = parsePaymentObject['type'];
Expand Down
5 changes: 3 additions & 2 deletions sdk/taxPayment/log/log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../../utils/rest.js');
const check = require('../../utils/check.js');
const Resource = require('../../utils/resource.js').Resource


Expand All @@ -19,9 +20,9 @@ class Log extends Resource {
* @param created [string]: creation datetime for the log. ex: '2020-03-10 10:30:00.000'
*
*/
constructor(created, type, errors, payment, id = null) {
constructor({ created, type, errors, payment, id = null }) {
super(id);
this.created = created;
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.payment = payment;
Expand Down
4 changes: 2 additions & 2 deletions sdk/taxPayment/taxPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class TaxPayment extends Resource {
this.status = status;
this.type = type;
this.transactionIds = transactionIds;
this.updated = updated;
this.created = created;
this.updated = check.datetime(updated);
this.created = check.datetime(created);
this.fee = fee;
}
}
Expand Down
3 changes: 2 additions & 1 deletion sdk/transaction/transaction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../utils/rest.js');
const check = require('../utils/check.js');
const Resource = require('../utils/resource.js').Resource


Expand Down Expand Up @@ -44,7 +45,7 @@ class Transaction extends Resource {
this.fee = fee;
this.source = source;
this.balance = balance;
this.created = created;
this.created = check.datetime(created);
}
}

Expand Down
3 changes: 2 additions & 1 deletion sdk/transfer/log/log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../../utils/rest.js');
const check = require('../../utils/check.js');
const Resource = require('../../utils/resource.js').Resource


Expand All @@ -21,7 +22,7 @@ class Log extends Resource {
*/
constructor({ created, type, errors, transfer, id }) {
super(id);
this.created = created;
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.transfer = transfer;
Expand Down
4 changes: 2 additions & 2 deletions sdk/transfer/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class Transfer extends Resource {
this.tags = tags;
this.fee = fee;
this.status = status;
this.created = created;
this.updated = updated;
this.created = check.datetime(created);
this.updated = check.datetime(updated);
this.transactionIds = transactionIds;
}
}
Expand Down
5 changes: 3 additions & 2 deletions sdk/utilityPayment/log/log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const rest = require('../../utils/rest.js');
const check = require('../../utils/check.js');
const Resource = require('../../utils/resource.js').Resource


Expand All @@ -19,9 +20,9 @@ class Log extends Resource {
* @param created [string]: creation datetime for the log. ex: '2020-03-10 10:30:00.000'
*
*/
constructor(created, type, errors, payment, id = null) {
constructor({ created, type, errors, payment, id = null }) {
super(id);
this.created = created;
this.created = check.datetime(created);
this.type = type;
this.errors = errors;
this.payment = payment;
Expand Down
2 changes: 1 addition & 1 deletion sdk/utilityPayment/utilityPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class UtilityPayment extends Resource {
this.tags = tags;
this.amount = amount;
this.status = status;
this.created = created;
this.created = check.datetime(created);
this.fee = fee;
}
}
Expand Down

0 comments on commit cb3c404

Please sign in to comment.