Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring for implement eslint and aumated tests #6

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
20 changes: 20 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": [
"airbnb-base"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
}
}
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.idea
node_modules/
package-lock.json
.idea
node_modules/
package-lock.json
40 changes: 20 additions & 20 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2019 Rede

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
MIT License
Copyright (c) 2019 Rede
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
154 changes: 77 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
# SDK Node.js

SDK de integração eRede

# Utilizando

## Autorizando uma transação

```js
const eRede = require('./lib/erede');
const Transaction = require('./lib/transaction');
const Store = require('./lib/store');
const Environment = require('./lib/environment');

let store = new Store('TOKEN', 'PV', Environment.sandbox());
let transaction = new Transaction(10, "ref123").creditCard(
'5448280000000007',
'235',
'12',
'2020',
'Fulano de Tal'
);

new eRede(store).create(transaction).then(transaction => {
if (transaction.returnCode === "00") {
console.log(`Transação autorizada com sucesso: ${transaction.tid}`);
}
});
```

Por padrão, a transação é capturada automaticamente; caso seja necessário apenas autorizar a transação, o método `Transaction.capture()` deverá ser chamado com o parâmetro `false`:

```js
const eRede = require('./lib/erede');
const Transaction = require('./lib/transaction');
const Store = require('./lib/store');
const Environment = require('./lib/environment');

let store = new Store('TOKEN', 'PV', Environment.sandbox());
let transaction = new Transaction(10, "ref123").creditCard(
'5448280000000007',
'235',
'12',
'2020',
'Fulano de Tal'
).autoCapture(false);

new eRede(store).create(transaction).then(transaction => {
if (transaction.returnCode === "00") {
console.log(`Transação autorizada com sucesso: ${transaction.tid}`);
}
});
```

## Autorizando uma transação com parcelamento

```js
const eRede = require('./lib/erede');
const Transaction = require('./lib/transaction');
const Store = require('./lib/store');
const Environment = require('./lib/environment');

let store = new Store('TOKEN', 'PV', Environment.sandbox());
let transaction = new Transaction(10, "ref123", 2).creditCard(
'5448280000000007',
'235',
'12',
'2020',
'Fulano de Tal'
);

new eRede(store).create(transaction).then(transaction => {
if (transaction.returnCode === "00") {
console.log(`Transação autorizada com sucesso: ${transaction.tid}`);
}
});
```
# SDK Node.js
SDK de integração eRede
# Utilizando
## Autorizando uma transação
```js
const eRede = require('./lib/erede');
const Transaction = require('./lib/transaction');
const Store = require('./lib/store');
const Environment = require('./lib/environment');
let store = new Store('TOKEN', 'PV', Environment.sandbox());
let transaction = new Transaction(10, "ref123").creditCard(
'5448280000000007',
'235',
'12',
'2020',
'Fulano de Tal'
);
new eRede(store).create(transaction).then(transaction => {
if (transaction.returnCode === "00") {
console.log(`Transação autorizada com sucesso: ${transaction.tid}`);
}
});
```
Por padrão, a transação é capturada automaticamente; caso seja necessário apenas autorizar a transação, o método `Transaction.capture()` deverá ser chamado com o parâmetro `false`:
```js
const eRede = require('./lib/erede');
const Transaction = require('./lib/transaction');
const Store = require('./lib/store');
const Environment = require('./lib/environment');
let store = new Store('TOKEN', 'PV', Environment.sandbox());
let transaction = new Transaction(10, "ref123").creditCard(
'5448280000000007',
'235',
'12',
'2020',
'Fulano de Tal'
).autoCapture(false);
new eRede(store).create(transaction).then(transaction => {
if (transaction.returnCode === "00") {
console.log(`Transação autorizada com sucesso: ${transaction.tid}`);
}
});
```
## Autorizando uma transação com parcelamento
```js
const eRede = require('./lib/erede');
const Transaction = require('./lib/transaction');
const Store = require('./lib/store');
const Environment = require('./lib/environment');
let store = new Store('TOKEN', 'PV', Environment.sandbox());
let transaction = new Transaction(10, "ref123", 2).creditCard(
'5448280000000007',
'235',
'12',
'2020',
'Fulano de Tal'
);
new eRede(store).create(transaction).then(transaction => {
if (transaction.returnCode === "00") {
console.log(`Transação autorizada com sucesso: ${transaction.tid}`);
}
});
```
20 changes: 0 additions & 20 deletions lib/additional.js

This file was deleted.

31 changes: 0 additions & 31 deletions lib/address.js

This file was deleted.

19 changes: 0 additions & 19 deletions lib/antifraud.js

This file was deleted.

21 changes: 0 additions & 21 deletions lib/authorization.js

This file was deleted.

21 changes: 0 additions & 21 deletions lib/capture.js

This file was deleted.

44 changes: 0 additions & 44 deletions lib/cart.js

This file was deleted.