Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.156.0] - 2024.11.07

### Added
- [orders] Added organizationUnit property in order product entity

## [3.155.0] - 2024.10.30

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "git",
"url": "https://github.com/ArrowSphere/nodejs-api-client.git"
},
"version": "3.155.0",
"version": "3.156.0",
"description": "Node.js client for ArrowSphere's public API",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { AbstractEntity } from '../../../../../abstractEntity';

export enum OrganizationUnitTypeFields {
COLUMN_ORGANIZATION_UNIT_REF = 'organizationUnitRef',
COLUMN_NAME = 'name',
}

export type OrganizationUnitType = {
[OrganizationUnitTypeFields.COLUMN_ORGANIZATION_UNIT_REF]?: string;
[OrganizationUnitTypeFields.COLUMN_NAME]?: string;
};

export class OrganizationUnit extends AbstractEntity<OrganizationUnitType> {
readonly #organizationUnitRef?: string;
readonly #name?: string;

public constructor(data: OrganizationUnit) {
super(data);

this.#organizationUnitRef =
data[OrganizationUnitTypeFields.COLUMN_ORGANIZATION_UNIT_REF];
this.#name = data[OrganizationUnitTypeFields.COLUMN_NAME];
}

get organizationUnitRef(): string | undefined {
return this.#organizationUnitRef;
}
get name(): string | undefined {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very important but an empty line is missing here.

return this.#name;
}

public toJSON(): OrganizationUnitType {
return {
[OrganizationUnitTypeFields.COLUMN_ORGANIZATION_UNIT_REF]: this
.organizationUnitRef,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to split this line.

[OrganizationUnitTypeFields.COLUMN_NAME]: this.name,
};
}
}
20 changes: 20 additions & 0 deletions src/orders/entities/orders/products/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
ProductIdentifiersType,
} from './identifiers/productIdentifiers';
import { PriceBand, PriceBandType } from './priceBand/priceBand';
import {
OrganizationUnit,
OrganizationUnitType,
} from './organizationUnit/organizationUnit';

export enum OrderProductsFields {
COLUMN_SKU = 'sku',
Expand All @@ -25,6 +29,7 @@ export enum OrderProductsFields {
COLUMN_PROGRAM = 'program',
COLUMN_IDENTIFIERS = 'identifiers',
COLUMN_ORGANIZATION_UNIT_REF = 'organizationUnitRef',
COLUMN_ORGANIZATION_UNIT = 'organizationUnit',
COLUMN_PRICE_BAND = 'priceBand',
}

Expand All @@ -45,6 +50,7 @@ export type OrderProductsType = {
[OrderProductsFields.COLUMN_PROGRAM]: ProductProgramType;
[OrderProductsFields.COLUMN_IDENTIFIERS]: ProductIdentifiersType;
[OrderProductsFields.COLUMN_ORGANIZATION_UNIT_REF]?: string;
[OrderProductsFields.COLUMN_ORGANIZATION_UNIT]?: OrganizationUnitType;
[OrderProductsFields.COLUMN_PRICE_BAND]?: PriceBandType;
};

Expand All @@ -65,6 +71,7 @@ export class OrderProduct extends AbstractEntity<OrderProductsType> {
readonly #program: ProductProgram;
readonly #identifier: ProductIdentifiers;
readonly #organizationUnitRef?: string;
readonly #organizationUnit?: OrganizationUnit;
readonly #priceBand?: PriceBand;

public constructor(getOrderProducts: OrderProductsType) {
Expand Down Expand Up @@ -107,6 +114,15 @@ export class OrderProduct extends AbstractEntity<OrderProductsType> {
);
this.#organizationUnitRef =
getOrderProducts[OrderProductsFields.COLUMN_ORGANIZATION_UNIT_REF];
this.#organizationUnit = getOrderProducts[
OrderProductsFields.COLUMN_ORGANIZATION_UNIT
]
? new OrganizationUnit(
getOrderProducts[
OrderProductsFields.COLUMN_ORGANIZATION_UNIT
] as OrganizationUnit,
)
: undefined;
this.#priceBand = getOrderProducts[OrderProductsFields.COLUMN_PRICE_BAND]
? new PriceBand(
getOrderProducts[OrderProductsFields.COLUMN_PRICE_BAND] as PriceBand,
Expand Down Expand Up @@ -165,6 +181,9 @@ export class OrderProduct extends AbstractEntity<OrderProductsType> {
get priceBand(): PriceBand | undefined {
return this.#priceBand;
}
get organizationUnit(): OrganizationUnit | undefined {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing empty line here too.

return this.#organizationUnit;
}

public toJSON(): OrderProductsType {
return {
Expand All @@ -185,6 +204,7 @@ export class OrderProduct extends AbstractEntity<OrderProductsType> {
[OrderProductsFields.COLUMN_IDENTIFIERS]: this.identifier.toJSON(),
[OrderProductsFields.COLUMN_ORGANIZATION_UNIT_REF]: this
.organizationUnitRef,
[OrderProductsFields.COLUMN_ORGANIZATION_UNIT]: this.organizationUnit?.toJSON(),
[OrderProductsFields.COLUMN_PRICE_BAND]: this.priceBand?.toJSON(),
};
}
Expand Down
7 changes: 7 additions & 0 deletions tests/orders/mocks/orders.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '../../../src';
import { UpdateOrderResultData } from '../../../src/orders/entities/orders/updateOrderResult';
import { PriceBandFields } from '../../../src/orders/entities/orders/products/priceBand/priceBand';
import { OrganizationUnitTypeFields } from '../../../src/orders/entities/orders/products/organizationUnit/organizationUnit';

export const PAYLOAD_ORDERS: GetData<DataListOrdersType> = {
[GetResultFields.COLUMN_STATUS]: 200,
Expand Down Expand Up @@ -83,6 +84,12 @@ export const PAYLOAD_ORDERS: GetData<DataListOrdersType> = {
},
},
[OrderProductsFields.COLUMN_ORGANIZATION_UNIT_REF]: 'XSPOU321',
[OrderProductsFields.COLUMN_ORGANIZATION_UNIT]: {
[OrganizationUnitTypeFields.COLUMN_ORGANIZATION_UNIT_REF]:
'XSPOU321',
[OrganizationUnitTypeFields.COLUMN_NAME]:
'organization_unit_name',
},
[OrderProductsFields.COLUMN_PRICE_BAND]: {
[PriceBandFields.COLUMN_ATTRIBUTES]: [
{ name: 'Attribute1', value: 'value1' },
Expand Down
Loading