Skip to content

Commit

Permalink
Merge pull request #62 from starkbank/feature/transaction-ids-to-char…
Browse files Browse the repository at this point in the history
…ge-payment

Add missing properties to ChargePayment resources
  • Loading branch information
cdottori-stark authored Nov 12, 2021
2 parents dd09128 + cb3c404 commit 8d891e4
Show file tree
Hide file tree
Showing 26 changed files with 93 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
6 changes: 4 additions & 2 deletions sdk/boletoPayment/boletoPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

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
40 changes: 39 additions & 1 deletion sdk/darfPayment/darfPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

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
8 changes: 5 additions & 3 deletions sdk/taxPayment/taxPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
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
Loading

0 comments on commit 8d891e4

Please sign in to comment.