Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
massaru-stark committed May 9, 2022
1 parent c0fee70 commit 5fc135f
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1241,15 +1253,15 @@ 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',
branchCode: '0000',
name: 'testKey',
taxId: '012.345.678-90',
keyId: '+5511989898989'
}));
});

console.log(claim);
})();
Expand Down Expand Up @@ -1353,15 +1365,15 @@ 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',
email: 'ned.stark@company.com',
password: '12345678',
teamEmail: 'pix.team@company.com',
teamPhones: ['+55-11988889999', '+55-11988889998']
}));
});

console.log(director);
})();
Expand All @@ -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);
})();
Expand Down Expand Up @@ -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);
})();
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 4 additions & 5 deletions sdk/brcodeCertificate/brcodeCertificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down
16 changes: 7 additions & 9 deletions sdk/event/attempt/attempt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions sdk/infractionReport/infractionReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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):
Expand All @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 1 addition & 3 deletions sdk/issuingCard/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 1 addition & 3 deletions sdk/issuingHolder/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions sdk/issuingInvoice/log/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const log = require('./log.js');

exports.get = log.get;
exports.query = log.query;
exports.page = log.page;
25 changes: 22 additions & 3 deletions sdk/issuingInvoice/log/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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 } = {}) {
/**
*
Expand Down
8 changes: 4 additions & 4 deletions sdk/pixClaim/pixClaim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down
Loading

0 comments on commit 5fc135f

Please sign in to comment.