Skip to content

Commit c7688e4

Browse files
feat(API Sync): Added Get Credit note and Subscription update with non catalog price (#43)
1 parent 7b77e4e commit c7688e4

26 files changed

+208
-16
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a
1212

1313
This means when upgrading minor versions of the SDK, you may notice type errors. You can safely ignore these or fix by adding additional type guards.
1414

15+
## 1.6.0 - 2024-09-16
16+
17+
### Added
18+
19+
- Added `adjustments.getCreditNotePDF()` to [get a credit note for an adjustment](https://developer.paddle.com/api-reference/adjustments/get-credit-note-pdf?utm_source=dx&utm_medium=paddle-node-sdk)
20+
- Added `disposition` query parameter to `adjustments.getCreditNotePDF()` and `transactions.getInvoicePDF()` operations, see [related changelog](https://developer.paddle.com/changelog/2024/invoice-pdf-open-in-browser?utm_source=dx&utm_medium=paddle-node-sdk).
21+
- Added pagination support to `notificationSettings.list()` operation, see [related changelog](https://developer.paddle.com/changelog/2024/notification-settings-pagination?utm_source=dx&utm_medium=paddle-node-sdk).
22+
- Added support for Non-catalog products and prices to the `subscriptions.update()` and `subscriptions.previewUpdate()` operations, see [related changelog](https://developer.paddle.com/changelog/2024/add-custom-items-subscription?utm_source=dx&utm_medium=paddle-node-sdk).
23+
24+
### Fixed
25+
26+
- Marked `notification_id` as optional in `IEventsResponse` interface.
27+
- Fixed a bug where query parameters with false values were not passed correctly to the API.
28+
29+
---
30+
1531
## 1.5.1 - 2024-09-10
1632

1733
### Fixed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paddle/paddle-node-sdk",
3-
"version": "1.5.1",
3+
"version": "1.6.0",
44
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/esm/index.js",

src/__tests__/resources/adjustments.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { AdjustmentsResource, ListAdjustmentQueryParameters } from '../../resources';
88
import { getPaddleTestClient } from '../helpers/test-client';
99
import {
10+
AdjustmentMock,
1011
AdjustmentMockResponse,
1112
CreateAdjustmentExpectation,
1213
CreateAdjustmentMock,
@@ -61,4 +62,17 @@ describe('AdjustmentsResource', () => {
6162

6263
expect(convertToSnakeCase(CreateAdjustmentMock)).toEqual(CreateAdjustmentExpectation);
6364
});
65+
66+
test('should get an link to download credit note PDF for an adjustment', async () => {
67+
const adjustmentId = AdjustmentMock.id;
68+
69+
const paddleInstance = getPaddleTestClient();
70+
paddleInstance.get = jest.fn().mockResolvedValue(AdjustmentMockResponse);
71+
72+
const adjustmentResponse = new AdjustmentsResource(paddleInstance);
73+
const creditNotePDF = await adjustmentResponse.getCreditNotePDF(adjustmentId);
74+
75+
expect(paddleInstance.get).toBeCalledWith(`/adjustments/${adjustmentId}/credit-note?`);
76+
expect(creditNotePDF).toBeDefined();
77+
});
6478
});

src/__tests__/resources/notification-settings.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('NotificationSettingsResource', () => {
2525
const notificationsResource = new NotificationSettingsResource(paddleInstance);
2626
const notifications = await notificationsResource.list();
2727

28-
expect(paddleInstance.get).toBeCalledWith('/notification-settings');
28+
expect(paddleInstance.get).toBeCalledWith('/notification-settings?');
2929
expect(notifications.length).toBe(1);
3030
});
3131

src/__tests__/resources/subscriptions.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ describe('SubscriptionsResource', () => {
106106
expect(convertToSnakeCase(UpdateSubscriptionMock)).toEqual(UpdateSubscriptionExpectation);
107107
});
108108

109+
test('should update an existing subscription with non-catalog price', async () => {
110+
const subscriptionId = SubscriptionMock.id;
111+
const subscriptionToBeUpdated: UpdateSubscriptionRequestBody = UpdateSubscriptionMock;
112+
113+
const paddleInstance = getPaddleTestClient();
114+
paddleInstance.patch = jest.fn().mockResolvedValue(SubscriptionMockResponse);
115+
116+
const subscriptionsResource = new SubscriptionsResource(paddleInstance);
117+
const updatedSubscription = await subscriptionsResource.update(subscriptionId, subscriptionToBeUpdated);
118+
119+
expect(paddleInstance.patch).toBeCalledWith(`/subscriptions/${subscriptionId}`, subscriptionToBeUpdated);
120+
expect(updatedSubscription).toBeDefined();
121+
expect(convertToSnakeCase(UpdateSubscriptionMock)).toEqual(UpdateSubscriptionExpectation);
122+
});
123+
109124
test('should preview update an existing subscription', async () => {
110125
const subscriptionId = SubscriptionMock.id;
111126
const subscriptionToBeUpdated: UpdateSubscriptionRequestBody = UpdateSubscriptionMock;

src/__tests__/resources/transactions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('TransactionsResource', () => {
130130
const transactionsResource = new TransactionsResource(paddleInstance);
131131
const updatedTransaction = await transactionsResource.getInvoicePDF(transactionId);
132132

133-
expect(paddleInstance.get).toBeCalledWith(`/transactions/${transactionId}/invoice`);
133+
expect(paddleInstance.get).toBeCalledWith(`/transactions/${transactionId}/invoice?`);
134134
expect(updatedTransaction).toBeDefined();
135135
});
136136

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
import { type IAdjustmentCreditNotePDF } from '../../types';
8+
9+
export class AdjustmentCreditNotePDF {
10+
public readonly url: string;
11+
12+
constructor(adjustment: IAdjustmentCreditNotePDF) {
13+
this.url = adjustment.url;
14+
}
15+
}

src/entities/adjustment/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export * from './adjustment-item';
1010
export * from './adjustment';
1111
export * from './adjustment-collection';
1212
export * from './adjustment-item-totals';
13+
export * from './adjustment-credit-note-pdf';

src/enums/shared/disposition.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* ! Autogenerated code !
3+
* Do not make changes to this file.
4+
* Changes may be overwritten as part of auto-generation.
5+
*/
6+
7+
export type Disposition = 'attachment' | 'inline';

src/enums/shared/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ export * from './error-code';
1919
export * from './payment-type';
2020
export * from './catalog-type';
2121
export * from './available-payment-methods';
22+
export * from './disposition';

0 commit comments

Comments
 (0)