@vansite/ts-sharetribe-flex-sdk
Version:
This is a TypeScript SDK for Sharetribe Flex API. It reduces the complexity of the API and provides a more user-friendly interface.
36 lines • 1.4 kB
TypeScript
/**
* @fileoverview Provides the Money class for handling monetary values.
* This class ensures proper structure and validation of monetary values with an amount and a currency.
*/
import { SdkType } from "../types";
declare const MONEY_SDK_TYPE = "Money";
/**
* Error thrown when invalid Money values are provided.
*/
export declare class InvalidMoneyError extends Error {
constructor(message: string);
}
/**
* Class representing a monetary value.
*
* The Money class encapsulates an amount in the smallest unit of the currency (e.g., cents)
* and a currency code (e.g., "USD").
*/
declare class Money implements SdkType {
amount: number;
currency: string;
readonly _sdkType: typeof MONEY_SDK_TYPE;
/**
* Creates an instance of the Money class.
*
* @param {number} amount - The monetary amount, represented in the smallest unit of the currency (e.g., cents for USD).
* @param {string} currency - The currency code, represented as a three-character uppercase string (e.g., "USD").
* @throws {InvalidMoneyError} If the amount is not an integer or currency is not a valid ISO 4217 code.
* @example
* const money = new Money(1000, 'USD');
* console.log(money); // Outputs: Money { amount: 1000, currency: 'USD' }
*/
constructor(amount: number, currency: string);
}
export default Money;
//# sourceMappingURL=Money.d.ts.map