diff --git a/CHANGELOG.md b/CHANGELOG.md index 97723121..776495a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ Given a version number MAJOR.MINOR.PATCH, increment: ## [Unreleased] +### 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 diff --git a/sdk/balance/balance.js b/sdk/balance/balance.js index 62273c7c..d46fa0e8 100644 --- a/sdk/balance/balance.js +++ b/sdk/balance/balance.js @@ -1,4 +1,5 @@ const rest = require('../utils/rest.js'); +const check = require('../utils/check.js'); const Resource = require('../utils/resource.js').Resource @@ -23,7 +24,7 @@ class Balance extends Resource { super(id); this.amount = amount; this.currency = currency; - this.updated = updated; + this.updated = check.datetime(updated); } } diff --git a/sdk/boleto/boleto.js b/sdk/boleto/boleto.js index e889d0d7..faacf329 100644 --- a/sdk/boleto/boleto.js +++ b/sdk/boleto/boleto.js @@ -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; } } diff --git a/sdk/boleto/log/log.js b/sdk/boleto/log/log.js index 47da5f18..28096d37 100644 --- a/sdk/boleto/log/log.js +++ b/sdk/boleto/log/log.js @@ -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; diff --git a/sdk/boletoHolmes/boletoHolmes.js b/sdk/boletoHolmes/boletoHolmes.js index 609e2e16..2f5aacdf 100644 --- a/sdk/boletoHolmes/boletoHolmes.js +++ b/sdk/boletoHolmes/boletoHolmes.js @@ -1,4 +1,5 @@ const rest = require('../utils/rest.js'); +const check = require('../utils/check.js'); const Resource = require('../utils/resource.js').Resource @@ -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); } } diff --git a/sdk/boletoHolmes/log/log.js b/sdk/boletoHolmes/log/log.js index 8afb1a47..4bfe2040 100644 --- a/sdk/boletoHolmes/log/log.js +++ b/sdk/boletoHolmes/log/log.js @@ -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; } diff --git a/sdk/boletoPayment/boletoPayment.js b/sdk/boletoPayment/boletoPayment.js index e17f91cd..185565a4 100644 --- a/sdk/boletoPayment/boletoPayment.js +++ b/sdk/boletoPayment/boletoPayment.js @@ -28,11 +28,12 @@ class BoletoPayment extends Resource { * Attributes (return-only): * @param id [string, default null]: unique id returned when payment is created. ex: '5656565656565656' * @param status [string, default null]: current payment status. ex: 'success' or 'failed' + * @param transactionIds [list of strings, default null]: ledger transaction ids linked to this BoletoPayment. ex: ['19827356981273'] * @param fee [integer, default null]: fee charged when boleto payment is created. ex: 200 (= R$ 2.00) * @param created [string, default null]: creation datetime for the payment. ex: '2020-03-10 10:30:00.000' * */ - constructor({ taxId, description, scheduled, line, barCode, tags, id, status, amount, fee, created }) { + constructor({ taxId, description, scheduled, line, barCode, tags, id, status, amount, transactionIds, fee, created }) { super(id); this.taxId = taxId; this.description = description; @@ -42,8 +43,9 @@ class BoletoPayment extends Resource { this.tags = tags; this.status = status; this.amount = amount; + this.transactionIds = transactionIds; this.fee = fee; - this.created = created; + this.created = check.datetime(created); } } diff --git a/sdk/boletoPayment/log/log.js b/sdk/boletoPayment/log/log.js index 7c8ab553..80559da9 100644 --- a/sdk/boletoPayment/log/log.js +++ b/sdk/boletoPayment/log/log.js @@ -1,4 +1,5 @@ const rest = require('../../utils/rest.js'); +const check = require('../../utils/check.js'); const Resource = require('../../utils/resource.js').Resource @@ -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; diff --git a/sdk/brcodePayment/brcodePayment.js b/sdk/brcodePayment/brcodePayment.js index c2e3690d..2bdffecd 100644 --- a/sdk/brcodePayment/brcodePayment.js +++ b/sdk/brcodePayment/brcodePayment.js @@ -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); } } diff --git a/sdk/brcodePayment/log/log.js b/sdk/brcodePayment/log/log.js index 5d3fc816..1618cf8c 100644 --- a/sdk/brcodePayment/log/log.js +++ b/sdk/brcodePayment/log/log.js @@ -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; diff --git a/sdk/darfPayment/darfPayment.js b/sdk/darfPayment/darfPayment.js index 9e67427a..6071b749 100644 --- a/sdk/darfPayment/darfPayment.js +++ b/sdk/darfPayment/darfPayment.js @@ -4,9 +4,43 @@ const Resource = require('../utils/resource').Resource; class DarfPayment extends Resource { + /** + * + * TaxPayment object + * + * @description When you initialize a DarfPayment, the entity will not be automatically + * created in the Stark Bank API. The 'create' function sends the objects + * to the Stark Bank API and returns the list of created objects. + * + * Parameters (required): + * @param description [string]: Text to be displayed in your statement (min. 10 characters). ex: "payment ABC" + * @param revenueCode [string]: 4-digit tax code assigned by Federal Revenue. ex: "5948" + * @param taxId [string]: tax id (formatted or unformatted) of the payer. ex: "12.345.678/0001-95" + * @param competence [string]: competence month of the service. ex: ex: '2020-03-10' + * @param nominalAmount [int]: amount due in cents without fee or interest. ex: 23456 (= R$ 234.56) + * @param fineAmount [int]: fixed amount due in cents for fines. ex: 234 (= R$ 2.34) + * @param interestAmount [int]: amount due in cents for interest. ex: 456 (= R$ 4.56) + * @param due [string]: due date for payment. ex: ex: '2020-03-10' + * + * Parameters (optional): + * @param referenceNumber [string]: number assigned to the region of the tax. ex: "08.1.17.00-4" + * @param scheduled [string, default today]: payment scheduled date. ex: '2020-03-10' + * @param tags [list of strings]: list of strings for tagging + * + * Attributes (return-only): + * @param id [string, default null]: unique id returned when payment is created. ex: "5656565656565656" + * @param status [string, default null]: current payment status. ex: "success" or "failed" + * @param amount [int, default null]: Total amount due calculated from other amounts. ex: 24146 (= R$ 241.46) + * @param fee [integer, default null]: fee charged when the DarfPayment is processed. ex: 0 (= R$ 0.00) + * @param transactionIds [list of strings, default null]: ledger transaction ids linked to this DarfPayment. ex: ['19827356981273'] + * @param updated [string, default null]: latest update datetime for the payment. ex: '2020-03-10 10:30:00.000' + * @param created [string, default null]: creation datetime for the payment. ex: '2020-03-10 10:30:00.000' + * + */ constructor({ revenueCode, taxId, competence, referenceNumber, fineAmount, interestAmount, - due, description, tags, scheduled, status, amount, nominalAmount, id + due, description, tags, scheduled, status, amount, nominalAmount, fee, + transactionIds, updated, created, id }) { super(id); this.revenueCode = revenueCode; @@ -22,6 +56,10 @@ class DarfPayment extends Resource { this.status = status; this.amount = amount; this.nominalAmount = nominalAmount; + this.transactionIds = transactionIds; + this.fee = fee; + this.updated = check.datetime(updated); + this.created = check.datetime(created); } } diff --git a/sdk/darfPayment/log/log.js b/sdk/darfPayment/log/log.js index a81323d0..a32f23e6 100644 --- a/sdk/darfPayment/log/log.js +++ b/sdk/darfPayment/log/log.js @@ -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; diff --git a/sdk/deposit/deposit.js b/sdk/deposit/deposit.js index 7efee25b..67cfc831 100644 --- a/sdk/deposit/deposit.js +++ b/sdk/deposit/deposit.js @@ -1,4 +1,5 @@ const rest = require('../utils/rest.js'); +const check = require('../utils/check.js'); const Resource = require('../utils/resource.js').Resource; @@ -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); } } diff --git a/sdk/deposit/log/log.js b/sdk/deposit/log/log.js index a88a1ab0..09884cd5 100644 --- a/sdk/deposit/log/log.js +++ b/sdk/deposit/log/log.js @@ -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; diff --git a/sdk/event/attempt/attempt.js b/sdk/event/attempt/attempt.js index ed8c9f46..a94b5eed 100644 --- a/sdk/event/attempt/attempt.js +++ b/sdk/event/attempt/attempt.js @@ -1,4 +1,5 @@ const Resource = require('../../utils/resource.js').Resource; +const check = require('../../utils/check.js'); const rest = require('../../utils/rest.js'); @@ -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); } } diff --git a/sdk/event/event.js b/sdk/event/event.js index 468b5317..15e9e39a 100644 --- a/sdk/event/event.js +++ b/sdk/event/event.js @@ -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; diff --git a/sdk/invoice/invoice.js b/sdk/invoice/invoice.js index 3cb06c38..cfacb6ef 100644 --- a/sdk/invoice/invoice.js +++ b/sdk/invoice/invoice.js @@ -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); } } diff --git a/sdk/invoice/log/log.js b/sdk/invoice/log/log.js index cd016e74..5d73d394 100644 --- a/sdk/invoice/log/log.js +++ b/sdk/invoice/log/log.js @@ -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; diff --git a/sdk/paymentRequest/paymentRequest.js b/sdk/paymentRequest/paymentRequest.js index df7e2832..1389bd43 100644 --- a/sdk/paymentRequest/paymentRequest.js +++ b/sdk/paymentRequest/paymentRequest.js @@ -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 @@ -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']; diff --git a/sdk/taxPayment/log/log.js b/sdk/taxPayment/log/log.js index 779f2b86..6f8db779 100644 --- a/sdk/taxPayment/log/log.js +++ b/sdk/taxPayment/log/log.js @@ -1,4 +1,5 @@ const rest = require('../../utils/rest.js'); +const check = require('../../utils/check.js'); const Resource = require('../../utils/resource.js').Resource @@ -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; diff --git a/sdk/taxPayment/taxPayment.js b/sdk/taxPayment/taxPayment.js index c5a4cd54..c2352c65 100644 --- a/sdk/taxPayment/taxPayment.js +++ b/sdk/taxPayment/taxPayment.js @@ -29,13 +29,14 @@ class TaxPayment extends Resource { * @param status [string, default null]: current payment status. ex: 'success' or 'failed' * @param amount [int, default null]: amount automatically calculated from line or bar_code. ex: 23456 (= R$ 234.56) * @param fee [integer, default null]: fee charged when the tax payment is created. ex: 200 (= R$ 2.00) + * @param transactionIds [list of strings, default null]: ledger transaction ids linked to this TaxPayment. ex: ['19827356981273'] * @param updated [string, default null]: latest update datetime for the payment. ex: '2020-03-10 10:30:00.000' * @param created [string, default null]: creation datetime for the payment. ex: '2020-03-10 10:30:00.000' * */ constructor({ description, scheduled, line, barCode, tags, - amount, status, type, updated, created, fee, id, + amount, status, type, transactionIds, updated, created, fee, id, }) { super(id); this.barCode = barCode; @@ -46,8 +47,9 @@ class TaxPayment extends Resource { this.amount = amount; this.status = status; this.type = type; - this.updated = updated; - this.created = created; + this.transactionIds = transactionIds; + this.updated = check.datetime(updated); + this.created = check.datetime(created); this.fee = fee; } } diff --git a/sdk/transaction/transaction.js b/sdk/transaction/transaction.js index 59dc83a9..bbb0c27a 100644 --- a/sdk/transaction/transaction.js +++ b/sdk/transaction/transaction.js @@ -1,4 +1,5 @@ const rest = require('../utils/rest.js'); +const check = require('../utils/check.js'); const Resource = require('../utils/resource.js').Resource @@ -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); } } diff --git a/sdk/transfer/log/log.js b/sdk/transfer/log/log.js index 4e438bc9..84dea7a3 100644 --- a/sdk/transfer/log/log.js +++ b/sdk/transfer/log/log.js @@ -1,4 +1,5 @@ const rest = require('../../utils/rest.js'); +const check = require('../../utils/check.js'); const Resource = require('../../utils/resource.js').Resource @@ -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; diff --git a/sdk/transfer/transfer.js b/sdk/transfer/transfer.js index 20c51e65..fd58c072 100644 --- a/sdk/transfer/transfer.js +++ b/sdk/transfer/transfer.js @@ -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; } } diff --git a/sdk/utilityPayment/log/log.js b/sdk/utilityPayment/log/log.js index e8584d7b..57a250a7 100644 --- a/sdk/utilityPayment/log/log.js +++ b/sdk/utilityPayment/log/log.js @@ -1,4 +1,5 @@ const rest = require('../../utils/rest.js'); +const check = require('../../utils/check.js'); const Resource = require('../../utils/resource.js').Resource @@ -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; diff --git a/sdk/utilityPayment/utilityPayment.js b/sdk/utilityPayment/utilityPayment.js index 486aac6d..9f5b7d14 100644 --- a/sdk/utilityPayment/utilityPayment.js +++ b/sdk/utilityPayment/utilityPayment.js @@ -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; } }