This repository has been archived by the owner on Jul 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,235 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [1.1.0] - 2016-06-18 | ||
|
||
### Added | ||
|
||
+ Get one card | ||
+ Cards are now instance of `Card` | ||
+ Add Set / get limits on card | ||
+ Add Block / unblock on card | ||
+ Better CLI for unmocked tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ Not all endpoints are available yet. | |
+ [x] Get Transactions (with search) | ||
+ [x] Add / update memo on transactions | ||
+ [x] Create a transfert | ||
+ [ ] unpair | ||
+ [x] unpair | ||
+ [ ] pair | ||
+ [ ] certify transfer | ||
|
||
|
@@ -103,7 +103,4 @@ Run `npm test` for full mocked testing with coverage. | |
|
||
Less asserts. Used for detect api change. | ||
|
||
Run `[email protected] TEST_PASSWORD=ilovemylittlepony TRANSFER_IBAN=FR7630001007941234567890185 TRANSFER_BIC=BNPAFRPP TRANSFER_NAME="George Loutre" TRANSFER_PIN=123456 npm run test-unmock` for un-mocked test. | ||
|
||
The transfer test (*0.01 €) can be switch off with env `NO_TRANSFER`. | ||
Otherwise, *it should be confirmed* in the app. | ||
Run `npm run test-unmock` for un-mocked test. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict'; | ||
|
||
const Promise = require('bluebird'); | ||
|
||
const utils = require('./utils'); | ||
|
||
/** | ||
* @typedef cardLimit | ||
* | ||
* @property {String} limit Limit type | ||
* @property {Number} [amount] Amount | ||
* @property {String[]} [countryList] Array of country code | ||
*/ | ||
|
||
/** | ||
* Card instance | ||
* linked to an account. An account should contains many card. | ||
*/ | ||
class Card { | ||
constructor(account, card) { | ||
this.account = account; | ||
this.id = card.id; | ||
this.cardType = card.cardType; | ||
this.n26Status = card.n26Status; | ||
this.maskedPan = card.maskedPan; | ||
this.expirationDate = card.expirationDate; | ||
this.pinDefined = card.pinDefined; | ||
this.cardActivated = card.cardActivated; | ||
this.usernameOnCard = card.usernameOnCard; | ||
} | ||
|
||
/** | ||
* Get / set card limit | ||
* | ||
* @param {Object} [limit] | ||
* @param {String} limit.limit Limit type | ||
* @param {Number} [limit.amount] Amount | ||
* @param {String[]} [limit.countryList] Array of country code | ||
* | ||
* @return {Promise<cardLimit[]>} | ||
*/ | ||
limits(limit) { | ||
return Promise.try(() => { | ||
if (limit) { | ||
if (!limit.limit || | ||
(limit.limit === 'COUNTRY_LIST' && !limit.countryList) || | ||
(limit.limit !== 'COUNTRY_LIST' && limit.amount === undefined)) { | ||
throw new Error('BAD_PARAMS'); | ||
} | ||
|
||
return utils.callApi(this.account, 'setCardLimits', {cardId: this.id, limit}); | ||
} | ||
|
||
return utils.callApi(this.account, 'getCardLimits', this.id); | ||
}); | ||
} | ||
|
||
/** | ||
* Block card | ||
* | ||
* @return {Promise} | ||
*/ | ||
block() { | ||
return utils.callApi(this.account, 'blockCard', this.id) | ||
.tap(() => { this.n26Status = 'BLOCKED'; }); | ||
} | ||
|
||
/** | ||
* Unblock card | ||
* | ||
* @return {Promise} | ||
*/ | ||
unblock() { | ||
return utils.callApi(this.account, 'unblockCard', this.id) | ||
.tap(() => { this.n26Status = 'ACTIVE'; }); | ||
} | ||
} | ||
|
||
module.exports = Card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,13 +32,13 @@ describe('auth', () => { | |
password: 'password', | ||
grant_type: 'password' | ||
}) | ||
.reply(200, data); | ||
.reply(200, data.account); | ||
|
||
api = nock('https://api.tech26.de') | ||
.defaultReplyHeaders({ | ||
'Content-Type': 'application/json' | ||
}) | ||
.matchHeader('Authorization', `Bearer ${data.access_token}`) | ||
.matchHeader('Authorization', `Bearer ${data.account.access_token}`) | ||
.get('/api/me') | ||
.reply(200, { | ||
email: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.