Skip to content

Commit

Permalink
Added createdAt and updatedAt to product and price entities (#15)
Browse files Browse the repository at this point in the history
* Added `createdAt` and `updatedAt` to product and price entities

* Updated report API to support discount and product_prices
  • Loading branch information
vijayasingam-paddle authored Mar 13, 2024
1 parent 2fb1bb5 commit 42cd44f
Show file tree
Hide file tree
Showing 39 changed files with 213 additions and 97 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-node-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.

### Versioning

When we make [non-breaking changes](https://developer.paddle.com/api-reference/about/versioning?utm_source=dx&utm_medium=paddle-node-sdk#non-breaking-change) to the Paddle API, we'll only release a new major version of the Node.js SDK when it causes problems at runtime. We won't release a new version of the SDK when we weaken TypeScript types in a way that doesn't cause existing implementations to break or malfunction. For example, if we add a new field to a request or an allowed value for a field in a response, this weakens the Typescript type but does not cause existing usages to stop working.

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.1.0 - 2024-03-13

### Added

- Added `createdAt` and `updatedAt` to product and price entities, see [related changelog](https://developer.paddle.com/changelog/2024/product-price-dates?utm_source=dx&utm_medium=paddle-node-sdk).

### Changed

- Updated [report API](https://developer.paddle.com/api-reference/reports/create-report?utm_source=dx&utm_medium=paddle-node-sdk) to support `discounts` and `product_prices` report, see [related changelog](https://developer.paddle.com/changelog/2024/product-prices-discounts-reports?utm_source=dx&utm_medium=paddle-node-sdk).

### Removed

- Removed `ISharedProductResponse` and `ISharedPriceResponse` interfaces as they were redundant. Please use `IProductResponse` and `IPriceResponse` instead.

---

## 1.0.2 - 2024-03-12

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ Keep in mind that API keys are separate for your sandbox and live accounts, so y

This SDK comes with TypeScript definitions for the Paddle API. We recommend that you update frequently to keep the TypeScript definitions up-to-date with the API. Use `// @ts-ignore` to prevent any type error if you don't want to update.

### Versioning

When we make [non-breaking changes](https://developer.paddle.com/api-reference/about/versioning?utm_source=dx&utm_medium=paddle-node-sdk#non-breaking-change) to the Paddle API, we'll only release a new major version of the Node.js SDK when it causes problems at runtime. We won't release a new version of the SDK when we weaken TypeScript types in a way that doesn't cause existing implementations to break or malfunction. For example, if we add a new field to a request or an allowed value for a field in a response, this weakens the Typescript type but does not cause existing usages to stop working.

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.

## Naming conventions

Properties in the Paddle API use `snake_case`. To follow JavaScript conventions, properties in this SDK use `camelCase`. This means:
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.0.2",
"version": "1.1.0",
"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
7 changes: 5 additions & 2 deletions src/__tests__/mocks/notifications/price-created.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IPriceResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { IPriceNotificationResponse } from '../../../notifications';

export const PriceCreatedMock: IEventsResponse<IPriceResponse> = {
export const PriceCreatedMock: IEventsResponse<IPriceNotificationResponse> = {
event_id: 'evt_01h7zd9n8vch227m3dgwqcvf6t',
event_type: 'price.created',
occurred_at: '2023-08-16T14:51:48.380054Z',
Expand Down Expand Up @@ -46,6 +47,8 @@ export const PriceCreatedMockExpectation = {
minimum: 1,
},
status: 'active',
createdAt: null,
updatedAt: null,
taxMode: 'account_setting',
trialPeriod: {
frequency: 3,
Expand Down
7 changes: 5 additions & 2 deletions src/__tests__/mocks/notifications/price-imported.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IPriceResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { IPriceNotificationResponse } from '../../../notifications';

export const PriceImportedMock: IEventsResponse<IPriceResponse> = {
export const PriceImportedMock: IEventsResponse<IPriceNotificationResponse> = {
event_id: 'evt_01hgarz844zdfws6djn9rz6qm7',
event_type: 'price.imported',
occurred_at: '2023-11-28T10:53:03.492854Z',
Expand Down Expand Up @@ -49,6 +50,8 @@ export const PriceImportedMockExpectation = {
minimum: 1,
},
status: 'active',
createdAt: null,
updatedAt: null,
taxMode: 'account_setting',
trialPeriod: null,
type: 'standard',
Expand Down
7 changes: 5 additions & 2 deletions src/__tests__/mocks/notifications/price-updated.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IPriceResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { IPriceNotificationResponse } from '../../../notifications';

export const PriceUpdatedMock: IEventsResponse<IPriceResponse> = {
export const PriceUpdatedMock: IEventsResponse<IPriceNotificationResponse> = {
event_id: 'evt_01h83wg1aqxmf897qqb47tre5s',
event_type: 'price.updated',
occurred_at: '2023-08-18T08:34:23.703674Z',
Expand Down Expand Up @@ -46,6 +47,8 @@ export const PriceUpdatedMockExpectation = {
minimum: 1,
},
status: 'active',
createdAt: null,
updatedAt: null,
taxMode: 'account_setting',
trialPeriod: {
frequency: 30,
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/mocks/notifications/product-created.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IProductResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { IProductNotificationResponse } from '../../../notifications';

export const ProductCreatedMock: IEventsResponse<IProductResponse> = {
export const ProductCreatedMock: IEventsResponse<IProductNotificationResponse> = {
event_id: 'evt_01h7zcgmnv3ee9cqrj9fpww3mg',
event_type: 'product.created',
occurred_at: '2023-08-16T14:38:08.571366Z',
Expand Down Expand Up @@ -45,6 +46,7 @@ export const ProductCreatedMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
eventId: 'evt_01h7zcgmnv3ee9cqrj9fpww3mg',
eventType: 'product.created',
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/mocks/notifications/product-imported.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IProductResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { IProductNotificationResponse } from '../../../notifications';

export const ProductImportedMock: IEventsResponse<IProductResponse> = {
export const ProductImportedMock: IEventsResponse<IProductNotificationResponse> = {
event_id: 'evt_01hgas2cm8r02nxryp83jqvg6k',
event_type: 'product.imported',
occurred_at: '2023-11-28T10:54:46.408439Z',
Expand Down Expand Up @@ -42,6 +43,7 @@ export const ProductImportedMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
eventId: 'evt_01hgas2cm8r02nxryp83jqvg6k',
eventType: 'product.imported',
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/mocks/notifications/product-updated.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IProductResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { IProductNotificationResponse } from '../../../notifications';

export const ProductUpdatedMock: IEventsResponse<IProductResponse> = {
export const ProductUpdatedMock: IEventsResponse<IProductNotificationResponse> = {
event_id: 'evt_01h7zcr13xte50ncas1jkgpbfk',
event_type: 'product.updated',
occurred_at: '2023-08-16T14:42:10.685247Z',
Expand Down Expand Up @@ -45,6 +46,7 @@ export const ProductUpdatedMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
eventId: 'evt_01h7zcr13xte50ncas1jkgpbfk',
eventType: 'product.updated',
Expand Down
14 changes: 12 additions & 2 deletions src/__tests__/mocks/notifications/transaction-billed.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type ITransactionResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { ITransactionNotificationResponse } from '../../../notifications';

export const TransactionBilledMock: IEventsResponse<ITransactionResponse> = {
export const TransactionBilledMock: IEventsResponse<ITransactionNotificationResponse> = {
event_id: 'evt_01h8e3a5029s6xrd5qj89beawp',
event_type: 'transaction.billed',
occurred_at: '2023-08-22T07:45:55.202630Z',
Expand Down Expand Up @@ -240,6 +241,7 @@ export const TransactionBilledMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
proration: null,
quantity: 20,
Expand Down Expand Up @@ -272,6 +274,7 @@ export const TransactionBilledMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
proration: null,
quantity: 1,
Expand Down Expand Up @@ -304,6 +307,7 @@ export const TransactionBilledMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
proration: null,
quantity: 1,
Expand Down Expand Up @@ -359,6 +363,7 @@ export const TransactionBilledMockExpectation = {
frequency: 1,
interval: 'year',
},
createdAt: null,
customData: null,
description: 'Annual (per seat)',
id: 'pri_01gsz91wy9k1yn7kx82aafwvea',
Expand All @@ -378,6 +383,7 @@ export const TransactionBilledMockExpectation = {
currencyCode: 'USD',
},
unitPriceOverrides: [],
updatedAt: null,
},
proration: null,
quantity: 20,
Expand All @@ -388,6 +394,7 @@ export const TransactionBilledMockExpectation = {
frequency: 1,
interval: 'year',
},
createdAt: null,
customData: null,
description: 'Annual (recurring addon)',
id: 'pri_01gsz96z29d88jrmsf2ztbfgjg',
Expand All @@ -407,13 +414,15 @@ export const TransactionBilledMockExpectation = {
currencyCode: 'USD',
},
unitPriceOverrides: [],
updatedAt: null,
},
proration: null,
quantity: 1,
},
{
price: {
billingCycle: null,
createdAt: null,
customData: null,
description: 'One-time charge',
id: 'pri_01gsz98e27ak2tyhexptwc58yk',
Expand Down Expand Up @@ -441,6 +450,7 @@ export const TransactionBilledMockExpectation = {
},
},
],
updatedAt: null,
},
proration: null,
quantity: 1,
Expand Down
14 changes: 12 additions & 2 deletions src/__tests__/mocks/notifications/transaction-canceled.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type ITransactionResponse } from '../../../types';
import { type IEventsResponse } from '../../../types';
import { ITransactionNotificationResponse } from '../../../notifications';

export const TransactionCanceledMock: IEventsResponse<ITransactionResponse> = {
export const TransactionCanceledMock: IEventsResponse<ITransactionNotificationResponse> = {
event_id: 'evt_01h8e3dvbz4y98ge4q3raptg16',
event_type: 'transaction.canceled',
occurred_at: '2023-08-22T07:47:56.415447Z',
Expand Down Expand Up @@ -240,6 +241,7 @@ export const TransactionCanceledMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
proration: null,
quantity: 20,
Expand Down Expand Up @@ -272,6 +274,7 @@ export const TransactionCanceledMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
proration: null,
quantity: 1,
Expand Down Expand Up @@ -304,6 +307,7 @@ export const TransactionCanceledMockExpectation = {
status: 'active',
taxCategory: 'standard',
type: 'standard',
updatedAt: null,
},
proration: null,
quantity: 1,
Expand Down Expand Up @@ -359,6 +363,7 @@ export const TransactionCanceledMockExpectation = {
frequency: 1,
interval: 'year',
},
createdAt: null,
customData: null,
description: 'Annual (per seat)',
id: 'pri_01gsz91wy9k1yn7kx82aafwvea',
Expand All @@ -378,6 +383,7 @@ export const TransactionCanceledMockExpectation = {
currencyCode: 'USD',
},
unitPriceOverrides: [],
updatedAt: null,
},
proration: null,
quantity: 20,
Expand All @@ -388,6 +394,7 @@ export const TransactionCanceledMockExpectation = {
frequency: 1,
interval: 'year',
},
createdAt: null,
customData: null,
description: 'Annual (recurring addon)',
id: 'pri_01gsz96z29d88jrmsf2ztbfgjg',
Expand All @@ -407,13 +414,15 @@ export const TransactionCanceledMockExpectation = {
currencyCode: 'USD',
},
unitPriceOverrides: [],
updatedAt: null,
},
proration: null,
quantity: 1,
},
{
price: {
billingCycle: null,
createdAt: null,
customData: null,
description: 'One-time charge',
id: 'pri_01gsz98e27ak2tyhexptwc58yk',
Expand Down Expand Up @@ -441,6 +450,7 @@ export const TransactionCanceledMockExpectation = {
},
},
],
updatedAt: null,
},
proration: null,
quantity: 1,
Expand Down
Loading

0 comments on commit 42cd44f

Please sign in to comment.