Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
acidtangodev committed May 31, 2021
0 parents commit 819be2c
Show file tree
Hide file tree
Showing 63 changed files with 8,132 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint/eslint-plugin",
"prettier"
],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended"
],
"root": true,
"env": {
"node": true,
"jest": true
},
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
22 changes: 22 additions & 0 deletions .github/workflows/gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: gitleaks

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
gitleaks:
name: gitleaks
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: gitleaks-action
uses: zricethezav/[email protected]
36 changes: 36 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches:
- main

jobs:
tests:
name: Test
runs-on: ubuntu-latest
container: node:lts
timeout-minutes: 5
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/[email protected]
with:
node-version: 14
registry-url: https://registry.npmjs.org
scope: '@acid-tango'
- uses: actions/[email protected]
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Lint
run: yarn lint
- name: Tests
run: yarn test
env:
ARCUS_API_KEY: ${{secrets.ARCUS_API_KEY}}
ARCUS_SECRET_KEY: ${{secrets.ARCUS_SECRET_KEY}}
36 changes: 36 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on: pull_request

jobs:
tests:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["12", "14", "16"]
container: node:lts
timeout-minutes: 5
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org
scope: '@acid-tango'
- uses: actions/[email protected]
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Lint
run: yarn lint
- name: Tests
run: yarn test
env:
ARCUS_API_KEY: ${{secrets.ARCUS_API_KEY}}
ARCUS_SECRET_KEY: ${{secrets.ARCUS_SECRET_KEY}}
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
release:
types: [created]

jobs:
tests:
name: Test
runs-on: ubuntu-latest
container: node:lts
timeout-minutes: 5
steps:
- name: Check out repository code
uses: actions/checkout@v2
- uses: actions/[email protected]
with:
node-version: 14
registry-url: https://registry.npmjs.org
scope: '@acid-tango'
- uses: actions/[email protected]
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Lint
run: yarn lint
- name: Tests
run: yarn test
env:
ARCUS_API_KEY: ${{secrets.ARCUS_API_KEY}}
ARCUS_SECRET_KEY: ${{secrets.ARCUS_SECRET_KEY}}
- name: Publish
run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPMJS_TOKEN}}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.idea
lib
.vscode
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit "$1"
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/migrations/*.ts
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100
}
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2021 AcidTango

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 (including the next paragraph) 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.
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# arcus-js

[![NPM version](https://img.shields.io/npm/v/@acid-tango/arcus-js.svg)](https://www.npmjs.com/package/@acid-tango/arcus-js)
[![CI](https://github.com/acidtango/arcus-js/actions/workflows/main.yaml/badge.svg)](https://github.com/acidtango/arcus-js/actions/workflows/main.yaml)

Arcus TypeScript client library for [Arcus API v3.x](https://docs.arcusfi.com/api/3.mx/endpoints/)

## Installation

```bash
npm install --save @acid-tango/arcus-js
# or
yarn add @acid-tango/arcus-js
```

## Usage

- [Authentication](#authentication)
- [Account](#account)
- [Billers](#billers)
- [Payment](#payment)
- [Transactions](#transactions)

### Authentication

```typescript
import { Arcus } from '@acid-tango/arcus-js';

const arcusClient = Arcus.create(
process.env.ARCUS_API_KEY as string,
process.env.ARCUS_SECRET_KEY as string,
);
```

### Get account info

Returns all the info about your account.

```typescript
const account = await arcusClient.getAccount()
```

### Billers methods

Return all billers:

```typescript
const allBillers = await arcusClient.getBillers()
```

Return billers by type:

```typescript
const utilities = await arcusClient.getBillersUtilities()
const topUps = await arcusClient.getBillersTopUps()
const giftCards = await arcusClient.getBillersGiftCards()
```

### Payment

```typescript
// Creates a single payment and returns the created transaction
const singlePayParams: ArcusSinglePayParams = {...}

const transaction = await arcusClient.singlePay(singlePayParams)
```

### Transactions

Get a transaction by id:

```typescript
const transaction = await arcusClient.getTransaction(transactionId)
```

Cancel a transaction by id:

```typescript
await arcusClient.cancelTransaction(transactionId)
```

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'feat: Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## 📲 Contact

The project was mainly developed by [Abel García](mailto:[email protected]), [Aarón Pérez](mailto:[email protected]), [Daniel Ramos](mailto:[email protected]) and [Daniel Gak](mailto:[email protected]) from [Acid Tango](https://acidtango.com/) with ❤️ and 💪 for [Rabbit](https://www.rabbitmx.com/).

## License

[MIT](LICENSE)
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
28 changes: 28 additions & 0 deletions examples/pay-netflix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Arcus } from '../src/Arcus';

const main = async () => {
const arcus = Arcus.create(
process.env.ARCUS_API_KEY as string,
process.env.ARCUS_SECRET_KEY as string,
);

const giftCards = await arcus.getBillersGiftCards();

const netflix = giftCards.find((giftCard) => giftCard.id === 13723); // CÓDIGO NETFLIX $300

if (!netflix) throw new Error("Couldn't find netflix");

await arcus.singlePay({
billerId: netflix.id,
accountNumber: '321654871238120',
amount: 130,
currency: 'MXN',
externalId: '84bce950-c878-483e-aeca-41217f969301',
});

const transactions = await arcus.getTransactions();

console.log(transactions);
};

main().catch((err) => console.error(err));
Loading

0 comments on commit 819be2c

Please sign in to comment.