-
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 #129 from starkbank/feature/merchant-session-reque…
…st-methods Add get and query methods
- Loading branch information
Showing
7 changed files
with
95 additions
and
3 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
const merchantPurchase = require('./merchantPurchase.js') |
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,66 @@ | ||
const Resource = require('starkcore').Resource; | ||
const rest = require('../utils/rest.js'); | ||
const check = require('starkcore').check; | ||
|
||
class MerchantPurchase extends Resource { | ||
|
||
/** | ||
* Check out our API Documentation at https://starkbank.com/docs/api#merchant-purchase | ||
*/ | ||
|
||
constructor({id, amount, installmentCount, cardExpiration, cardNumber, cardSecurityCode, | ||
holderName, holderEmail, holderPhone, fundingType, billingCountryCode, billingCity, billingStateCode, | ||
billingStreetLine1, billingStreetLine2, billingZipCode, metadata, cardEnding, cardId, challengeMode, | ||
challengeUrl, created, currencyCode, endToEndId, fee, network, source, status, tags, updated | ||
}){ | ||
super(id) | ||
this.amount = amount | ||
this.installmentCount = installmentCount | ||
this.cardExpiration = cardExpiration | ||
this.cardNumber = cardNumber | ||
this.cardSecurityCode = cardSecurityCode | ||
this.holderName = holderName | ||
this.holderEmail = holderEmail | ||
this.holderPhone = holderPhone | ||
this.fundingType = fundingType | ||
this.billingCountryCode = billingCountryCode | ||
this.billingCity = billingCity | ||
this.billingStateCode = billingStateCode | ||
this.billingStreetLine1 = billingStreetLine1 | ||
this.billingStreetLine2 = billingStreetLine2 | ||
this.billingZipCode = billingZipCode | ||
this.metadata = metadata | ||
this.cardEnding = cardEnding | ||
this.cardId = cardId | ||
this.challengeMode = challengeMode | ||
this.challengeUrl = challengeUrl | ||
this.created = created | ||
this.currencyCode = currencyCode | ||
this.endToEndId = endToEndId | ||
this.fee = fee | ||
this.network = network | ||
this.source = source | ||
this.status = status | ||
this.tags = tags | ||
this.updated = updated | ||
} | ||
} | ||
|
||
exports.MerchantPurchase = MerchantPurchase; | ||
let resource = {'class': exports.MerchantPurchase, 'name': 'MerchantPurchase'}; | ||
|
||
exports.query = async function ({ limit, after, before, status, tags, ids, user} = {}) { | ||
let query = { | ||
limit: limit, | ||
after: check.date(after), | ||
before: check.date(before), | ||
status: status, | ||
tags: tags, | ||
ids: ids, | ||
}; | ||
return rest.getList(resource, query, user); | ||
}; | ||
|
||
exports.get = async function (id, {user} = {}) { | ||
return rest.getId(resource, id, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const assert = require('assert'); | ||
const starkbank = require('../index.js'); | ||
|
||
starkbank.user = require('./utils/user').exampleProject; | ||
|
||
describe('MerchantSessionQuery', function(){ | ||
this.timeout(10000); | ||
it('test_success', async () => { | ||
let merchantPurchases = await starkbank.merchantPurchase.query({limit: 3}); | ||
for await (let merchantPurchase of merchantPurchases) { | ||
assert(typeof merchantPurchase.id == 'string'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('MerchantSessionGet', function(){ | ||
this.timeout(10000); | ||
it('test_success', async () => { | ||
let merchantPurchase = await starkbank.merchantPurchase.get(5019538395496448); | ||
assert(typeof merchantPurchase.id == 'string'); | ||
}); | ||
}); |
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