Skip to content

Commit b6da233

Browse files
authored
Merge pull request #22 from SIDANWhatever/feature/change-query-param-to-accept-typed-objects
Feature/change query param to accept typed objects
2 parents 606b41c + 04569da commit b6da233

File tree

26 files changed

+2110
-2214
lines changed

26 files changed

+2110
-2214
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@maestro-org/typescript-sdk",
3-
"version": "1.1.2",
3+
"version": "1.2.2",
44
"description": "TypeScript SDK for the Maestro Dapp Platform",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/api/accounts/helpers.ts

Lines changed: 148 additions & 241 deletions
Large diffs are not rendered by default.

src/api/accounts/index.ts

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { AxiosRequestConfig } from 'axios';
22
import { BaseAPI } from '../../base';
33
import { AccountsApiFp } from './helpers';
4+
import {
5+
AccountAddressesQueryParams,
6+
AccountAssetsQueryParams,
7+
AccountHistoryQueryParams,
8+
AccountRewardsQueryParams,
9+
AccountUpdatesQueryParams,
10+
} from './type';
411

512
/**
613
* AccountsApi - object-oriented interface
@@ -13,66 +20,48 @@ export class AccountsApi extends BaseAPI {
1320
* Returns a list of addresses seen on-chain which use the specified stake key
1421
* @summary Stake account addresses
1522
* @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\')
16-
* @param {number | null} [count] The max number of results per page
17-
* @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page
23+
* @param {AccountAddressesQueryParams} [queryParams] Query parameters.
1824
* @param {*} [options] Override http request option.
1925
* @throws {RequiredError}
2026
* @memberof AccountsApi
2127
*/
2228
public accountAddresses(
2329
stakeAddr: string,
24-
count?: number | null,
25-
cursor?: string | null,
30+
queryParams?: AccountAddressesQueryParams,
2631
options?: AxiosRequestConfig,
2732
) {
2833
return AccountsApiFp(this.configuration)
29-
.accountAddresses(stakeAddr, count, cursor, options)
34+
.accountAddresses(stakeAddr, queryParams, options)
3035
.then((request) => request(this.axios));
3136
}
3237

3338
/**
3439
* Returns a list of native assets which are owned by addresses with the specified stake key
3540
* @summary Stake account assets
3641
* @param {string} stakeAddr Bech32 encoded reward/stake address (\'stake1...\')
37-
* @param {string | null} [policy] Filter results to only show assets of the specified policy
38-
* @param {number | null} [count] The max number of results per page
39-
* @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page
42+
* @param {AccountAssetsQueryParams} [queryParams] Query parameters.
4043
* @param {*} [options] Override http request option.
4144
* @throws {RequiredError}
4245
* @memberof AccountsApi
4346
*/
44-
public accountAssets(
45-
stakeAddr: string,
46-
policy?: string | null,
47-
count?: number | null,
48-
cursor?: string | null,
49-
options?: AxiosRequestConfig,
50-
) {
47+
public accountAssets(stakeAddr: string, queryParams?: AccountAssetsQueryParams, options?: AxiosRequestConfig) {
5148
return AccountsApiFp(this.configuration)
52-
.accountAssets(stakeAddr, policy, count, cursor, options)
49+
.accountAssets(stakeAddr, queryParams, options)
5350
.then((request) => request(this.axios));
5451
}
5552

5653
/**
5754
* Returns per-epoch history for the specified stake key
5855
* @summary Stake account history
5956
* @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\')
60-
* @param {number | null} [epochNo] Fetch result for only a specific epoch
61-
* @param {number | null} [count] The max number of results per page
62-
* @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page
57+
* @param {AccountHistoryQueryParams} [queryParams] Query parameters.
6358
* @param {*} [options] Override http request option.
6459
* @throws {RequiredError}
6560
* @memberof AccountsApi
6661
*/
67-
public accountHistory(
68-
stakeAddr: string,
69-
epochNo?: number | null,
70-
count?: number | null,
71-
cursor?: string | null,
72-
options?: AxiosRequestConfig,
73-
) {
62+
public accountHistory(stakeAddr: string, queryParams?: AccountHistoryQueryParams, options?: AxiosRequestConfig) {
7463
return AccountsApiFp(this.configuration)
75-
.accountHistory(stakeAddr, epochNo, count, cursor, options)
64+
.accountHistory(stakeAddr, queryParams, options)
7665
.then((request) => request(this.axios));
7766
}
7867

@@ -94,41 +83,31 @@ export class AccountsApi extends BaseAPI {
9483
* Returns a list of staking-related rewards for the specified stake key (pool `member` or `leader` rewards, deposit `refund`)
9584
* @summary Stake account rewards
9685
* @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\')
97-
* @param {number | null} [count] The max number of results per page
98-
* @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page
86+
* @param {AccountRewardsQueryParams} [queryParams] Query parameters.
9987
* @param {*} [options] Override http request option.
10088
* @throws {RequiredError}
10189
* @memberof AccountsApi
10290
*/
103-
public accountRewards(
104-
stakeAddr: string,
105-
count?: number | null,
106-
cursor?: string | null,
107-
options?: AxiosRequestConfig,
108-
) {
91+
public accountRewards(stakeAddr: string, queryParams?: AccountRewardsQueryParams, options?: AxiosRequestConfig) {
10992
return AccountsApiFp(this.configuration)
110-
.accountRewards(stakeAddr, count, cursor, options)
93+
.accountRewards(stakeAddr, queryParams, options)
11194
.then((request) => request(this.axios));
11295
}
11396

11497
/**
11598
* Returns a list of updates relating to the specified stake key ( `registration`, `deregistration`, `delegation`, `withdrawal`)
11699
* @summary Stake account updates
117100
* @param {string} stakeAddr Bech32 encoded stake/reward address (\'stake1...\')
118-
* @param {number | null} [count] The max number of results per page
119-
* @param {string | null} [cursor] Pagination cursor string, use the cursor included in a page of results to fetch the next page
101+
* @param {AccountUpdatesQueryParams} [queryParams] Query parameters.
120102
* @param {*} [options] Override http request option.
121103
* @throws {RequiredError}
122104
* @memberof AccountsApi
123105
*/
124-
public accountUpdates(
125-
stakeAddr: string,
126-
count?: number | null,
127-
cursor?: string | null,
128-
options?: AxiosRequestConfig,
129-
) {
106+
public accountUpdates(stakeAddr: string, queryParams?: AccountUpdatesQueryParams, options?: AxiosRequestConfig) {
130107
return AccountsApiFp(this.configuration)
131-
.accountUpdates(stakeAddr, count, cursor, options)
108+
.accountUpdates(stakeAddr, queryParams, options)
132109
.then((request) => request(this.axios));
133110
}
134111
}
112+
113+
export * from './type';

src/api/accounts/type.ts

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/**
2+
* Query parameters for accountAddresses.
3+
* @export
4+
* @interface AccountAddressesQueryParams
5+
*
6+
*/
7+
export interface AccountAddressesQueryParams {
8+
/**
9+
* The max number of results per page.
10+
* @type {number | null}
11+
* @memberof AccountAddressesQueryParams
12+
*/
13+
count?: number | null;
14+
/**
15+
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
16+
* @type {string | null}
17+
* @memberof AccountAddressesQueryParams
18+
*/
19+
cursor?: string | null;
20+
}
21+
22+
/**
23+
* Query parameters for accountAssets.
24+
* @export
25+
* @interface AccountAssetsQueryParams
26+
*
27+
*/
28+
export interface AccountAssetsQueryParams {
29+
/**
30+
* Filter results to only show assets of the specified policy
31+
* @type {string | null}
32+
* @memberof AccountAssetsQueryParams
33+
*/
34+
policy?: string | null;
35+
/**
36+
* The max number of results per page.
37+
* @type {number | null}
38+
* @memberof AccountAssetsQueryParams
39+
*/
40+
count?: number | null;
41+
/**
42+
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
43+
* @type {string | null}
44+
* @memberof AccountAssetsQueryParams
45+
*/
46+
cursor?: string | null;
47+
}
48+
49+
/**
50+
* Query parameters for accountHistory.
51+
* @export
52+
* @interface AccountHistoryQueryParams
53+
*
54+
*/
55+
export interface AccountHistoryQueryParams {
56+
/**
57+
* Fetch result for only a specific epoch
58+
* @type {string | null}
59+
* @memberof AccountHistoryQueryParams
60+
*/
61+
epochNo?: number | null;
62+
/**
63+
* The max number of results per page.
64+
* @type {number | null}
65+
* @memberof AccountHistoryQueryParams
66+
*/
67+
count?: number | null;
68+
/**
69+
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
70+
* @type {string | null}
71+
* @memberof AccountHistoryQueryParams
72+
*/
73+
cursor?: string | null;
74+
}
75+
76+
/**
77+
* Query parameters for accountRewards.
78+
* @export
79+
* @interface AccountRewardsQueryParams
80+
*
81+
*/
82+
export interface AccountRewardsQueryParams {
83+
/**
84+
* The max number of results per page.
85+
* @type {number | null}
86+
* @memberof AccountRewardsQueryParams
87+
*/
88+
count?: number | null;
89+
/**
90+
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
91+
* @type {string | null}
92+
* @memberof AccountRewardsQueryParams
93+
*/
94+
cursor?: string | null;
95+
}
96+
97+
/**
98+
* Query parameters for accountUpdates.
99+
* @export
100+
* @interface AccountUpdatesQueryParams
101+
*
102+
*/
103+
export interface AccountUpdatesQueryParams {
104+
/**
105+
* The max number of results per page.
106+
* @type {number | null}
107+
* @memberof AccountUpdatesQueryParams
108+
*/
109+
count?: number | null;
110+
/**
111+
* Pagination cursor string, use the cursor included in a page of results to fetch the next page.
112+
* @type {string | null}
113+
* @memberof AccountUpdatesQueryParams
114+
*/
115+
cursor?: string | null;
116+
}

0 commit comments

Comments
 (0)