Skip to content

Commit 63705d9

Browse files
authored
Merge pull request #144 from starkbank/feature/add-pdf-deposit
Add pdf on reversed deposit log
2 parents 09f2213 + f2f4fd0 commit 63705d9

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Given a version number MAJOR.MINOR.PATCH, increment:
1313

1414

1515
## [Unreleased]
16+
### Added
17+
- PDF method for DepositLog resource
1618

1719
## [2.31.0] - 2025-03-27
1820
### Added

sdk/deposit/log/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const log = require('./log.js');
22

33
exports.get = log.get;
4+
exports.pdf = log.pdf;
45
exports.query = log.query;
56
exports.page = log.page;
6-
exports.Log = log.Log;
7+
exports.Log = log.Log;

sdk/deposit/log/log.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,24 @@ exports.page = async function ({ cursor, limit, after, before, types, depositIds
115115
};
116116
return rest.getPage(resource, query, user);
117117
};
118+
119+
exports.pdf = async function (id, {user} = {}) {
120+
/**
121+
*
122+
* Retrieve a specific reversal receipt pdf file
123+
*
124+
* @description Whenever a Deposit is successfully reversed, a reversed log will be created. To retrieve a specific reversal receipt, you can request the corresponding log PDF.
125+
*
126+
* Parameters (required):
127+
* @param id [string]: object unique id. ex: '5656565656565656'
128+
*
129+
* Parameters (optional):
130+
131+
* @param user [Project object]: Project object. Not necessary if starkbank.user was set before function call
132+
*
133+
* Return:
134+
* @returns Reversed deposit log pdf file
135+
*
136+
*/
137+
return rest.getContent(resource, id, user, null, 'pdf');
138+
};

tests/testDepositLog.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,28 @@ describe('TestDepositLogGetPage', function () {
4949
assert(ids.length == 10);
5050
});
5151
});
52+
53+
describe('TestDepositLogGet', function(){
54+
this.timeout(10000);
55+
it('test_success', async () => {
56+
let i = 0;
57+
const logs = await starkbank.deposit.log.query({limit: 150});
58+
for await (let log of logs) {
59+
assert(typeof log.id == 'string');
60+
i += 1;
61+
}
62+
assert(i === 150);
63+
});
64+
});
65+
66+
describe('TestDepositPdfGet', function(){
67+
this.timeout(10000);
68+
it('test_success', async () => {
69+
let deposits = await starkbank.deposit.log.query({limit: 1, types: 'reversed'});
70+
for await (let deposit of deposits) {
71+
let pdf = await starkbank.deposit.log.pdf(deposit.id);
72+
const pdfSignature = pdf.toString('utf8', 0, 5);
73+
assert(pdfSignature === '%PDF-');
74+
}
75+
});
76+
});

0 commit comments

Comments
 (0)