Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustment type and VND currency #87

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ 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.

## 2.2.0 - 2024-12-12

### Added

- `VND` (Vietnamese dong) as new currency
- Added `adjustment.type` which is either `partial` which should include `items` or `full` where `items` are not required

## 2.1.3 - 2024-11-29

### Changed
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": "2.1.3",
"version": "2.2.0",
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
"main": "dist/cjs/index.cjs.node.js",
"module": "dist/esm/index.esm.node.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const AdjustmentCreatedMock: IEventsResponse<IAdjustmentResponse> = {
},
],
action: 'refund',
type: 'partial',
reason: 'error',
status: 'pending_approval',
totals: { fee: '5', tax: '8', total: '100', earnings: '87', subtotal: '92', currency_code: 'USD' },
Expand All @@ -41,6 +42,7 @@ export const AdjustmentCreatedMock: IEventsResponse<IAdjustmentResponse> = {
export const AdjustmentCreatedMockExpectation = {
data: {
action: 'refund',
type: 'partial',
createdAt: '2023-08-21T14:08:43.297512Z',
creditAppliedToBalance: true,
currencyCode: 'USD',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const AdjustmentUpdatedMock: IEventsResponse<IAdjustmentResponse> = {
},
],
action: 'refund',
type: 'partial',
reason: 'error',
status: 'approved',
totals: { fee: '5', tax: '8', total: '100', earnings: '87', subtotal: '92', currency_code: 'USD' },
Expand All @@ -41,6 +42,7 @@ export const AdjustmentUpdatedMock: IEventsResponse<IAdjustmentResponse> = {
export const AdjustmentUpdatedMockExpectation = {
data: {
action: 'refund',
type: 'partial',
createdAt: '2023-08-21T14:08:43.297512Z',
creditAppliedToBalance: true,
currencyCode: 'USD',
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/mocks/resources/adjustments.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const CreateAdjustmentExpectation = {

export const AdjustmentMock: IAdjustmentResponse = {
action: 'credit',
type: 'partial',
items: [
{
amount: '1000',
Expand Down
9 changes: 8 additions & 1 deletion src/entities/adjustment/adjustment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type AdjustmentAction, type AdjustmentStatus, type CurrencyCode } from '../../enums/index.js';
import {
type AdjustmentActionType,
type AdjustmentAction,
type AdjustmentStatus,
type CurrencyCode,
} from '../../enums/index.js';
import { AdjustmentItem } from './adjustment-item.js';
import { PayoutTotalsAdjustment, TotalAdjustments } from '../shared/index.js';
import { type IAdjustmentResponse } from '../../types/index.js';

export class Adjustment {
public readonly id: string;
public readonly action: AdjustmentAction;
public readonly type: AdjustmentActionType;
public readonly transactionId: string;
public readonly subscriptionId: string | null;
public readonly customerId: string;
Expand All @@ -28,6 +34,7 @@ export class Adjustment {
constructor(adjustment: IAdjustmentResponse) {
this.id = adjustment.id;
this.action = adjustment.action;
this.type = adjustment.type;
this.transactionId = adjustment.transaction_id;
this.subscriptionId = adjustment.subscription_id ? adjustment.subscription_id : null;
this.customerId = adjustment.customer_id;
Expand Down
7 changes: 7 additions & 0 deletions src/enums/adjustment/adjustment-action-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* ! Autogenerated code !
* Do not make changes to this file.
* Changes may be overwritten as part of auto-generation.
*/

export type AdjustmentActionType = 'full' | 'partial';
5 changes: 3 additions & 2 deletions src/enums/adjustment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Changes may be overwritten as part of auto-generation.
*/

export * from './adjustment-type.js';
export * from './adjustment-currency-code.js';
export * from './adjustment-action-type.js';
export * from './adjustment-action.js';
export * from './adjustment-currency-code.js';
export * from './adjustment-status.js';
export * from './adjustment-type.js';
2 changes: 2 additions & 0 deletions src/enums/shared/currency-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Do not make changes to this file.
* Changes may be overwritten as part of auto-generation.
*/

export type CurrencyCode =
| 'USD'
| 'EUR'
Expand Down Expand Up @@ -33,4 +34,5 @@ export type CurrencyCode =
| 'TRY'
| 'TWD'
| 'UAH'
| 'VND'
| 'ZAR';
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type AdjustmentAction, type AdjustmentStatus, type CurrencyCode } from '../../../enums/index.js';
import {
type AdjustmentActionType,
type AdjustmentAction,
type AdjustmentStatus,
type CurrencyCode,
} from '../../../enums/index.js';
import { AdjustmentItemNotification } from './adjustment-item-notification.js';
import { PayoutTotalsAdjustmentNotification, TotalAdjustmentsNotification } from '../shared/index.js';
import { type IAdjustmentNotificationResponse } from '../../types/index.js';

export class AdjustmentNotification {
public readonly id: string;
public readonly action: AdjustmentAction;
public readonly type: AdjustmentActionType;
public readonly transactionId: string;
public readonly subscriptionId: string | null;
public readonly customerId: string;
Expand All @@ -28,6 +34,7 @@ export class AdjustmentNotification {
constructor(adjustment: IAdjustmentNotificationResponse) {
this.id = adjustment.id;
this.action = adjustment.action;
this.type = adjustment.type;
this.transactionId = adjustment.transaction_id;
this.subscriptionId = adjustment.subscription_id ? adjustment.subscription_id : null;
this.customerId = adjustment.customer_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type AdjustmentAction, type AdjustmentStatus, type CurrencyCode } from '../../../enums/index.js';
import {
type AdjustmentActionType,
type AdjustmentAction,
type AdjustmentStatus,
type CurrencyCode,
} from '../../../enums/index.js';
import { type IAdjustmentItemNotificationResponse } from './adjustment-item-notification-response.js';
import {
type IPayoutTotalsAdjustmentNotificationResponse,
Expand All @@ -14,6 +19,7 @@ import {
export interface IAdjustmentNotificationResponse {
id: string;
action: AdjustmentAction;
type: AdjustmentActionType;
transaction_id: string;
subscription_id?: string | null;
customer_id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ export interface CreateAdjustmentLineItem {
type: AdjustmentType;
}

export interface CreateAdjustmentRequestBody {
interface CreatePartialAdjustmentRequestBody {
action: AdjustmentAction;
items: CreateAdjustmentLineItem[];
reason: string;
transactionId: string;
type?: 'partial';
}

interface CreateFullAdjustmentRequestBody {
action: AdjustmentAction;
reason: string;
transactionId: string;
type?: 'full';
}

export type CreateAdjustmentRequestBody = CreatePartialAdjustmentRequestBody | CreateFullAdjustmentRequestBody;
8 changes: 7 additions & 1 deletion src/types/adjustment/adjustment-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type AdjustmentAction, type AdjustmentStatus, type CurrencyCode } from '../../enums/index.js';
import {
type AdjustmentActionType,
type AdjustmentAction,
type AdjustmentStatus,
type CurrencyCode,
} from '../../enums/index.js';
import { type IAdjustmentItemResponse } from './adjustment-item-response.js';
import { type IPayoutTotalsAdjustmentResponse, type ITotalAdjustmentsResponse } from '../shared/index.js';

export interface IAdjustmentResponse {
id: string;
action: AdjustmentAction;
type: AdjustmentActionType;
transaction_id: string;
subscription_id?: string | null;
customer_id: string;
Expand Down
Loading