-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
137 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { AssetAmount as AssetAmountModel } from "../client"; | ||
|
||
/** A representation of a balance. */ | ||
export class AssetAmount { | ||
public readonly amount: string; | ||
public readonly ticker: string; | ||
public readonly raw_numeric: string; | ||
public readonly exp: number; | ||
|
||
public constructor(amount: string, raw_numeric: string, exp: number, ticker: string) { | ||
Check failure on line 10 in src/coinbase/asset_amount.ts GitHub Actions / lint
|
||
this.amount = amount; | ||
this.ticker = ticker; | ||
this.raw_numeric = raw_numeric; | ||
this.exp = exp; | ||
} | ||
|
||
/** | ||
* Converts a AssetAmountModel into a AssetAmount object. | ||
* | ||
* @param {AssetAmountModel} model - The assetAmount model object. | ||
* @returns {AssetAmount} The Balance object. | ||
*/ | ||
public static fromModel(model: AssetAmountModel): AssetAmount { | ||
return new AssetAmount( | ||
model.amount, | ||
model.raw_numeric, | ||
model.exp, | ||
model.ticker, | ||
); | ||
} | ||
|
||
public getAmount(): string { | ||
return this.amount; | ||
} | ||
|
||
public getTicker(): string { | ||
return this.ticker; | ||
} | ||
|
||
public getRawNumeric(): string { | ||
return this.raw_numeric; | ||
} | ||
|
||
public getExp(): number { | ||
return this.exp; | ||
} | ||
|
||
public toString(): string { | ||
return `{ amount: '${this.amount}', raw_numeric: '${this.raw_numeric}', exp: ${this.exp}, ticker: '${this.ticker}' }`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters