-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from starkbank/feature/logs
Add logs
- Loading branch information
Showing
7 changed files
with
79 additions
and
7 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
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
const merchantPurchase = require('./merchantPurchase.js') | ||
const merchantPurchase = require('./merchantPurchase.js') | ||
exports.log = require('./log'); | ||
exports.MerchantPurchase = merchantPurchase.MerchantPurchase; | ||
exports.query = merchantPurchase.query; | ||
exports.get = merchantPurchase.get; |
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,4 @@ | ||
const log = require('./log.js'); | ||
|
||
exports.get = log.get; | ||
exports.query = log.query; |
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,34 @@ | ||
const rest = require('../../utils/rest.js'); | ||
const check = require('starkcore').check; | ||
const Resource = require('../../utils/resource.js').Resource | ||
|
||
class Log extends Resource { | ||
|
||
/** | ||
* Check out our API Documentation at https://starkbank.com/docs/api#merchant-purchase | ||
*/ | ||
|
||
constructor({ created, type, errors, merchantPurchase, id }) { | ||
super(id); | ||
this.created = check.datetime(created); | ||
this.type = type; | ||
this.errors = errors; | ||
this.merchantPurchase = merchantPurchase; | ||
} | ||
} | ||
|
||
exports.Log = Log; | ||
let resource = {'class': exports.Log, 'name': 'MerchantPurchaseLog'}; | ||
|
||
exports.get = async function (id, {user} = {}) { | ||
return rest.getId(resource, id, user); | ||
}; | ||
|
||
exports.query = async function ({ limit, after, before, user} = {}) { | ||
let query = { | ||
limit: limit, | ||
after: after, | ||
before: before | ||
}; | ||
return rest.getList(resource, query, user); | ||
}; |
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
const merchantSession = require('./merchantSession.js'); | ||
exports.MerchantSession = merchantSession.MerchantSession; | ||
exports.create = merchantSession.create; | ||
exports.purchase = merchantSession.purchase; |
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,25 @@ | ||
const assert = require('assert'); | ||
const starkbank = require('../index.js'); | ||
|
||
starkbank.user = require('./utils/user').exampleProject; | ||
|
||
describe('MerchantSessionQueryLog', function(){ | ||
this.timeout(10000); | ||
it('test_success', async () => { | ||
let logs = await starkbank.merchantPurchase.log.query({limit: 3}); | ||
for await (let log of logs) { | ||
assert(typeof log.id == 'string'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('MerchantSessionGetLog', function(){ | ||
this.timeout(10000); | ||
it('test_success', async () => { | ||
let logs = await starkbank.merchantPurchase.log.query({limit: 1}); | ||
for await (let log of logs) { | ||
log = await starkbank.merchantPurchase.log.get(log.id); | ||
assert(typeof log.id == 'string'); | ||
} | ||
}); | ||
}); |