Skip to content

Commit

Permalink
Fixed missing params in requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-musialowski committed Nov 28, 2024
1 parent 9d36132 commit 991dd39
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
4 changes: 3 additions & 1 deletion demos/xray_wip/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ async function displaySecurityDetails (postmanJSON) {
id: 'F0GBR052QA',
idType: 'MSID',
type: 'FO',
weight: '100'
weight: '100',
name: 'BlackRock Income and Growth Ord',
holdingType: 'weight'
}
]
}
Expand Down
10 changes: 10 additions & 0 deletions src/Shared/MorningstarOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ interface MorningstarSecurityOptionsGeneric<IDType> {
*/
type?: (string|MorningstarSecurityType);

/**
* Type of holding.
*/
holdingType?: string;

/**
* Weight of holding.
*/
weight?: (number|string);

}


Expand Down
8 changes: 6 additions & 2 deletions src/XRay/XRayConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface XRayHoldingObject {
amount?: string;
identifier: string;
identifierType: string;
holdingType: number;
holdingType: string|number;
name?: string;
securityType?: string;
weight?: string;
Expand Down Expand Up @@ -78,7 +78,7 @@ function convertHoldings (
const holding: XRayHoldingObject = {
identifier: security.id,
identifierType: security.idType,
holdingType
holdingType: security.holdingType || holdingType
};

if (security.name) {
Expand All @@ -89,6 +89,10 @@ function convertHoldings (
holding.securityType = security.type;
}

if (security.weight) {
holding.weight = security.weight.toString();
}

return holding;
});
}
Expand Down
22 changes: 17 additions & 5 deletions src/XRay/XRayJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,34 @@ namespace XRayJSON {
);
}

function checkRegionalExposure (
regionalExposureArray?: unknown
): regionalExposureArray is Array<RegionalExposure> {
return (
!!regionalExposureArray &&
typeof regionalExposureArray === 'object' &&
regionalExposureArray instanceof Array &&
(
regionalExposureArray &&
regionalExposureArray.length === 0 ||
isRegionalExposure(regionalExposureArray[0])
)
);
}


function isBreakdowns (
json?: unknown
): json is Breakdowns {
return (
!!json &&
typeof json === 'object' &&

(json as Breakdowns).assetAllocation instanceof Array &&
(
(json as Breakdowns).assetAllocation.length === 0 ||
isAssetAllocation((json as Breakdowns).assetAllocation[0])
) &&
(
typeof (json as Breakdowns).regionalExposure === 'undefined' ||
isRegionalExposure((json as Breakdowns).regionalExposure)
)
) && checkRegionalExposure((json as Breakdowns).regionalExposure)
);
}

Expand Down

0 comments on commit 991dd39

Please sign in to comment.