-
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 #131 from starkbank/fix/merchant-purchase-log
Fix merchantPurchase log
- Loading branch information
Showing
14 changed files
with
252 additions
and
12 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
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ const log = require('./log.js'); | |
|
||
exports.get = log.get; | ||
exports.query = log.query; | ||
exports.page = log.page; |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
const merchantSession = require('./merchantSession.js'); | ||
exports.log = require('./log'); | ||
exports.MerchantSession = merchantSession.MerchantSession; | ||
exports.create = merchantSession.create; | ||
exports.purchase = merchantSession.purchase; | ||
exports.purchase = merchantSession.purchase; | ||
exports.query = merchantSession.query; | ||
exports.get = merchantSession.get; | ||
exports.page = merchantSession.page; |
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,5 @@ | ||
const log = require('./log.js'); | ||
|
||
exports.get = log.get; | ||
exports.query = log.query; | ||
exports.page = log.page; |
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,46 @@ | ||
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-session | ||
*/ | ||
|
||
constructor({ created, type, errors, session, id }) { | ||
super(id); | ||
this.created = check.datetime(created); | ||
this.type = type; | ||
this.errors = errors; | ||
this.session = session; | ||
} | ||
} | ||
|
||
exports.Log = Log; | ||
let resource = {'class': exports.Log, 'name': 'MerchantSessionLog'}; | ||
|
||
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); | ||
}; | ||
|
||
exports.page = async function ({ cursor, limit, after, before, types, sessionIds, user } = {}) { | ||
let query = { | ||
cursor: cursor, | ||
limit: limit, | ||
after: after, | ||
before: before, | ||
types: types, | ||
sessionIds: sessionIds, | ||
}; | ||
return rest.getPage(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
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
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,45 @@ | ||
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 merchantSessionLogs = await starkbank.merchantSession.log.query({limit: 3}); | ||
for await (let log of merchantSessionLogs) { | ||
assert(typeof log.id == 'string'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('MerchantSessionGetLog', function(){ | ||
this.timeout(10000); | ||
it('test_success', async () => { | ||
let merchantSessionLogs = await starkbank.merchantSession.log.query({limit: 3}); | ||
for await (let log of merchantSessionLogs) { | ||
log = await starkbank.merchantSession.log.get(log.id); | ||
assert(typeof log.id == 'string'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('MerchantSessionPageLog', function () { | ||
this.timeout(10000); | ||
it('test_success', async () => { | ||
let ids = []; | ||
let cursor = null; | ||
let page = null; | ||
for (let i = 0; i < 2; i++) { | ||
[page, cursor] = await starkbank.merchantSession.log.page({ limit: 5, cursor: cursor }); | ||
for (let entity of page) { | ||
assert(!ids.includes(entity.id)); | ||
ids.push(entity.id); | ||
} | ||
if (cursor == null) { | ||
break; | ||
} | ||
} | ||
assert(ids.length == 10); | ||
}); | ||
}); |