Skip to content

Commit

Permalink
Added directory tree & usage method. (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel authored Aug 12, 2021
1 parent a810ac6 commit 18313f0
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,41 @@ If you are using the types in a `commonjs` module, like in a Node app, you just
....
```

## Directory structure
```bash
└── src
β”‚ β”œβ”€β”€ blockchain // Blockchain API methods without private key
β”‚ β”œβ”€β”€ connector // Wrapper around all HTTP methods
β”‚ β”œβ”€β”€ contracts // Abi and byte code smart contracts
β”‚ β”‚ β”œβ”€β”€ custodial
β”‚ β”‚ β”œβ”€β”€ erc20
β”‚ β”‚ β”œβ”€β”€ erc721
β”‚ β”‚ β”œβ”€β”€ erc1155
β”‚ β”‚ β”œβ”€β”€ marketplace
β”‚ β”‚ β”œβ”€β”€ trc20
β”‚ β”‚ β”œβ”€β”€ trc721
β”‚ β”œβ”€β”€ ledger // Ledger API methods
β”‚ β”œβ”€β”€ model // Validation, interfaces and DTO classes
β”‚ β”‚ β”œβ”€β”€ request
β”‚ β”‚ β”œβ”€β”€ response
β”‚ β”‚ β”œβ”€β”€ validation
β”‚ β”œβ”€β”€ multiToken // Multi Token API methods
β”‚ β”œβ”€β”€ nft // NFT API methods
β”‚ β”‚ β”œβ”€β”€ marketplace // Marketplace API methods
β”‚ β”œβ”€β”€ offchain // Offchain API methods
β”‚ β”œβ”€β”€ record // Logging API methods
β”‚ β”œβ”€β”€ security // Security and KMS methods
β”‚ β”œβ”€β”€ tatum // Service API methods
β”‚ β”œβ”€β”€ transaction // Transaction API methods
β”‚ β”œβ”€β”€ wallet // Wallet, private key and address API methods
β”‚ └── constants.ts // Constants
β”œβ”€β”€ README.md
β”œβ”€β”€ package.json
β”œβ”€β”€ tslint.js
β”œβ”€β”€ tsconfig.json
└── .gitignore
```

## Contributing

Contributions to the Tatum API client are welcome. Please ensure
Expand Down
14 changes: 14 additions & 0 deletions src/model/response/common/Consumption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Usage information of credits
*/
export interface Consumption {
/**
* UTC millis timestamp of the day.
*/
day: number

/**
* Number of credits consumed for the specific day.
*/
usage: number
}
1 change: 1 addition & 0 deletions src/model/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './common/Rate';
export * from './common/SignatureId';
export * from './common/TransactionHash';
export * from './common/TxHash';
export * from './common/Consumption';
export * from './kms/TransactionKMS';
export * from './eth/EthBlock';
export * from './eth/EthTx';
Expand Down
9 changes: 9 additions & 0 deletions src/tatum/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { getUsage } from './index'

describe('Test Tatum Service', () => {
it('Test getUsage', async () => {
const usage = await getUsage()
expect(usage).not.toBeNull()
expect(Array.isArray(usage)).toBe(true)
});
});
13 changes: 9 additions & 4 deletions src/tatum/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { get } from '../connector/tatum'
import {Currency} from '../model';
import {Fiat} from '../model';
import {Rate} from '../model/response/common/Rate';
import { Consumption, Currency, Fiat, Rate } from '../model';

/**
* For more details, see <a href="https://tatum.io/apidoc#operation/getExchangeRate" target="_blank">Tatum API documentation</a>
*/
export const getExchangeRate = async (currency: Fiat | Currency, basePair = Fiat.EUR): Promise<Rate> =>
get(`/v3/tatum/rate/${currency}?basePair=${basePair}`);
get(`/v3/tatum/rate/${currency}?basePair=${basePair}`);

/**
* Returns credit consumption last of month.
*
* For more details, see <a href="https://tatum.io/apidoc#operation/getCredits" target="_blank">Tatum API documentation</a>
*/
export const getUsage = async (): Promise<Consumption[]> => get('/v3/tatum/usage')

0 comments on commit 18313f0

Please sign in to comment.