Skip to content

Commit 8aada8c

Browse files
Updated the optional properties in Pricing preview (#21)
1 parent e0943ff commit 8aada8c

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ 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.2.2 - 2024-04-03
16+
17+
### Fixed
18+
19+
- Updated the optional properties returned by `pricingPreview.preview` operation to match the API response.
20+
21+
---
22+
1523
## 1.2.1 - 2024-03-20
1624

1725
### 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.2.1",
3+
"version": "1.2.2",
44
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/__tests__/mocks/resources/pricing-preview.mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const PricingPreviewRequest: PricingPreviewRequestBody = {
1818
],
1919
};
2020
export const PricingPreviewMock: IPricingPreviewResponse = {
21-
available_payment_method: 'apple_pay',
21+
available_payment_methods: ['apple_pay'],
2222
currency_code: 'USD',
2323
address: {
2424
country_code: 'US',

src/entities/pricing-preview/pricing-preview.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ export class PricingPreview {
1313
public readonly customerId: string | null;
1414
public readonly addressId: string | null;
1515
public readonly businessId: string | null;
16-
public readonly currencyCode: CurrencyCode | null;
16+
public readonly currencyCode: CurrencyCode;
1717
public readonly discountId: string | null;
1818
public readonly address: AddressPreview | null;
1919
public readonly customerIpAddress: string | null;
20-
public readonly details: PricingPreviewDetails | null;
21-
public readonly availablePaymentMethods: AvailablePaymentMethod | null;
20+
public readonly details: PricingPreviewDetails;
21+
public readonly availablePaymentMethods: AvailablePaymentMethod[];
2222

2323
constructor(pricePreview: IPricingPreviewResponse) {
2424
this.customerId = pricePreview.customer_id ?? null;
2525
this.addressId = pricePreview.address_id ?? null;
2626
this.businessId = pricePreview.business_id ?? null;
27-
this.currencyCode = pricePreview.currency_code ?? null;
27+
this.currencyCode = pricePreview.currency_code;
2828
this.discountId = pricePreview.discount_id ?? null;
2929
this.address = pricePreview.address ? new AddressPreview(pricePreview.address) : null;
3030
this.customerIpAddress = pricePreview.customer_ip_address ?? null;
31-
this.details = pricePreview.details ? new PricingPreviewDetails(pricePreview.details) : null;
32-
this.availablePaymentMethods = pricePreview.available_payment_method ?? null;
31+
this.details = new PricingPreviewDetails(pricePreview.details);
32+
this.availablePaymentMethods = pricePreview.available_payment_methods ?? [];
3333
}
3434
}

src/types/pricing-preview/pricing-preview-response.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export interface IPricingPreviewResponse {
1313
customer_id?: string | null;
1414
address_id?: string | null;
1515
business_id?: string | null;
16-
currency_code?: CurrencyCode | null;
16+
currency_code: CurrencyCode;
1717
discount_id?: string | null;
1818
address?: IAddressPreviewResponse | null;
1919
customer_ip_address?: string | null;
2020
items: IPricingPreviewItemResponse[];
21-
details?: IPricingPreviewDetailsResponse | null;
22-
available_payment_method?: AvailablePaymentMethod | null;
21+
details: IPricingPreviewDetailsResponse;
22+
available_payment_methods: AvailablePaymentMethod[];
2323
}

0 commit comments

Comments
 (0)