diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100755 index 0000000..d217e1e --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,44 @@ +{ + "env": { + "browser": true, + "es2021": true, + "node": true + }, + "extends": [ + "airbnb-base", + "plugin:prettier/recommended", + "prettier" + ], + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint", + "prettier" + ], + "rules": { + + }, + "settings": { + "import/resolver": { + "node": { + "paths": [ + "src", + "examples" + ], + "extensions": [ + ".js", + ".jsx", + ".ts", + ".tsx" + ] + } + } + } +} diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..d5b2c24 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules +*.p12 +simulaMod.ts +teste.ts \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100755 index 0000000..1ebe8e2 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "printWidth": 100, + "tabWidth": 4, + "singleQuote": true, + "jsxBracketSameLine": true, + "trailingComma": "es5", + "semi": true +} \ No newline at end of file diff --git a/examples/config.ts b/examples/config.ts new file mode 100644 index 0000000..ee883bb --- /dev/null +++ b/examples/config.ts @@ -0,0 +1,18 @@ +export = { + // PRODUÇÃO = false + // HOMOLOGAÇÃO = true + sandbox: false, + + // CREDENCIAIS DE PRODUÇÃO + clientIdProducao: '', + clientSecretProducao: '', + pathCertProducao: '', + + // CREDENCIAIS DE HOMOLOGAÇÃO + clientIdHomologacao: '', + clientSecretHomologacao: '', + pathCertHomologacao: '', + + // VALIDAR MTLS? + validateMtls: false, +}; diff --git a/examples/defaults/carnet/cancelCarnet.ts b/examples/defaults/carnet/cancelCarnet.ts new file mode 100644 index 0000000..cd867f8 --- /dev/null +++ b/examples/defaults/carnet/cancelCarnet.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.cancelCarnet(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/cancelParcel.ts b/examples/defaults/carnet/cancelParcel.ts new file mode 100644 index 0000000..c534e54 --- /dev/null +++ b/examples/defaults/carnet/cancelParcel.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, + parcel: 1, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.cancelParcel(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/createCarnet.ts b/examples/defaults/carnet/createCarnet.ts new file mode 100644 index 0000000..2a8ca44 --- /dev/null +++ b/examples/defaults/carnet/createCarnet.ts @@ -0,0 +1,28 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + items: [ + { + name: 'Carnet Item 1', + value: 1000, + amount: 2, + }, + ], + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + repeats: 12, + split_items: false, + expire_at: '2022-01-05', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.createCarnet({}, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/createCarnetHistory.ts b/examples/defaults/carnet/createCarnetHistory.ts new file mode 100644 index 0000000..3791033 --- /dev/null +++ b/examples/defaults/carnet/createCarnetHistory.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1001, +}; + +const body = { + description: 'This carnet is about a service', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.createCarnetHistory(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/detailCarnet.ts b/examples/defaults/carnet/detailCarnet.ts new file mode 100644 index 0000000..4b45e1c --- /dev/null +++ b/examples/defaults/carnet/detailCarnet.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.detailCarnet(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/resendCarnet.ts b/examples/defaults/carnet/resendCarnet.ts new file mode 100644 index 0000000..07800e0 --- /dev/null +++ b/examples/defaults/carnet/resendCarnet.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1002, +}; + +const body = { + email: 'oldbuck@gerencianet.com.br', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.resendCarnet(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/resendParcel.ts b/examples/defaults/carnet/resendParcel.ts new file mode 100644 index 0000000..17c0136 --- /dev/null +++ b/examples/defaults/carnet/resendParcel.ts @@ -0,0 +1,17 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1002, + parcel: 1, +}; + +const body = { + email: 'oldbuck@gerencianet.com.br', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.resendParcel(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/settleCarnetParcel.ts b/examples/defaults/carnet/settleCarnetParcel.ts new file mode 100644 index 0000000..814b5d5 --- /dev/null +++ b/examples/defaults/carnet/settleCarnetParcel.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 26812, + parcel: 5, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.settleCarnetParcel(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/updateCarnetMetadata.ts b/examples/defaults/carnet/updateCarnetMetadata.ts new file mode 100644 index 0000000..965f767 --- /dev/null +++ b/examples/defaults/carnet/updateCarnetMetadata.ts @@ -0,0 +1,17 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1004, +}; + +const body = { + notification_url: 'http://yourdomain.com', + custom_id: 'my_new_id', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.updateCarnetMetadata(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/carnet/updateParcel.ts b/examples/defaults/carnet/updateParcel.ts new file mode 100644 index 0000000..00708c5 --- /dev/null +++ b/examples/defaults/carnet/updateParcel.ts @@ -0,0 +1,17 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1008, + parcel: 1 +}; + +const body = { + expire_at: '2020-12-12', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.updateParcel(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/cancelCharge.ts b/examples/defaults/charge/cancelCharge.ts new file mode 100644 index 0000000..1421d7e --- /dev/null +++ b/examples/defaults/charge/cancelCharge.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.cancelCharge(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/chargeLink.ts b/examples/defaults/charge/chargeLink.ts new file mode 100644 index 0000000..ef2963e --- /dev/null +++ b/examples/defaults/charge/chargeLink.ts @@ -0,0 +1,21 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const body = { + billet_discount: 0, + card_discount: 0, + message: '', + expire_at: '2021-01-05', + request_delivery_address: false, + payment_method: 'all', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.chargeLink(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createBilletPayment.ts b/examples/defaults/charge/createBilletPayment.ts new file mode 100644 index 0000000..93f885d --- /dev/null +++ b/examples/defaults/charge/createBilletPayment.ts @@ -0,0 +1,27 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const body = { + payment: { + banking_billet: { + expire_at: '2021-01-05', + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + }, + }, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.payCharge(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createCardPayment.ts b/examples/defaults/charge/createCardPayment.ts new file mode 100644 index 0000000..89f4878 --- /dev/null +++ b/examples/defaults/charge/createCardPayment.ts @@ -0,0 +1,36 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + payment: { + credit_card: { + installments: 1, + payment_token: '6426f3abd8688639c6772963669bbb8e0eb3c319', + billing_address: { + street: 'Av. JK', + number: 909, + neighborhood: 'Bauxita', + zipcode: '35400000', + city: 'Ouro Preto', + state: 'MG', + }, + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + }, + }, +}; + +const params = { + id: 1000, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.payCharge(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createCharge.ts b/examples/defaults/charge/createCharge.ts new file mode 100644 index 0000000..b7f2fa5 --- /dev/null +++ b/examples/defaults/charge/createCharge.ts @@ -0,0 +1,24 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + items: [ + { + name: 'Product 1', + value: 1000, + amount: 2, + }, + ], + shippings: [ + { + name: 'Default Shipping Cost', + value: 100, + }, + ], +}; + +const gerencianet = Gerencianet(options); + +gerencianet.createCharge({}, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createChargeBalanceSheet.ts b/examples/defaults/charge/createChargeBalanceSheet.ts new file mode 100644 index 0000000..8fbe4ba --- /dev/null +++ b/examples/defaults/charge/createChargeBalanceSheet.ts @@ -0,0 +1,78 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const body = { + title: 'Balancete Demonstrativo', + body: [ + { + header: 'Demonstrativo de Consumo', + tables: [ + { + rows: [ + [ + { + align: 'left', + color: '#000000', + style: 'bold', + text: 'Exemplo de despesa', + colspan: 2, + }, + { + align: 'left', + color: '#000000', + style: 'bold', + text: 'Total lançado', + colspan: 2, + }, + ], + [ + { + align: 'left', + color: '#000000', + style: 'normal', + text: 'Instalação', + colspan: 2, + }, + { + align: 'left', + color: '#000000', + style: 'normal', + text: 'R$ 100,00', + colspan: 2, + }, + ], + ], + }, + ], + }, + { + header: 'Balancete Geral', + tables: [ + { + rows: [ + [ + { + align: 'left', + color: '#000000', + style: 'normal', + text: + 'Confira na documentação da Gerencianet todas as configurações possíveis de um boleto balancete.', + colspan: 4, + }, + ], + ], + }, + ], + }, + ], +}; + +const gerencianet = Gerencianet(options); + +gerencianet.createChargeBalanceSheet(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createChargeHistory.ts b/examples/defaults/charge/createChargeHistory.ts new file mode 100644 index 0000000..e610f6d --- /dev/null +++ b/examples/defaults/charge/createChargeHistory.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1001, +}; + +const body = { + description: 'This charge was not fully paid', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.createChargeHistory(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createChargeOneStep.ts b/examples/defaults/charge/createChargeOneStep.ts new file mode 100644 index 0000000..468ca62 --- /dev/null +++ b/examples/defaults/charge/createChargeOneStep.ts @@ -0,0 +1,37 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + payment: { + banking_billet: { + expire_at: '2021-08-30', + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + }, + }, + + items: [ + { + name: 'Product 1', + value: 1000, + amount: 2, + }, + ], + shippings: [ + { + name: 'Default Shipping Cost', + value: 100, + }, + ], +}; + +const gerencianet = Gerencianet(options); + +gerencianet.oneStep([], body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createChargeOneStepBilletMarketPlace.ts b/examples/defaults/charge/createChargeOneStepBilletMarketPlace.ts new file mode 100644 index 0000000..4f6a1cf --- /dev/null +++ b/examples/defaults/charge/createChargeOneStepBilletMarketPlace.ts @@ -0,0 +1,49 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + payment: { + banking_billet: { + expire_at: '2019-09-20', + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + }, + }, + + items: [ + { + name: 'Product 1', + value: 500, + amount: 1, + marketplace: { + repasses: [ + { + payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', + percentage: 2500, + }, + { + payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', + percentage: 1500, + }, + ], + }, + }, + ], + shippings: [ + { + name: 'Default Shipping Cost', + value: 100, + }, + ], +}; + +const gerencianet = Gerencianet(options); + +gerencianet.oneStep([], body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createChargeOneStepCardMarketPlace.ts b/examples/defaults/charge/createChargeOneStepCardMarketPlace.ts new file mode 100644 index 0000000..8a07ea5 --- /dev/null +++ b/examples/defaults/charge/createChargeOneStepCardMarketPlace.ts @@ -0,0 +1,58 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + payment: { + credit_card: { + installments: 1, + payment_token: 'InsiraAquiUmPayeementeCode', + billing_address: { + street: 'Street 3', + number: 10, + neighborhood: 'Bauxita', + zipcode: '35400000', + city: 'Ouro Preto', + state: 'MG', + }, + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + }, + }, + + items: [ + { + name: 'Product 1', + value: 500, + amount: 1, + marketplace: { + repasses: [ + { + payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', + percentage: 2500, + }, + { + payee_code: 'Insira_aqui_o_indentificador_da_conta_destino', + percentage: 1500, + }, + ], + }, + }, + ], + shippings: [ + { + name: 'Default Shipping Cost', + value: 100, + }, + ], +}; + +const gerencianet = Gerencianet(options); + +gerencianet.oneStep([], body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/createChargeOneStepCreditCard.ts b/examples/defaults/charge/createChargeOneStepCreditCard.ts new file mode 100644 index 0000000..1bd9b62 --- /dev/null +++ b/examples/defaults/charge/createChargeOneStepCreditCard.ts @@ -0,0 +1,46 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + payment: { + credit_card: { + installments: 1, + payment_token: '83d52dbd590d9ebc991938c711ddd31f65df89a5', + billing_address: { + street: 'Street 3', + number: 10, + neighborhood: 'Bauxita', + zipcode: '35400000', + city: 'Ouro Preto', + state: 'MG', + }, + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + }, + }, + + items: [ + { + name: 'Product 1', + value: 1000, + amount: 2, + }, + ], + shippings: [ + { + name: 'Default Shipping Cost', + value: 100, + }, + ], +}; + +const gerencianet = Gerencianet(options); + +gerencianet.oneStep([], body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/detailCharge.ts b/examples/defaults/charge/detailCharge.ts new file mode 100644 index 0000000..b0e3e15 --- /dev/null +++ b/examples/defaults/charge/detailCharge.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.detailCharge(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/resendBillet.ts b/examples/defaults/charge/resendBillet.ts new file mode 100644 index 0000000..95c121e --- /dev/null +++ b/examples/defaults/charge/resendBillet.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1000, +}; + +const body = { + email: 'oldbuck@gerencianet.com.br', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.resendBillet(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/settleCharge.ts b/examples/defaults/charge/settleCharge.ts new file mode 100644 index 0000000..cfd388b --- /dev/null +++ b/examples/defaults/charge/settleCharge.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 553834, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.settleCharge(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/updateBillet.ts b/examples/defaults/charge/updateBillet.ts new file mode 100644 index 0000000..f93672e --- /dev/null +++ b/examples/defaults/charge/updateBillet.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1008, +}; + +const body = { + expire_at: '2020-12-12', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.updateBillet(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/updateChargeLink.ts b/examples/defaults/charge/updateChargeLink.ts new file mode 100644 index 0000000..6cac7b3 --- /dev/null +++ b/examples/defaults/charge/updateChargeLink.ts @@ -0,0 +1,21 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const body = { + billet_discount: 0, + card_discount: 0, + message: '', + expire_at: '2021-01-05', + request_delivery_address: false, + payment_method: 'all', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.updateChargeLink(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/charge/updateChargeMetadata.ts b/examples/defaults/charge/updateChargeMetadata.ts new file mode 100644 index 0000000..972ef04 --- /dev/null +++ b/examples/defaults/charge/updateChargeMetadata.ts @@ -0,0 +1,17 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1008, +}; + +const body = { + notification_url: 'http://yourdomain.com', + custom_id: 'my_new_id', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.updateChargeMetadata(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/notification/getNotification.ts b/examples/defaults/notification/getNotification.ts new file mode 100644 index 0000000..5a3e361 --- /dev/null +++ b/examples/defaults/notification/getNotification.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + token: '252948279264ee47e117cb099ef81', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.getNotification(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/others/getInstallments.ts b/examples/defaults/others/getInstallments.ts new file mode 100644 index 0000000..bc20b73 --- /dev/null +++ b/examples/defaults/others/getInstallments.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + brand: 'visa', + total: 5000, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.getInstallments(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/cancelSubscription.ts b/examples/defaults/subscription/cancelSubscription.ts new file mode 100644 index 0000000..2e0bd1b --- /dev/null +++ b/examples/defaults/subscription/cancelSubscription.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.cancelSubscription(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/createPlan.ts b/examples/defaults/subscription/createPlan.ts new file mode 100644 index 0000000..1595532 --- /dev/null +++ b/examples/defaults/subscription/createPlan.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = {}; + +const body = { + name: 'My first plan', + repeats: 24, + interval: 2, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.createPlan(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/createSubscription.ts b/examples/defaults/subscription/createSubscription.ts new file mode 100644 index 0000000..d285e3b --- /dev/null +++ b/examples/defaults/subscription/createSubscription.ts @@ -0,0 +1,37 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const planBody = { + name: 'My first plan', + repeats: 24, + interval: 2, +}; + +const subscriptionBody = { + items: [ + { + name: 'Product 1', + value: 1000, + amount: 2, + }, + ], +}; + +const gerencianet = Gerencianet(options); + +const createSubscription = (response: any) => { + const params = { + id: response.data.plan_id, + }; + + return gerencianet.createSubscription(params, subscriptionBody); +}; + +gerencianet + .createPlan({}, planBody) + .then(createSubscription) + .then(console.log) + .catch(console.log) + .done(); diff --git a/examples/defaults/subscription/createSubscriptionHistory.ts b/examples/defaults/subscription/createSubscriptionHistory.ts new file mode 100644 index 0000000..2c82683 --- /dev/null +++ b/examples/defaults/subscription/createSubscriptionHistory.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1001, +}; + +const body = { + description: 'This subscription is about a service', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.createSubscriptionHistory(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/createSubscriptionPayment.ts b/examples/defaults/subscription/createSubscriptionPayment.ts new file mode 100644 index 0000000..61d3830 --- /dev/null +++ b/examples/defaults/subscription/createSubscriptionPayment.ts @@ -0,0 +1,35 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const body = { + payment: { + credit_card: { + payment_token: '33ffd6d982cd63f767fb2ee5c458cd39e8fc0ea0', + billing_address: { + street: 'Av. JK', + number: 909, + neighborhood: 'Bauxita', + zipcode: '35400000', + city: 'Ouro Preto', + state: 'MG', + }, + customer: { + name: 'Gorbadoc Oldbuck', + email: 'oldbuck@gerencianet.com.br', + cpf: '94271564656', + birth: '1977-01-15', + phone_number: '5144916523', + }, + }, + }, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.paySubscription(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/deletePlan.ts b/examples/defaults/subscription/deletePlan.ts new file mode 100644 index 0000000..aa6c751 --- /dev/null +++ b/examples/defaults/subscription/deletePlan.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.deletePlan(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/detailSubscription.ts b/examples/defaults/subscription/detailSubscription.ts new file mode 100644 index 0000000..f45f838 --- /dev/null +++ b/examples/defaults/subscription/detailSubscription.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.detailSubscription(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/getPlans.ts b/examples/defaults/subscription/getPlans.ts new file mode 100644 index 0000000..b3ad2f3 --- /dev/null +++ b/examples/defaults/subscription/getPlans.ts @@ -0,0 +1,14 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + name: 'My Plan', + limit: 20, + offset: 0, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.getPlans(params).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/updatePlan.ts b/examples/defaults/subscription/updatePlan.ts new file mode 100644 index 0000000..9f214d3 --- /dev/null +++ b/examples/defaults/subscription/updatePlan.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1008, +}; + +const body = { + name: 'My new plan', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.updatePlan(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/defaults/subscription/updateSubscriptionMetadata.ts b/examples/defaults/subscription/updateSubscriptionMetadata.ts new file mode 100644 index 0000000..cab473e --- /dev/null +++ b/examples/defaults/subscription/updateSubscriptionMetadata.ts @@ -0,0 +1,17 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: 1009, +}; + +const body = { + notification_url: 'http://yourdomain.com', + custom_id: 'my_new_id', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.updateSubscriptionMetadata(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/gn/account/gnDetailBalance.ts b/examples/gn/account/gnDetailBalance.ts new file mode 100644 index 0000000..9d01a46 --- /dev/null +++ b/examples/gn/account/gnDetailBalance.ts @@ -0,0 +1,8 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const gerencianet = Gerencianet(options); + +gerencianet.gnDetailBalance().then(console.log).catch(console.log).done(); diff --git a/examples/gn/account/gnDetailSettings.ts b/examples/gn/account/gnDetailSettings.ts new file mode 100644 index 0000000..cfbc617 --- /dev/null +++ b/examples/gn/account/gnDetailSettings.ts @@ -0,0 +1,9 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ + +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const gerencianet = Gerencianet(options); + +gerencianet.gnDetailSettings().then(console.log).catch(console.log).done(); diff --git a/examples/gn/account/gnUpdateSettings.ts b/examples/gn/account/gnUpdateSettings.ts new file mode 100644 index 0000000..874f5f3 --- /dev/null +++ b/examples/gn/account/gnUpdateSettings.ts @@ -0,0 +1,24 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + pix: { + receberSemChave: true, + chaves: { + SUACHAVEPIX: { + recebimento: { + txidObrigatorio: false, + qrCodeEstatico: { + recusarTodos: false, + }, + }, + }, + }, + }, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixUpdateSettings([], body).then(console.log).catch(console.log).done(); diff --git a/examples/gn/key/gnCreateEvp.ts b/examples/gn/key/gnCreateEvp.ts new file mode 100644 index 0000000..6d58ca9 --- /dev/null +++ b/examples/gn/key/gnCreateEvp.ts @@ -0,0 +1,9 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ + +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const gerencianet = Gerencianet(options); + +gerencianet.gnCreateEvp().then(console.log).catch(console.log).done(); diff --git a/examples/gn/key/gnDeleteEvp.ts b/examples/gn/key/gnDeleteEvp.ts new file mode 100644 index 0000000..662a364 --- /dev/null +++ b/examples/gn/key/gnDeleteEvp.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ + +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + chave: 'SUACHAVEPIX', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.gnDeleteEvp(params).then(console.log).catch(console.log).done(); diff --git a/examples/gn/key/gnListEvp.ts b/examples/gn/key/gnListEvp.ts new file mode 100644 index 0000000..8413b50 --- /dev/null +++ b/examples/gn/key/gnListEvp.ts @@ -0,0 +1,9 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ + +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const gerencianet = Gerencianet(options); + +gerencianet.gnListEvp().then(console.log).catch(console.log).done(); diff --git a/examples/package.json b/examples/package.json new file mode 100644 index 0000000..a31b071 --- /dev/null +++ b/examples/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "gn-api-sdk-typescript": "https://github.com/gerencianet/gn-api-sdk-typescript.git" + } +} \ No newline at end of file diff --git a/examples/pix/charge/pixCreateCharge.ts b/examples/pix/charge/pixCreateCharge.ts new file mode 100644 index 0000000..8b1bf61 --- /dev/null +++ b/examples/pix/charge/pixCreateCharge.ts @@ -0,0 +1,37 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + calendario: { + expiracao: 3600, + }, + devedor: { + cpf: '94271564656', + nome: 'Gorbadock Oldbuck', + }, + valor: { + original: '123.45', + }, + chave: 'SUACHAVEPIX', // Informe sua chave Pix cadastrada na Gerencianet + // o campo abaixo é opcional + infoAdicionais: [ + { + nome: 'Pagamento em', + valor: 'NOME DO SEU ESTABELECIMENTO', + }, + { + nome: 'Pedido', + valor: 'NUMERO DO PEDIDO DO CLIENTE', + }, + ], +}; + +const params = { + txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVq111', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixCreateCharge(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/pix/charge/pixCreateImmediateCharge.ts b/examples/pix/charge/pixCreateImmediateCharge.ts new file mode 100644 index 0000000..ab5d39e --- /dev/null +++ b/examples/pix/charge/pixCreateImmediateCharge.ts @@ -0,0 +1,36 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + calendario: { + expiracao: 3600, + }, + devedor: { + cpf: '94271564656', + nome: 'Gorbadock Oldbuck', + }, + valor: { + original: '123.45', + }, + chave: '+5522999486347', // Informe sua chave Pix cadastrada na Gerencianet + infoAdicionais: [ + { + nome: 'Pagamento em', + valor: 'NOME DO SEU ESTABELECIMENTO', + }, + { + nome: 'Pedido', + valor: 'NUMERO DO PEDIDO DO CLIENTE', + }, + ], +}; + +const params = { + txid: 'dt9BHlyzrb5jrFNAdfEDmDbVqVxdVpHgiO', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixCreateImmediateCharge(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/pix/charge/pixDetailCharge.ts b/examples/pix/charge/pixDetailCharge.ts new file mode 100644 index 0000000..75f58c1 --- /dev/null +++ b/examples/pix/charge/pixDetailCharge.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVqVxd', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixDetailCharge(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/charge/pixListCharges.ts b/examples/pix/charge/pixListCharges.ts new file mode 100644 index 0000000..3f3f329 --- /dev/null +++ b/examples/pix/charge/pixListCharges.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + inicio: '2021-01-22T16:01:35Z', + fim: '2021-11-30T20:10:00Z', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixListCharges(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/charge/pixUpdateCharge.ts b/examples/pix/charge/pixUpdateCharge.ts new file mode 100644 index 0000000..3f85ecf --- /dev/null +++ b/examples/pix/charge/pixUpdateCharge.ts @@ -0,0 +1,37 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +// Informe no body somente os dados que deseja atualizar +const body = { + calendario: { + expiracao: 3600, + }, + devedor: { + cpf: '94271564656', + nome: 'Gorbadock Oldbuck', + }, + valor: { + original: '123.45', + }, + chave: 'SUACHAVEPIX', // Informe sua chave Pix cadastrada na Gerencianet + infoAdicionais: [ + { + nome: 'Pagamento em', + valor: 'NOME DO SEU ESTABELECIMENTO', + }, + { + nome: 'Pedido', + valor: 'NUMERO DO PEDIDO DO CLIENTE', + }, + ], +}; + +const params = { + txid: 'dt9BHlyzrb5jrFNAdfEDVpHgiOmDbVqVxd', // Informe o TxId da cobrança +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixUpdateCharge(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/pix/location/pixCreateLocation.ts b/examples/pix/location/pixCreateLocation.ts new file mode 100644 index 0000000..a845c44 --- /dev/null +++ b/examples/pix/location/pixCreateLocation.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + tipoCob: 'cob', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixCreateLocation([], body).then(console.log).catch(console.log).done(); diff --git a/examples/pix/location/pixDetailLocation.ts b/examples/pix/location/pixDetailLocation.ts new file mode 100644 index 0000000..2a4f686 --- /dev/null +++ b/examples/pix/location/pixDetailLocation.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: '95', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixDetailLocation(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/location/pixGenerateQRCode.ts b/examples/pix/location/pixGenerateQRCode.ts new file mode 100644 index 0000000..5c09532 --- /dev/null +++ b/examples/pix/location/pixGenerateQRCode.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: '95', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixGenerateQRCode(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/location/pixListLocation.ts b/examples/pix/location/pixListLocation.ts new file mode 100644 index 0000000..c3e781b --- /dev/null +++ b/examples/pix/location/pixListLocation.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + inicio: '2021-01-22T16:01:35Z', + fim: '2021-11-30T20:10:00Z', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixListLocation(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/location/pixUnsetTxid.ts b/examples/pix/location/pixUnsetTxid.ts new file mode 100644 index 0000000..b0e8354 --- /dev/null +++ b/examples/pix/location/pixUnsetTxid.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + id: '95', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixUnsetTxid(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/pix/pixDetail.ts b/examples/pix/pix/pixDetail.ts new file mode 100644 index 0000000..5e9ef5b --- /dev/null +++ b/examples/pix/pix/pixDetail.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + e2eId: 'E18236120202104191813s0326120V4K', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixDetail(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/pix/pixDetailDevolution.ts b/examples/pix/pix/pixDetailDevolution.ts new file mode 100644 index 0000000..8eaee71 --- /dev/null +++ b/examples/pix/pix/pixDetailDevolution.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + e2eId: 'E18236120202104191813s0326120V4K', + id: '607dc88bb83bf', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixDetailDevolution(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/pix/pixDevolution.ts b/examples/pix/pix/pixDevolution.ts new file mode 100644 index 0000000..968a859 --- /dev/null +++ b/examples/pix/pix/pixDevolution.ts @@ -0,0 +1,17 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + valor: '7.89', +}; + +const params = { + e2eId: 'E18236120202104191813s0326120V4K', + id: '101', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixDevolution(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/pix/pix/pixListReceived.ts b/examples/pix/pix/pixListReceived.ts new file mode 100644 index 0000000..874e401 --- /dev/null +++ b/examples/pix/pix/pixListReceived.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + inicio: '2021-01-22T16:01:35Z', + fim: '2021-11-30T20:10:00Z', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixListReceived(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/pix/pixSend.ts b/examples/pix/pix/pixSend.ts new file mode 100644 index 0000000..4f937b6 --- /dev/null +++ b/examples/pix/pix/pixSend.ts @@ -0,0 +1,18 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + valor: '12.34', + pagador: { + chave: 'SUACHAVEPIX', + }, + favorecido: { + chave: 'ChavePixDeDestino', + }, +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixSend(body).then(console.log).catch(console.log).done(); diff --git a/examples/pix/webhook/pixConfigWebhook.ts b/examples/pix/webhook/pixConfigWebhook.ts new file mode 100644 index 0000000..a12785b --- /dev/null +++ b/examples/pix/webhook/pixConfigWebhook.ts @@ -0,0 +1,16 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const body = { + webhookUrl: 'https://exemplo-pix/webhook', +}; + +const params = { + chave: 'SUACHAVEPIX', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixConfigWebhook(params, body).then(console.log).catch(console.log).done(); diff --git a/examples/pix/webhook/pixDeleteWebhook.ts b/examples/pix/webhook/pixDeleteWebhook.ts new file mode 100644 index 0000000..da1feec --- /dev/null +++ b/examples/pix/webhook/pixDeleteWebhook.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + chave: 'SUACHAVEPIX', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixDeleteWebhook(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/webhook/pixDetailWebhook.ts b/examples/pix/webhook/pixDetailWebhook.ts new file mode 100644 index 0000000..73c27ab --- /dev/null +++ b/examples/pix/webhook/pixDetailWebhook.ts @@ -0,0 +1,12 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + chave: 'SUACHAVEPIX', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixDetailWebhook(params).then(console.log).catch(console.log).done(); diff --git a/examples/pix/webhook/pixListWebhook.ts b/examples/pix/webhook/pixListWebhook.ts new file mode 100644 index 0000000..78d9e7f --- /dev/null +++ b/examples/pix/webhook/pixListWebhook.ts @@ -0,0 +1,13 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import Gerencianet from 'gn-api-sdk-typescript'; +import options from '../../config'; + +const params = { + inicio: '2021-01-22T16:01:35Z', + fim: '2021-11-30T20:10:00Z', +}; + +const gerencianet = Gerencianet(options); + +gerencianet.pixListWebhook(params).then(console.log).catch(console.log).done(); diff --git a/index.ts b/index.ts new file mode 100755 index 0000000..624cda2 --- /dev/null +++ b/index.ts @@ -0,0 +1,32 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import GnSdk from './src/gn-sdk'; +import { ConfigInterface } from './src/interfaces/config.interface'; +import { CredentialsInterface } from './src/interfaces/credentials.interface'; + +export = (options: ConfigInterface) => { + let credentials: CredentialsInterface; + + if (options.sandbox) { + credentials = { + clientId: options.clientIdHomologacao, + clientSecret: options.clientSecretHomologacao, + pathCert: options.pathCertHomologacao, + sandbox: options.sandbox, + }; + } else { + credentials = { + clientId: options.clientIdProducao, + clientSecret: options.clientSecretProducao, + pathCert: options.pathCertProducao, + sandbox: options.sandbox, + }; + } + if (options.partnerToken) { + credentials.partnerToken = options.partnerToken; + } + if (options.validateMtls) { + credentials.validateMtls = options.validateMtls; + } + return new GnSdk(credentials); +}; diff --git a/package.json b/package.json new file mode 100755 index 0000000..026b7a4 --- /dev/null +++ b/package.json @@ -0,0 +1,46 @@ +{ + "name": "gn-api-sdk-typescript", + "version": "1.0.0", + "description": "Module for integration with Gerencianet API\"", + "main": "dist/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Gerencianet - Consultoria Tecnica | João Vitor Oliveira", + "license": "MIT", + "repository": "gerencianet/gn-api-sdk-typescript", + "homepage": "https://github.com/gerencianet/gn-api-sdk-typescript", + "keywords": [ + "gerencianet", + "pagamentos", + "payment", + "sdk", + "integração", + "integration", + "api", + "bank slip", + "boleto bancario", + "credit card", + "cartao de credito", + "pix" + ], + "devDependencies": { + "@types/node": "^15.0.1", + "@types/q": "^1.5.4", + "@typescript-eslint/eslint-plugin": "^4.22.0", + "@typescript-eslint/parser": "^4.22.0", + "eslint": "^7.25.0", + "eslint-config-airbnb-base": "^14.2.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.4.0", + "prettier": "^2.2.1", + "ts-node": "^9.1.1", + "typescript": "^4.2.4" + }, + "dependencies": { + "axios": "^0.21.1", + "fs": "*", + "q": "^1.5.1" + } +} diff --git a/src/gn-auth.ts b/src/gn-auth.ts new file mode 100755 index 0000000..4a83f45 --- /dev/null +++ b/src/gn-auth.ts @@ -0,0 +1,88 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import fs, { PathLike } from 'fs'; +import axios from 'axios'; +import https from 'https'; +import sdkPackage from '../package.json'; +import { CredentialsInterface } from './interfaces/credentials.interface'; + +class GnAuth { + private constants: any; + + private clientId: String; + + private clientSecret: String; + + private pathCert: PathLike; + + private baseUrl?: String; + + private certificate?: Buffer; + + constructor(options: CredentialsInterface, constants: any) { + this.constants = constants; + this.clientId = options.clientId; + this.clientSecret = options.clientSecret; + this.pathCert = options.pathCert; + this.baseUrl = options.baseUrl; + } + + public getAccessToken(): Promise { + let postParams: any; + // eslint-disable-next-line prettier/prettier + if ( this.constants.URL.PIX.production === this.baseUrl || this.constants.URL.PIX.sandbox === this.baseUrl) { + try { + this.certificate = fs.readFileSync(this.pathCert); + } catch (error) { + throw new Error('FALHA AO LER O CERTIFICADO'); + } + const dataCredentials = `${this.clientId}:${this.clientSecret}`; + const auth = Buffer.from(dataCredentials).toString('base64'); + + const agent = new https.Agent({ + pfx: this.certificate, + passphrase: '', + }); + + postParams = { + method: 'POST', + url: this.baseUrl + this.constants.ENDPOINTS.PIX.authorize.route, + headers: { + Authorization: `Basic ${auth}`, + 'Content-Type': 'application/json', + 'api-sdk': `typescript-${sdkPackage.version}`, + }, + httpsAgent: agent, + data: { + grant_type: 'client_credentials', + }, + }; + } else { + postParams = { + method: 'POST', + url: String(this.baseUrl + this.constants.ENDPOINTS.DEFAULT.authorize.route), + auth: { + username: this.clientId, + password: this.clientSecret, + }, + data: { + grant_type: 'client_credentials', + }, + headers: { + 'api-sdk': `typescript-${sdkPackage.version}`, + }, + }; + } + const response = axios(postParams) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.error(error); + }); + + return response; + } +} + +export default GnAuth; diff --git a/src/gn-constants.ts b/src/gn-constants.ts new file mode 100755 index 0000000..505c0a3 --- /dev/null +++ b/src/gn-constants.ts @@ -0,0 +1,271 @@ +export = { + URL: { + DEFAULT: { + production: 'https://api.gerencianet.com.br/v1', + sandbox: 'https://sandbox.gerencianet.com.br/v1', + }, + PIX: { + production: 'https://api-pix.gerencianet.com.br', + sandbox: 'https://api-pix-h.gerencianet.com.br', + }, + }, + ENDPOINTS: { + PIX: { + authorize: { + route: '/oauth/token', + method: 'post', + }, + pixCreateCharge: { + route: '/v2/cob/:txid', + method: 'put', + }, + pixUpdateCharge: { + route: '/v2/cob/:txid', + method: 'patch', + }, + pixCreateImmediateCharge: { + route: '/v2/cob', + method: 'post', + }, + pixDetailCharge: { + route: '/v2/cob/:txid', + method: 'get', + }, + pixListCharges: { + route: '/v2/cob', + method: 'get', + }, + pixDetail: { + route: '/v2/pix/:e2eId', + method: 'get', + }, + pixListReceived: { + route: '/v2/pix', + method: 'get', + }, + pixSend: { + route: '/v2/pix', + method: 'post', + }, + pixDevolution: { + route: '/v2/pix/:e2eId/devolucao/:id', + method: 'put', + }, + pixDetailDevolution: { + route: '/v2/pix/:e2eId/devolucao/:id', + method: 'get', + }, + pixConfigWebhook: { + route: '/v2/webhook/:chave', + method: 'put', + }, + pixDetailWebhook: { + route: '/v2/webhook/:chave', + method: 'get', + }, + pixListWebhook: { + route: '/v2/webhook', + method: 'get', + }, + pixDeleteWebhook: { + route: '/v2/webhook/:chave', + method: 'delete', + }, + pixCreateLocation: { + route: '/v2/loc', + method: 'post', + }, + pixListLocation: { + route: '/v2/loc', + method: 'get', + }, + pixDetailLocation: { + route: '/v2/loc/:id', + method: 'get', + }, + pixGenerateQRCode: { + route: '/v2/loc/:id/qrcode', + method: 'get', + }, + pixUnsetTxid: { + route: '/v2/loc/:id/txid', + method: 'delete', + }, + gnCreateEvp: { + route: '/v2/gn/evp', + method: 'post', + }, + gnListEvp: { + route: '/v2/gn/evp', + method: 'get', + }, + gnDeleteEvp: { + route: '/v2/gn/evp/:chave', + method: 'delete', + }, + gnDetailBalance: { + route: '/v2/gn/saldo', + method: 'get', + }, + gnUpdateSettings: { + route: '/v2/gn/config', + method: 'put', + }, + gnDetailSettings: { + route: '/v2/gn/config', + method: 'get', + }, + }, + + DEFAULT: { + authorize: { + route: '/authorize', + method: 'post', + }, + createCharge: { + route: '/charge', + method: 'post', + }, + detailCharge: { + route: '/charge/:id', + method: 'get', + }, + updateChargeMetadata: { + route: '/charge/:id/metadata', + method: 'put', + }, + updateBillet: { + route: '/charge/:id/billet', + method: 'put', + }, + payCharge: { + route: '/charge/:id/pay', + method: 'post', + }, + cancelCharge: { + route: '/charge/:id/cancel', + method: 'put', + }, + createCarnet: { + route: '/carnet', + method: 'post', + }, + detailCarnet: { + route: '/carnet/:id', + method: 'get', + }, + updateParcel: { + route: '/carnet/:id/parcel/:parcel', + method: 'put', + }, + updateCarnetMetadata: { + route: '/carnet/:id/metadata', + method: 'put', + }, + getNotification: { + route: '/notification/:token', + method: 'get', + }, + getPlans: { + route: '/plans', + method: 'get', + }, + createPlan: { + route: '/plan', + method: 'post', + }, + deletePlan: { + route: '/plan/:id', + method: 'del', + }, + createSubscription: { + route: '/plan/:id/subscription', + method: 'post', + }, + detailSubscription: { + route: '/subscription/:id', + method: 'get', + }, + paySubscription: { + route: '/subscription/:id/pay', + method: 'post', + }, + cancelSubscription: { + route: '/subscription/:id/cancel', + method: 'put', + }, + updateSubscriptionMetadata: { + route: '/subscription/:id/metadata', + method: 'put', + }, + getInstallments: { + route: '/installments', + method: 'get', + }, + resendBillet: { + route: '/charge/:id/billet/resend', + method: 'post', + }, + createChargeHistory: { + route: '/charge/:id/history', + method: 'post', + }, + resendCarnet: { + route: '/carnet/:id/resend', + method: 'post', + }, + resendParcel: { + route: '/carnet/:id/parcel/:parcel/resend', + method: 'post', + }, + createCarnetHistory: { + route: '/carnet/:id/history', + method: 'post', + }, + cancelCarnet: { + route: '/carnet/:id/cancel', + method: 'put', + }, + cancelParcel: { + route: '/carnet/:id/parcel/:parcel/cancel', + method: 'put', + }, + linkCharge: { + route: '/charge/:id/link', + method: 'post', + }, + chargeLink: { + route: '/charge/:id/link', + method: 'post', + }, + updateChargeLink: { + route: '/charge/:id/link', + method: 'put', + }, + updatePlan: { + route: '/plan/:id', + method: 'put', + }, + createSubscriptionHistory: { + route: '/subscription/:id/history', + method: 'post', + }, + createChargeBalanceSheet: { + route: '/charge/:id/balance-sheet', + method: 'post', + }, + settleCharge: { + route: '/charge/:id/settle', + method: 'put', + }, + settleCarnetParcel: { + route: '/carnet/:id/parcel/:parcel/settle', + method: 'put', + }, + oneStep: { + route: '/charge/one-step', + method: 'post', + }, + }, + }, +}; diff --git a/src/gn-endpoints.ts b/src/gn-endpoints.ts new file mode 100755 index 0000000..2381bd4 --- /dev/null +++ b/src/gn-endpoints.ts @@ -0,0 +1,214 @@ +/* eslint-disable import/extensions */ +import fs from 'fs'; +import q from 'q'; +import https from 'https'; +import axios from 'axios'; +import GnAuth from './gn-auth'; +import sdkPackage from '../package.json'; +import { CredentialsInterface } from './interfaces/credentials.interface'; +import { EndpointInterface } from './interfaces/endpoint.interface'; + +class GnEndpoints { + private options: CredentialsInterface; + + private accessToken!: String; + + private constants: any; + + private defer!: any; + + private certificate!: Buffer; + + private agent: any; + + private endpoint!: EndpointInterface; + + private body: any; + + private params: any; + + constructor(options: CredentialsInterface, constants: any) { + this.options = options; + this.constants = constants; + } + + public run(name: any, params: any, body: any): Promise { + this.defer = q.defer(); + if (Object.keys(this.constants.ENDPOINTS.PIX).includes(name)) { + try { + this.certificate = fs.readFileSync(this.options.pathCert); + this.agent = new https.Agent({ + pfx: this.certificate, + passphrase: '', + }); + } catch (error) { + throw new Error(`FALHA AO LER O CERTIFICADO: \n${error}`); + } + this.endpoint = this.constants.ENDPOINTS.PIX[name]; + this.options.baseUrl = this.options.sandbox + ? this.constants.URL.PIX.sandbox + : this.constants.URL.PIX.production; + } else { + this.endpoint = this.constants.ENDPOINTS.DEFAULT[name]; + this.options.baseUrl = this.options.sandbox + ? this.constants.URL.DEFAULT.sandbox + : this.constants.URL.DEFAULT.production; + } + this.body = body; + this.params = [params]; + + if (!this.accessToken) { + this.getAccessToken().then(this.directReq.bind(this)); + } else { + this.withTokenReq.call(this); + } + + return this.defer.promise; + } + + private getAccessToken(): Promise { + const gnAuth = new GnAuth(this.options, this.constants); + return gnAuth + .getAccessToken() + .then((response) => { + this.accessToken = response.access_token; + return this.accessToken; + }) + .catch((err) => { + return err; + }); + } + + private getResponse(response: any, body: any) { + return this.options.rawResponse ? response : body; + } + + private req() { + const req: any = this.getParams.call(this, this.endpoint.route); + req.method = this.endpoint.method; + axios(req) + .then((res) => { + console.log(res.data); + }) + .catch((error) => { + console.log(error.response.data); + }); + } + + private directReq() { + this.directReqCallback.bind(this); + this.req(); + } + + private directReqCallback(err: any, httpResponse: { statusCode: number }, bodyResponse: any) { + const response = this.getResponse(httpResponse, bodyResponse); + + if (err) { + this.defer.reject(err); + } else if (httpResponse.statusCode !== 200) { + this.defer.reject(response); + } else { + this.defer.resolve(response); + } + } + + private withTokenReq() { + this.withTokenReqCallback.bind(this); + } + + private withTokenReqCallback( + err: any, + httpResponse: { statusCode: number }, + httpResponseBody: any + ) { + const response = this.getResponse(httpResponse, httpResponseBody); + + if (err) { + this.defer.reject(err); + } else if (httpResponse.statusCode === 401) { + this.getAccessToken().then(this.directReq.bind(this)); + } else if (httpResponse.statusCode !== 200) { + this.defer.reject(response); + } else { + this.defer.resolve(response); + } + } + + private getParams(route: any): Object { + // eslint-disable-next-line no-useless-escape + const regex = /\:(\w+)/g; + let query = ''; + const placeholders = route.match(regex) || []; + const params: any = {}; + + if (this.params) { + this.params.forEach((obj: any) => { + if (obj) { + Object.entries(obj).forEach((entrie: any) => { + params[entrie[0]] = entrie[1]; + }); + } + }); + } + + const getVariables = () => { + return placeholders.map((item: any) => { + return item.replace(':', ''); + }); + }; + + const updateRoute = () => { + const variables = getVariables(); + variables.forEach((value: any, index: any) => { + if (params[value]) { + // eslint-disable-next-line no-param-reassign + route = route.replace(placeholders[index], params[value]); + delete params[value]; + } + }); + }; + + const getQueryString = () => { + const keys = Object.keys(params); + const initial = keys.length >= 1 ? '?' : ''; + return keys.reduce((previous, current, index, array) => { + const next = index === array.length - 1 ? '' : '&'; + return [previous, current, '=', params[current], next].join(''); + }, initial); + }; + + updateRoute(); + query = getQueryString(); + + const headers: any = { + 'api-sdk': `typescript-${sdkPackage.version}`, + 'Content-Type': 'application/json', + authorization: `Bearer ${this.accessToken}`, + }; + if (this.options.validateMtls) { + headers['x-skip-mtls-checking'] = false; + } else { + headers['x-skip-mtls-checking'] = true; + } + + if (this.options.partnerToken) { + headers['partner-token'] = this.options.partnerToken; + } + + const req: any = { + url: [this.options.baseUrl, route, query].join(''), + headers, + data: this.body, + }; + + if ( + this.constants.URL.PIX.production === this.options.baseUrl || + this.constants.URL.PIX.sandbox === this.options.baseUrl + ) { + req.httpsAgent = this.agent; + } + + return req; + } +} +export default GnEndpoints; diff --git a/src/gn-sdk.ts b/src/gn-sdk.ts new file mode 100755 index 0000000..677a462 --- /dev/null +++ b/src/gn-sdk.ts @@ -0,0 +1,26 @@ +/* eslint-disable import/extensions */ +/* eslint-disable import/no-unresolved */ +import GnEndpoints from './gn-endpoints'; +import constants from './gn-constants'; +import { CredentialsInterface } from './interfaces/credentials.interface'; + +class GnSdk { + // eslint-disable-next-line no-undef + [index: string]: any; + + constructor(options: CredentialsInterface) { + this.options = options; + const methods: any = constants.ENDPOINTS; + + Object.keys(methods).forEach((api) => { + Object.keys(methods[api]).forEach((key) => { + this[key] = (params: any, body: any) => { + const endpoints = new GnEndpoints(options, constants); + return endpoints.run(key, params, body); + }; + }); + }); + } +} + +export default GnSdk; diff --git a/src/interfaces/config.interface.ts b/src/interfaces/config.interface.ts new file mode 100755 index 0000000..9f31cac --- /dev/null +++ b/src/interfaces/config.interface.ts @@ -0,0 +1,13 @@ +import { PathLike } from 'fs'; + +export interface ConfigInterface { + clientIdProducao: string; + clientSecretProducao: string; + clientIdHomologacao: string; + clientSecretHomologacao: string; + pathCertProducao: PathLike; + pathCertHomologacao: PathLike; + sandbox: boolean; + partnerToken?: string; + validateMtls?: boolean; +} diff --git a/src/interfaces/credentials.interface.ts b/src/interfaces/credentials.interface.ts new file mode 100755 index 0000000..399c0fe --- /dev/null +++ b/src/interfaces/credentials.interface.ts @@ -0,0 +1,12 @@ +import { PathLike } from 'fs'; + +export interface CredentialsInterface { + clientId: string; + clientSecret: string; + pathCert: PathLike; + sandbox: boolean; + partnerToken?: string; + rawResponse?: any; + baseUrl?: string; + validateMtls?: boolean; +} diff --git a/src/interfaces/endpoint.interface.ts b/src/interfaces/endpoint.interface.ts new file mode 100755 index 0000000..786c0a0 --- /dev/null +++ b/src/interfaces/endpoint.interface.ts @@ -0,0 +1,4 @@ +export interface EndpointInterface { + route: string; + method: string; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100755 index 0000000..099fa31 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,72 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "ES6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ + "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./dist", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + + /* Advanced Options */ + "skipLibCheck": true, /* Skip type checking of declaration files. */ + "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ + "resolveJsonModule": true + } +}