Skip to content

Commit

Permalink
Updated the optional properties in Pricing preview (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayasingam-paddle authored Apr 3, 2024
1 parent e0943ff commit 8aada8c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a

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.

## 1.2.2 - 2024-04-03

### Fixed

- Updated the optional properties returned by `pricingPreview.preview` operation to match the API response.

---

## 1.2.1 - 2024-03-20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paddle/paddle-node-sdk",
"version": "1.2.1",
"version": "1.2.2",
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/mocks/resources/pricing-preview.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const PricingPreviewRequest: PricingPreviewRequestBody = {
],
};
export const PricingPreviewMock: IPricingPreviewResponse = {
available_payment_method: 'apple_pay',
available_payment_methods: ['apple_pay'],
currency_code: 'USD',
address: {
country_code: 'US',
Expand Down
12 changes: 6 additions & 6 deletions src/entities/pricing-preview/pricing-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ export class PricingPreview {
public readonly customerId: string | null;
public readonly addressId: string | null;
public readonly businessId: string | null;
public readonly currencyCode: CurrencyCode | null;
public readonly currencyCode: CurrencyCode;
public readonly discountId: string | null;
public readonly address: AddressPreview | null;
public readonly customerIpAddress: string | null;
public readonly details: PricingPreviewDetails | null;
public readonly availablePaymentMethods: AvailablePaymentMethod | null;
public readonly details: PricingPreviewDetails;
public readonly availablePaymentMethods: AvailablePaymentMethod[];

constructor(pricePreview: IPricingPreviewResponse) {
this.customerId = pricePreview.customer_id ?? null;
this.addressId = pricePreview.address_id ?? null;
this.businessId = pricePreview.business_id ?? null;
this.currencyCode = pricePreview.currency_code ?? null;
this.currencyCode = pricePreview.currency_code;
this.discountId = pricePreview.discount_id ?? null;
this.address = pricePreview.address ? new AddressPreview(pricePreview.address) : null;
this.customerIpAddress = pricePreview.customer_ip_address ?? null;
this.details = pricePreview.details ? new PricingPreviewDetails(pricePreview.details) : null;
this.availablePaymentMethods = pricePreview.available_payment_method ?? null;
this.details = new PricingPreviewDetails(pricePreview.details);
this.availablePaymentMethods = pricePreview.available_payment_methods ?? [];
}
}
6 changes: 3 additions & 3 deletions src/types/pricing-preview/pricing-preview-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export interface IPricingPreviewResponse {
customer_id?: string | null;
address_id?: string | null;
business_id?: string | null;
currency_code?: CurrencyCode | null;
currency_code: CurrencyCode;
discount_id?: string | null;
address?: IAddressPreviewResponse | null;
customer_ip_address?: string | null;
items: IPricingPreviewItemResponse[];
details?: IPricingPreviewDetailsResponse | null;
available_payment_method?: AvailablePaymentMethod | null;
details: IPricingPreviewDetailsResponse;
available_payment_methods: AvailablePaymentMethod[];
}

0 comments on commit 8aada8c

Please sign in to comment.