diff --git a/CHANGELOG.md b/CHANGELOG.md index bdca2cb..b03b96d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,9 +23,9 @@ Given a version number MAJOR.MINOR.PATCH, increment: - IssuingPurchase resource for Sub Issuers - IssuingTransaction resource for Sub Issuers - IssuingWithdrawal resource for Sub Issuers +- PixDirector resource for Direct Participants - PixKey resource for Indirect and Direct Participants - PixClaim resource for Indirect and Direct Participants -- PixDirector resource for Indirect and Direct Participants - ReversalRequest resource for Indirect and Direct Participants - InfractionReport resource for Indirect and Direct Participants - BrcodeCertificate resource for Indirect and Direct Participants diff --git a/README.md b/README.md index 3701640..839fd30 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ This SDK version is compatible with the Stark Infra API v2. - [PixDirector](#create-a-pixdirector): Create a Pix Director - [InfractionReport](#create-an-infractionreport): Create a Pix Key - [ReversalRequest](#create-a-reversalrequest): Claim a Pix Key - - [BrcodeCertificate](#query-brcodecertificates): View registered SPI participants certificates + - [BrcodeCertificate](#query-brcodecertificates): View Pix QR Code domain certificates registered with the Central Bank - [Credit Note](#credit-note) - [CreditNote](#create-creditnotes): Create credit notes - [Webhook Events](#webhook-events): @@ -706,6 +706,18 @@ await (async() => { })(); ``` +### Get an IssuingInvoice log + +You can also get a specific log by its id. + +```javascript +await (async() => { + let log = await starkinfra.issuingInvoice.log.get('5155165527080960'); + + console.log(log); +})(); +``` + ### Create IssuingWithdrawals You can create withdrawals to send cash back from your Issuing balance to your Banking balance @@ -1241,7 +1253,7 @@ You can create a Pix claim to request the transfer of a Pix key from another ban const starkinfra = require('starkinfra'); (async() => { - let claim = await starkinfra.pixClaim.create(new starkinfra.PixClaim({ + let claim = await starkinfra.pixClaim.create({ accountCreated: '2022-02-01T00:00:00.00', accountNumber: '5692908409716736', accountType: 'checking', @@ -1249,7 +1261,7 @@ const starkinfra = require('starkinfra'); name: 'testKey', taxId: '012.345.678-90', keyId: '+5511989898989' - })); + }); console.log(claim); })(); @@ -1353,7 +1365,7 @@ To register the Pix director contact information at the Central Bank, run the fo const starkinfra = require('starkinfra'); (async() => { - let director = await starkinfra.pixDirector.create(new starkinfra.PixDirector({ + let director = await starkinfra.pixDirector.create({ name: 'Edward Stark', taxId: '03.300.300/0001-00', phone: '+55-11999999999', @@ -1361,7 +1373,7 @@ const starkinfra = require('starkinfra'); password: '12345678', teamEmail: 'pix.team@company.com', teamPhones: ['+55-11988889999', '+55-11988889998'] - })); + }); console.log(director); })(); @@ -1376,10 +1388,10 @@ reverse a refund. Infraction reports can be created by either participant of a t const starkinfra = require('starkinfra'); (async() => { - let report = await starkinfra.infractionReport.create(new starkinfra.InfractionReport({ + let report = await starkinfra.infractionReport.create({ referenceId: "E20018183202201201450u34sDGd19lz", type: "fraud", - })); + }); console.log(report); })(); @@ -1491,11 +1503,11 @@ results in an erroneous transaction. const starkinfra = require('starkinfra'); (async() => { - let request = await starkinfra.reversalRequest.create(new starkinfra.ReversalRequest({ + let request = await starkinfra.reversalRequest.create({ amount: 100, referenceId: "E20018183202201201450u34sDGd19lz", reason: "fraud", - })); + }); console.log(request); })(); @@ -1525,7 +1537,7 @@ const starkinfra = require('starkinfra'); ### Get a ReversalRequest -After its creation, information on a Reversal Request may be retrieved by its. +After its creation, information on a Reversal Request may be retrieved by its id. ```javascript const starkinfra = require('starkinfra'); @@ -1600,7 +1612,7 @@ const starkinfra = require('starkinfra'); ### Query BrcodeCertificates -You can query for certificates of registered SPI participants able to issue dynamic QR Codes. +You can query for the Pix QR Code domain certificates registered with the Central Bank. ```javascript const starkinfra = require('starkinfra'); diff --git a/index.js b/index.js index 6f64649..4cdf1f2 100644 --- a/index.js +++ b/index.js @@ -27,7 +27,8 @@ exports.pixStatement = require('./sdk/pixStatement'); exports.reversalRequest = require('./sdk/reversalRequest'); exports.brcodeCertificate = require('./sdk/brcodeCertificate'); exports.creditNote = require('./sdk/creditNote'); -exports.returnId = require('./sdk/user/returnId.js'); +exports.bacenId = require('./sdk/utils/bacenId.js'); +exports.returnId = require('./sdk/utils/returnId.js'); exports.endToEndId = require('./sdk/utils/endToEndId.js'); exports.key = require('./sdk/key.js'); exports.error = require('./sdk/error.js'); diff --git a/sdk/brcodeCertificate/brcodeCertificate.js b/sdk/brcodeCertificate/brcodeCertificate.js index 1c6c2a0..a80887f 100644 --- a/sdk/brcodeCertificate/brcodeCertificate.js +++ b/sdk/brcodeCertificate/brcodeCertificate.js @@ -7,13 +7,12 @@ class BrcodeCertificate extends SubResource { * * BrcodeCertificate object * - * @description The BrcodeCertificate object displays the certificate information of registered SPI participants able - * to issue dynamic QR Codes. - * They are used in the validation of the URLs contained in the dynamic QR Codes. + * @description The BrcodeCertificate object displays the QR Code domain certificate information of Pix participants. + * All certificates must be registered with the Central Bank. * * Attributes (return-only): - * @param content [string]: certificate of the SPI participant in PEM format. - * @param domain [string]: current active domain (URL) of the SPI participant. + * @param content [string]: certificate of the Pix participant in PEM format. + * @param domain [string]: current active domain (URL) of the Pix participant. * */ constructor({ content, domain }) { diff --git a/sdk/event/attempt/attempt.js b/sdk/event/attempt/attempt.js index 69f9d7e..8a45485 100644 --- a/sdk/event/attempt/attempt.js +++ b/sdk/event/attempt/attempt.js @@ -17,7 +17,7 @@ class Attempt extends Resource { * @param message [string]: delivery error full description. ex: "HTTP POST request returned status 404" * @param eventId [string]: ID of the Event whose delivery failed. ex: "4848484848484848" * @param webhookId [string]: ID of the Webhook that triggered this event. ex: "5656565656565656" - * @param created [string]: creation datetime for the log. ex: '2020-03-10 10:30:00.000' + * @param created [string]: datetime representing the moment when the attempt was made. ex: '2020-03-10 10:30:00.000' * */ constructor({ id, code, message, webhookId, eventId, created }) { @@ -57,17 +57,16 @@ exports.get = async function (id, { user } = {}) { exports.query = async function ({ resource, limit, after, before, eventIds, webhookIds, user } = {}) { /** * - * Retrieve Event Logs + * Retrieve Event Attempts * * @description Receive a generator of Event Attempt objects previously created in the Stark Infra API * * Parameters (optional): - * @param ids [list of string, default []]: list of Attempt ids to filter. ex: ['5656565656565656', '4545454545454545'] * @param limit [integer, default null]: maximum number of objects to be retrieved. Unlimited if null. ex: 35 * @param after [string, default null] date filter for objects created only after specified date. ex: '2020-03-10' * @param before [string, default null] date filter for objects created only before specified date. ex: '2020-03-10' - * @param types [list of strings, default null]: filter retrieved objects by types. ex: ["registered", "paid"] - * @param cardIds [list of strings, default []]: list of Event ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] + * @param eventIds [list of strings, default []]: list of Event ids to filter attempts. ex: ['5656565656565656', '4545454545454545'] + * @param webhookIds [list of strings, default []]: list of Webhook ids to filter attempts. ex: ['5656565656565656', '4545454545454545'] * @param user [Organization/Project object, default null]: Project object. Not necessary if starkinfra.user was set before function call * * Return: @@ -88,19 +87,18 @@ exports.query = async function ({ resource, limit, after, before, eventIds, webh exports.page = async function ({ cursor, resource, limit, after, before, eventIds, webhookIds, user } = {}) { /** * - * Retrieve paged Event Logs + * Retrieve paged Event Attempts * * @description Receive a list of up to 100 Event.Attempt objects previously created in the Stark Infra API and the cursor to the next page. * Use this function instead of query if you want to manually page your cards. * * Parameters (optional): * @param cursor [string, default null]: cursor returned on the previous page function call - * @param ids [list of string, default []]: list of Attempt ids to filter. ex: ['5656565656565656', '4545454545454545'] * @param limit [integer, default null]: maximum number of objects to be retrieved. Unlimited if null. ex: 35 * @param after [string, default null] date filter for objects created only after specified date. ex: '2020-03-10' * @param before [string, default null] date filter for objects created only before specified date. ex: '2020-03-10' - * @param types [list of strings, default null]: filter retrieved objects by types. ex: ["registered", "paid"] - * @param cardIds [list of strings, default []]: list of Event ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545'] + * @param eventIds [list of strings, default []]: list of Event ids to filter attempts. ex: ['5656565656565656', '4545454545454545'] + * @param webhookIds [list of strings, default []]: list of Webhook ids to filter attempts. ex: ['5656565656565656', '4545454545454545'] * @param user [Organization/Project object, default null]: Project object. Not necessary if starkinfra.user was set before function call * * Return: diff --git a/sdk/infractionReport/infractionReport.js b/sdk/infractionReport/infractionReport.js index 622c229..694755b 100644 --- a/sdk/infractionReport/infractionReport.js +++ b/sdk/infractionReport/infractionReport.js @@ -118,7 +118,7 @@ exports.query = async function ({ limit, after, before, status, ids, type, user * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call * * Return: - * @returns generator of PixRequest objects with updated attributes + * @returns generator of InfractionReport objects with updated attributes * */ let query = { @@ -135,9 +135,9 @@ exports.query = async function ({ limit, after, before, status, ids, type, user exports.page = async function ({ cursor, limit, after, before, status, ids, type, user } = {}) { /** * - * Retrieve paged PixRequests + * Retrieve paged InfractionReports * - * @description Receive a list of up to 100 PixRequest objects previously created in the Stark Infra API and the cursor to the next page. + * @description Receive a list of up to 100 InfractionReport objects previously created in the Stark Infra API and the cursor to the next page. * Use this function instead of query if you want to manually page your requests. * * Parameters (optional): @@ -151,7 +151,7 @@ exports.page = async function ({ cursor, limit, after, before, status, ids, type * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call * * Return: - * @returns list of PixRequest objects with updated attributes and cursor to retrieve the next page of PixRequest objects + * @returns list of InfractionReport objects with updated attributes and cursor to retrieve the next page of InfractionReport objects * */ let query = { @@ -181,7 +181,7 @@ exports.update = async function ( id, result, { analysis, user } = {}) { * @param analysis [string, default null]: analysis that led to the result. * * Return: - * @returns list of PixRequest objects with updated attributes and cursor to retrieve the next page of PixRequest objects + * @returns list of InfractionReport objects with updated attributes and cursor to retrieve the next page of InfractionReport objects * */ let payload = { diff --git a/sdk/issuingCard/log/log.js b/sdk/issuingCard/log/log.js index 8de7f2d..068d33f 100644 --- a/sdk/issuingCard/log/log.js +++ b/sdk/issuingCard/log/log.js @@ -16,15 +16,13 @@ class Log extends Resource { * @param id [string]: unique id returned when the log is created. ex: '5656565656565656' * @param created [string]: creation datetime for the log. ex: '2020-03-10 10:30:00.000' * @param type [string]: type of the IssuingCard event which triggered the log creation. ex: 'processing' or 'success' - * @param errors [list of strings]: list of errors linked to this IssuingCard event. * @param card [IssuingCard]: IssuingCard entity to which the log refers to. * */ - constructor({ id, created, type, errors, card }) { + constructor({ id, created, type, card }) { super(id); this.created = check.datetime(created); this.type = type; - this.errors = errors; this.card = card; } } diff --git a/sdk/issuingHolder/log/log.js b/sdk/issuingHolder/log/log.js index bc34f7d..e16b256 100644 --- a/sdk/issuingHolder/log/log.js +++ b/sdk/issuingHolder/log/log.js @@ -16,15 +16,13 @@ class Log extends Resource { * @param id [string]: unique id returned when the log is created. ex: '5656565656565656' * @param created [string]: creation datetime for the log. ex: '2020-03-10 10:30:00.000' * @param type [string]: type of the IssuingHolder event which triggered the log creation. ex: 'processing' or 'success' - * @param errors [list of strings]: list of errors linked to this IssuingHolder event. * @param holder [IssuingHolder]: IssuingHolder entity to which the log refers to. * */ - constructor({ id, created, type, errors, holder }) { + constructor({ id, created, type, holder }) { super(id); this.created = check.datetime(created); this.type = type; - this.errors = errors; this.holder = holder; } } diff --git a/sdk/issuingInvoice/log/index.js b/sdk/issuingInvoice/log/index.js index da4849e..af3ddf3 100644 --- a/sdk/issuingInvoice/log/index.js +++ b/sdk/issuingInvoice/log/index.js @@ -1,4 +1,5 @@ const log = require('./log.js'); +exports.get = log.get; exports.query = log.query; exports.page = log.page; diff --git a/sdk/issuingInvoice/log/log.js b/sdk/issuingInvoice/log/log.js index 60dd3b4..93fc0c3 100644 --- a/sdk/issuingInvoice/log/log.js +++ b/sdk/issuingInvoice/log/log.js @@ -16,15 +16,13 @@ class Log extends Resource { * @param id [string]: unique id returned when the log is created. ex: '5656565656565656' * @param created [string]: creation datetime for the log. ex: '2020-03-10 10:30:00.000' * @param type [string]: type of the IssuingInvoice event which triggered the log creation. ex: 'processing' or 'success' - * @param errors [list of strings]: list of errors linked to this IssuingInvoice event. * @param request [IssuingInvoice]: IssuingInvoice entity to which the log refers to. * */ - constructor({ id, created, type, errors, invoice }) { + constructor({ id, created, type, invoice }) { super(id); this.created = check.datetime(created); this.type = type; - this.errors = errors; this.invoice = invoice; } } @@ -33,6 +31,27 @@ exports.Log = Log; let resource = {'class': exports.Log, 'name': 'IssuingInvoiceLog'}; +exports.get = async function (id, { user } = {}) { + /** + * + * Retrieve a specific IssuingInvoice Log + * + * @description Receive a single IssuingInvoice Log object previously created by the Stark Infra API by passing its id + * + * Parameters (required): + * @param id [string]: object unique id. ex: '5656565656565656' + * + * Parameters (optional): + * @param user [Organization/Project object]: Organization or Project object. Not necessary if starkinfra.user was set before function call + * + * Return: + * @returns IssuingInvoice Log object with updated attributes + * + */ + return rest.getId(resource, id, user); +}; + + exports.query = async function ({ ids, types, after, before, limit, user } = {}) { /** * diff --git a/sdk/pixClaim/pixClaim.js b/sdk/pixClaim/pixClaim.js index c39a029..1e255b1 100644 --- a/sdk/pixClaim/pixClaim.js +++ b/sdk/pixClaim/pixClaim.js @@ -105,7 +105,7 @@ exports.get = async function (id, {user} = {}) { exports.query = async function ({ limit, after, before, status, ids, type, agent, keyType, keyId, user } = {}) { /** * - * Retrieve PixRequests + * Retrieve PixClaims * * @description Receive a generator of PixClaim objects previously created in the Stark Infra API * @@ -122,7 +122,7 @@ exports.query = async function ({ limit, after, before, status, ids, type, agent * @param user [Organization/Project object, default null]: Project object. Not necessary if starkinfra.user was set before function call * * Return: - * @returns generator of PixRequest objects with updated attributes + * @returns generator of PixClaim objects with updated attributes * */ let query = { @@ -191,11 +191,11 @@ exports.update = async function ( id, status, { reason, user } = {}) { * @param status [string]: patched status for Pix Claim. Options: "confirmed" and "canceled" * * Parameters (optional): - * @param reason [string, default: "userRequested"]: reason why the PixClaim is being patched. Options: "fraud", "userRequested". + * @param reason [string, default: "userRequested"]: reason why the PixClaim is being patched. Options: "fraud", "userRequested", "accountClosure". * @param user [Organization/Project object, default null]: Project object. Not necessary if starkinfra.user was set before function call * * Return: - * @returns list of PixRequest objects with updated attributes and cursor to retrieve the next page of PixRequest objects + * @returns list of PixClaim objects with updated attributes and cursor to retrieve the next page of PixClaim objects * */ let payload = { diff --git a/sdk/pixKey/pixKey.js b/sdk/pixKey/pixKey.js index 6e3341a..68daafd 100644 --- a/sdk/pixKey/pixKey.js +++ b/sdk/pixKey/pixKey.js @@ -95,6 +95,7 @@ exports.get = async function (id, payerId, { endToEndId, user } = {}) { * @param payerId [string]: tax id (CPF/CNPJ) of the individual or business requesting the PixKey information. This id is used by the Central Bank to limit request rates. ex: "20.018.183/0001-80". * * Parameters (optional): + * @param endToEndId [string, default None]: central bank's unique transaction id. If the request results in the creation of a PixRequest, the same endToEndId should be used. If this parameter is not passed, one endToEndId will be automatically created. Example: "E00002649202201172211u34srod19le" * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call * * Return: @@ -117,7 +118,7 @@ exports.query = async function ({ limit, after, before, status, tags, ids, type, * @param before [string, default null]: date filter for objects created before a specified date. ex: '2020-03-10' * @param status [list of strings, default null]: filter for status of retrieved objects. Options: "created", "failed", "delivered", "closed", "canceled". * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - * @param type [list of strings, default null]: filter for the type of retrieved PixKeys. Options: "fraud", "reversal", "reversalChargeback" + * @param type [strings, default null]: filter for the type of retrieved PixKeys. Options: "cpf", "cnpj", "phone", "email" and "evp" * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call * * Return: @@ -151,7 +152,7 @@ exports.page = async function ({ cursor, limit, after, before, status, tags, ids * @param before [string, default null]: date filter for objects created before a specified date. ex: '2020-03-10' * @param status [list of strings, default null]: filter for status of retrieved objects. Options: "created", "failed", "delivered", "closed", "canceled". * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - * @param type [list of strings, default null]: filter for the type of retrieved PixKeys. Options: "fraud", "reversal", "reversalChargeback" + * @param type [strings, default null]: filter for the type of retrieved PixKeys. Options: "cpf", "cnpj", "phone", "email" and "evp" * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call * * Return: @@ -176,7 +177,7 @@ exports.update = async function ( id, reason, { accountCreated, accountNumber, a * * Update PixKey entity * - * @description Update a PixKey parameters by passing id. + * @description Update a PixKey parameters by passing its id. * * Parameters (required): * @param id [string]: PixKey id. ex: '5656565656565656' diff --git a/sdk/reversalRequest/reversalRequest.js b/sdk/reversalRequest/reversalRequest.js index 39fa20e..6c29954 100644 --- a/sdk/reversalRequest/reversalRequest.js +++ b/sdk/reversalRequest/reversalRequest.js @@ -118,7 +118,6 @@ exports.query = async function ({ limit, after, before, status, ids, user } = {} * @param before [string, default null]: date filter for objects created before a specified date. ex: '2020-03-10' * @param status [list of strings, default null]: filter for status of retrieved objects. Options: "created", "failed", "delivered", "closed", "canceled". * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - * @param type [list of strings, default null]: filter for the type of retrieved ReversalRequests. Options: "fraud", "reversal", "reversalChargeback" * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call * * Return: @@ -150,7 +149,6 @@ exports.page = async function ({ cursor, limit, after, before, status, ids, user * @param before [string, default null]: date filter for objects created before a specified date. ex: '2020-03-10' * @param status [list of strings, default null]: filter for status of retrieved objects. Options: "created", "failed", "delivered", "closed", "canceled". * @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] - * @param type [list of strings, default null]: filter for the type of retrieved ReversalRequests. Options: "fraud", "reversal", "reversalChargeback" * @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call * * Return: diff --git a/sdk/user/index.js b/sdk/user/index.js index 2f970f9..9fc296a 100644 --- a/sdk/user/index.js +++ b/sdk/user/index.js @@ -1,4 +1,2 @@ -exports.bacenId = require('./bacenId.js'); -exports.returnId = require('./returnId.js'); exports.Project = require('./project.js').Project; exports.Organization = require('./organization.js').Organization; diff --git a/sdk/user/bacenId.js b/sdk/utils/bacenId.js similarity index 100% rename from sdk/user/bacenId.js rename to sdk/utils/bacenId.js diff --git a/sdk/user/returnId.js b/sdk/utils/returnId.js similarity index 67% rename from sdk/user/returnId.js rename to sdk/utils/returnId.js index 9aaaa5a..c225d0b 100644 --- a/sdk/user/returnId.js +++ b/sdk/utils/returnId.js @@ -1,4 +1,4 @@ -const {bacenId} = require("./index"); +const {bacenId} = require("../../index"); exports.create = function (bankCode) { diff --git a/tests/testIssuingInvoiceLog.js b/tests/testIssuingInvoiceLog.js index c4d6b79..4ae3f07 100644 --- a/tests/testIssuingInvoiceLog.js +++ b/tests/testIssuingInvoiceLog.js @@ -13,3 +13,15 @@ describe('TestIssuingInvoiceLogQuery', function() { } }); }); + +describe('TestIssuingInvoiceLogGet', function() { + this.timeout(10000); + it('test_success', async () => { + let logs = await starkinfra.issuingInvoice.log.query({'limit': 1}); + for await (let log of logs) { + assert(typeof log.id == 'string'); + log = await starkinfra.issuingInvoice.log.get(log.id); + assert(typeof log.id == 'string'); + } + }); +});