Skip to content

Commit

Permalink
rm request body
Browse files Browse the repository at this point in the history
  • Loading branch information
marchsu committed Aug 9, 2024
1 parent a42f6c8 commit 891a2a0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 74 deletions.
79 changes: 29 additions & 50 deletions src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
import type { RequestArgs } from './base';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';
import { start } from 'repl';

/**
*
Expand Down Expand Up @@ -725,45 +726,6 @@ export interface FetchStakingRewardsRequest {
'format': StakingRewardFormat;
}


/**
*
* @export
* @interface FetchHistoricalStakingBalancesRequest
*/
export interface FetchHistoricalStakingBalancesRequest {
/**
* The ID of the blockchain network
* @type {string}
* @memberof FetchHistoricalStakingBalancesRequest
*/
'network_id': string;
/**
* The ID of the asset for which the staking balances are being fetched
* @type {string}
* @memberof FetchHistoricalStakingBalancesRequest
*/
'asset_id': string;
/**
* The onchain address for which the staking balances are being fetched
* @type {string}
* @memberof FetchHistoricalStakingBalancesRequest
*/
'address': string;
/**
* The start time of this staking balance period
* @type {string}
* @memberof FetchHistoricalStakingBalancesRequest
*/
'start_time': string;
/**
* The end time of this staking balance period
* @type {string}
* @memberof FetchHistoricalStakingBalancesRequest
*/
'end_time': string;
}

/**
*
* @export
Expand Down Expand Up @@ -3940,9 +3902,18 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
fetchHistoricalStakingBalances: async (FetchHistoricalStakingBalancesRequest: FetchHistoricalStakingBalancesRequest, limit?: number, page?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'FetchHistoricalStakingBalancesRequest' is not null or undefined
assertParamExists('fetchHistoricalStakingBalances', 'FetchHistoricalStakingBalancesRequest', FetchHistoricalStakingBalancesRequest)
fetchHistoricalStakingBalances: async (address: string, networkId: string, assetId: string, startTime: string, endTime: string, limit?: number, page?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'networkId' is not null or undefined
assertParamExists('fetchHistoricalStakingBalances', 'networkId', networkId)
// verify required parameter 'address' is not null or undefined
assertParamExists('fetchHistoricalStakingBalances', 'address', address)
// verify required parameter 'assetId' is not null or undefined
assertParamExists('fetchHistoricalStakingBalances', 'assetId', assetId)
// verify required parameter 'startTime' is not null or undefined
assertParamExists('fetchHistoricalStakingBalances', 'startTime', startTime)
// verify required parameter 'endTime' is not null or undefined
assertParamExists('fetchHistoricalStakingBalances', 'endTime', endTime)

const localVarPath = `/v1/stake/balances`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand All @@ -3955,6 +3926,12 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

localVarQueryParameter['address'] = address;
localVarQueryParameter['networkId'] = networkId;
localVarQueryParameter['assetId'] = assetId;
localVarQueryParameter['startTime'] = startTime;
localVarQueryParameter['endTime'] = endTime

if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
Expand All @@ -3963,14 +3940,12 @@ export const StakeApiAxiosParamCreator = function (configuration?: Configuration
localVarQueryParameter['page'] = page;
}



localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(FetchHistoricalStakingBalancesRequest, localVarRequestOptions, configuration)
localVarRequestOptions.data = serializeDataIfNeeded(null, localVarRequestOptions, configuration)

return {
url: toPathString(localVarUrlObj),
Expand Down Expand Up @@ -4169,14 +4144,18 @@ export const StakeApiFp = function(configuration?: Configuration) {
/**
* Fetch historical staking balances for given address
* @summary Fetch historical staking balances
* @param {FetchHistoricalStakingBalancesRequest} FetchHistoricalStakingBalancesRequest
* @param {string} address The address to fetch historical staking balances for
* @param {string} networkId The ID of the blockchain network
* @param {string} assetId The ID of the asset
* @param {string} startTime The start time of the staking balances
* @param {string} endTime The end time of the staking balances
* @param {number} [limit] A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 50.
* @param {string} [page] A cursor for pagination across multiple pages of results. Don\&#39;t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async fetchHistoricalStakingBalances(FetchHistoricalStakingBalancesRequest: FetchHistoricalStakingBalancesRequest, limit?: number, page?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FetchHistoricalStakingBalances200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchHistoricalStakingBalances(FetchHistoricalStakingBalancesRequest, limit, page, options);
async fetchHistoricalStakingBalances(address: string, networkId: string, assetId: string, startTime: string, endTime: string, limit?: number, page?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FetchHistoricalStakingBalances200Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchHistoricalStakingBalances(address, networkId, assetId, startTime, endTime, limit, page, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['StakeApi.fetchHistoricalStakingBalances']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
Expand Down Expand Up @@ -4290,8 +4269,8 @@ export const StakeApiFactory = function (configuration?: Configuration, basePath
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
fetchHistoricalStakingBalances(FetchHistoricalStakingBalancesRequest: FetchHistoricalStakingBalancesRequest, limit?: number, page?: string, options?: any): AxiosPromise<FetchHistoricalStakingBalances200Response> {
return localVarFp.fetchHistoricalStakingBalances(FetchHistoricalStakingBalancesRequest, limit, page, options).then((request) => request(axios, basePath));
fetchHistoricalStakingBalances(address: string, networkId: string, assetId: string, startTime: string, endTime: string, limit?: number, page?: string, options?: any): AxiosPromise<FetchHistoricalStakingBalances200Response> {
return localVarFp.fetchHistoricalStakingBalances(address, networkId, assetId, startTime, endTime, limit, page, options).then((request) => request(axios, basePath));
},
/**
* Get the latest state of a staking operation
Expand Down
13 changes: 5 additions & 8 deletions src/coinbase/staking_balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ export class StakingBalance {

while (queue.length > 0) {
const page = queue.shift();
const request = {
network_id: Coinbase.normalizeNetwork(networkId),
asset_id: assetId,
address: address,
start_time: startTime,
end_time: endTime,
};

const response = await Coinbase.apiClients.stake!.fetchHistoricalStakingBalances(
request,
address,
networkId,
assetId,
startTime,
endTime,
100,
page?.length ? page : undefined,
);
Expand Down
7 changes: 5 additions & 2 deletions src/coinbase/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
StakingContext as StakingContextModel,
FetchStakingRewardsRequest,
FetchStakingRewards200Response,
FetchHistoricalStakingBalancesRequest,
FetchHistoricalStakingBalances200Response,
FaucetTransaction,
BroadcastStakingOperationRequest,
Expand Down Expand Up @@ -430,7 +429,11 @@ export type StakeAPIClient = {
* @param options - Axios request options.
*/
fetchHistoricalStakingBalances(
FetchHistoricalStakingBalancesRequest: FetchHistoricalStakingBalancesRequest,
address: string,
networkId: string,
assetId: string,
startTime: string,
endTime: string,
limit?: number,
page?: string,
options?: AxiosRequestConfig,
Expand Down
24 changes: 10 additions & 14 deletions src/tests/staking_historical_balance_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ describe("StakingBalance", () => {
expect(response).toBeInstanceOf(Array<StakingBalance>);
expect(response.length).toEqual(2);
expect(Coinbase.apiClients.stake!.fetchHistoricalStakingBalances).toHaveBeenCalledWith(
{
network_id: address.getNetworkId(),
asset_id: Coinbase.assets.Eth,
address: address.getId(),
start_time: startTime,
end_time: endTime,
},
address.getId(),
address.getNetworkId(),
Coinbase.assets.Eth,
startTime,
endTime,
100,
undefined,
);
Expand All @@ -106,13 +104,11 @@ describe("StakingBalance", () => {
expect(response).toBeInstanceOf(Array<StakingBalance>);
expect(response.length).toEqual(6);
expect(Coinbase.apiClients.stake!.fetchHistoricalStakingBalances).toHaveBeenCalledWith(
{
network_id: address.getNetworkId(),
asset_id: Coinbase.assets.Eth,
address: address.getId(),
start_time: startTime,
end_time: endTime,
},
address.getId(),
address.getNetworkId(),
Coinbase.assets.Eth,
startTime,
endTime,
100,
undefined,
);
Expand Down

0 comments on commit 891a2a0

Please sign in to comment.