Skip to content

Commit

Permalink
Merge pull request wirecardBrasil#38 from wirecardBrasil/accounts/exi…
Browse files Browse the repository at this point in the history
…stence

Accounts/existence
  • Loading branch information
somentelucas committed Nov 14, 2018
2 parents fcffac5 + f87f053 commit 94074d5
Show file tree
Hide file tree
Showing 10 changed files with 1,237 additions and 1,014 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
service_name: travis-ci
repo_token: FjbzZ0XyhSQhc3lz86TFNySFOvj6gMMbl
repo_token: VJ5XxInvFgsQ8yETY5oU1mfR9vZLx3FIG
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"eqeqeq": "warn",
"no-throw-literal": "off",
"handle-callback-err": "warn",
"no-undef": "warn"
"no-undef": "warn",
"semi": "off"
},
"env": {
"mocha": true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ node_modules/
moip-sdk-node.iml
.DS_Store
.nyc_output
yarn-error.log

moip.js
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
- [Account](#account)
- [Create](#create-3)
- [Get](#get-3)
- [Check Existence](#check-existence)
- [Bank Account](#bank-account)
- [Create](#create-4)
- [Get](#get-4)
Expand Down Expand Up @@ -849,6 +850,19 @@ moip.account.getOne(accountId)
})
```

#### Check Existence
Verify if an account already exists through the `e-mail` or `tax document`
```javascript
moip.account.exists({
email: 'integracao@labs.moip.com.br'
// tax_document: 880.956.367-03
}).then(() => {
console.log('If here, the account exists')
}).catch(() => {
console.log('If here, the account does not exist')
})
```

## Bank Account
#### Create
```javascript
Expand Down
9 changes: 8 additions & 1 deletion dist/resources/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ var _api = require('../client/api');

var _api2 = _interopRequireDefault(_api);

var _utils = require('../utils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var create = function create(opts, account) {
Expand All @@ -18,7 +20,12 @@ var getOne = function getOne(opts, _id) {
return _api2.default.get(opts, '/accounts', _id);
};

var exists = function exists(opts, _query) {
return _api2.default.get(opts, '/accounts/exists', null, null, (0, _utils.getQuerystring)(_query));
};

exports.default = {
create: create,
getOne: getOne
getOne: getOne,
exists: exists
};
6 changes: 5 additions & 1 deletion lib/resources/account.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import api from '../client/api'
import {getQuerystring} from '../utils'

const create = (opts, account) => api.post(opts, '/accounts', account)

const getOne = (opts, _id) => api.get(opts, '/accounts', _id)

const exists = (opts, _query) => api.get(opts, '/accounts/exists', null, null, getQuerystring(_query))

export default {
create,
getOne
getOne,
exists
}
Loading

0 comments on commit 94074d5

Please sign in to comment.