eclesiar-sdk 1.0.4 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -4
- package/src/api/accounts/getAccount.ts +9 -0
- package/src/api/accounts/getMyEquipment.ts +9 -0
- package/{dist/api/accounts/index.d.ts → src/api/accounts/index.ts} +10 -2
- package/src/api/accounts/types.ts +6 -0
- package/src/api/countries/getCountries.ts +7 -0
- package/src/api/countries/getCountryRegions.ts +13 -0
- package/{dist/api/countries/index.d.ts → src/api/countries/index.ts} +10 -2
- package/src/api/countries/types.ts +6 -0
- package/{dist/api/index.d.ts → src/api/index.ts} +2 -1
- package/src/api/market/getAuctionBid.ts +14 -0
- package/src/api/market/getAuctions.ts +13 -0
- package/src/api/market/getCoinOffers.ts +20 -0
- package/src/api/market/getItemOffers.ts +20 -0
- package/src/api/market/getJobs.ts +19 -0
- package/{dist/api/market/index.js → src/api/market/index.ts} +13 -3
- package/src/api/market/types.ts +9 -0
- package/src/api/server/getEquipments.ts +9 -0
- package/src/api/server/getItems.ts +9 -0
- package/src/api/server/getStatus.ts +6 -0
- package/{dist/api/server/index.d.ts → src/api/server/index.ts} +12 -2
- package/src/api/server/types.ts +6 -0
- package/src/api/statistics/getStatistics.ts +14 -0
- package/{dist/api/statistics/index.d.ts → src/api/statistics/index.ts} +9 -2
- package/src/api/statistics/types.ts +5 -0
- package/src/api/wars/getWarRoundHits.ts +19 -0
- package/src/api/wars/getWarRounds.ts +11 -0
- package/src/api/wars/getWars.ts +22 -0
- package/{dist/api/wars/index.d.ts → src/api/wars/index.ts} +13 -2
- package/src/api/wars/types.ts +7 -0
- package/src/client.ts +68 -0
- package/src/index.ts +10 -0
- package/{dist/types/accounts.d.ts → src/types/accounts.ts} +4 -3
- package/{dist/types/country.d.ts → src/types/country.ts} +15 -11
- package/src/types/index.ts +6 -0
- package/src/types/market.ts +57 -0
- package/{dist/types/server.d.ts → src/types/server.ts} +7 -5
- package/src/types/statistics.ts +25 -0
- package/src/types/wars.ts +59 -0
- package/tsconfig.json +18 -0
- package/dist/api/accounts/getAccount.d.ts +0 -4
- package/dist/api/accounts/getAccount.js +0 -5
- package/dist/api/accounts/getMyEquipment.d.ts +0 -4
- package/dist/api/accounts/getMyEquipment.js +0 -5
- package/dist/api/accounts/index.js +0 -7
- package/dist/api/accounts/types.d.ts +0 -7
- package/dist/api/accounts/types.js +0 -1
- package/dist/api/countries/getCountries.d.ts +0 -2
- package/dist/api/countries/getCountries.js +0 -4
- package/dist/api/countries/getCountryRegions.d.ts +0 -6
- package/dist/api/countries/getCountryRegions.js +0 -5
- package/dist/api/countries/index.js +0 -7
- package/dist/api/countries/types.d.ts +0 -7
- package/dist/api/countries/types.js +0 -1
- package/dist/api/index.js +0 -6
- package/dist/api/market/getAuctionBid.d.ts +0 -5
- package/dist/api/market/getAuctionBid.js +0 -8
- package/dist/api/market/getAuctions.d.ts +0 -5
- package/dist/api/market/getAuctions.js +0 -8
- package/dist/api/market/getCoinOffers.d.ts +0 -6
- package/dist/api/market/getCoinOffers.js +0 -9
- package/dist/api/market/getItemOffers.d.ts +0 -6
- package/dist/api/market/getItemOffers.js +0 -9
- package/dist/api/market/getJobs.d.ts +0 -7
- package/dist/api/market/getJobs.js +0 -8
- package/dist/api/market/index.d.ts +0 -9
- package/dist/api/market/types.d.ts +0 -25
- package/dist/api/market/types.js +0 -1
- package/dist/api/server/getEquipments.d.ts +0 -4
- package/dist/api/server/getEquipments.js +0 -5
- package/dist/api/server/getItems.d.ts +0 -4
- package/dist/api/server/getItems.js +0 -5
- package/dist/api/server/getStatus.d.ts +0 -2
- package/dist/api/server/getStatus.js +0 -4
- package/dist/api/server/index.js +0 -9
- package/dist/api/server/types.d.ts +0 -10
- package/dist/api/server/types.js +0 -1
- package/dist/api/statistics/getStatistics.d.ts +0 -6
- package/dist/api/statistics/getStatistics.js +0 -5
- package/dist/api/statistics/index.js +0 -5
- package/dist/api/statistics/types.d.ts +0 -6
- package/dist/api/statistics/types.js +0 -1
- package/dist/api/wars/getWarRoundHits.d.ts +0 -7
- package/dist/api/wars/getWarRoundHits.js +0 -8
- package/dist/api/wars/getWarRounds.d.ts +0 -6
- package/dist/api/wars/getWarRounds.js +0 -5
- package/dist/api/wars/getWars.d.ts +0 -8
- package/dist/api/wars/getWars.js +0 -9
- package/dist/api/wars/index.js +0 -9
- package/dist/api/wars/types.d.ts +0 -10
- package/dist/api/wars/types.js +0 -1
- package/dist/client.d.ts +0 -17
- package/dist/client.js +0 -33
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -1
- package/dist/types/accounts.js +0 -1
- package/dist/types/country.js +0 -1
- package/dist/types/index.d.ts +0 -6
- package/dist/types/index.js +0 -6
- package/dist/types/market.d.ts +0 -52
- package/dist/types/market.js +0 -1
- package/dist/types/server.js +0 -1
- package/dist/types/statistics.d.ts +0 -10
- package/dist/types/statistics.js +0 -1
- package/dist/types/wars.d.ts +0 -45
- package/dist/types/wars.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eclesiar-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"type": "module",
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
16
|
"scripts": {
|
|
20
17
|
"build": "tsc --declaration --outDir dist --moduleResolution node && tsc-alias"
|
|
21
18
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { AccountData } from "@/types/accounts";
|
|
3
|
+
|
|
4
|
+
export async function getAccount({
|
|
5
|
+
account_id
|
|
6
|
+
}: { account_id: number }): Promise<AccountData>{
|
|
7
|
+
const params = new URLSearchParams({ account_id: String(account_id) });
|
|
8
|
+
return apiFetch<AccountData>(`/account?${params.toString()}`)
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { EquipmentItem } from "@/types/accounts";
|
|
3
|
+
|
|
4
|
+
export async function getMyEquipment({
|
|
5
|
+
page = 1
|
|
6
|
+
}: { page?: number } = {}): Promise<EquipmentItem[]>{
|
|
7
|
+
const params = new URLSearchParams({ page: String(page) });
|
|
8
|
+
return apiFetch<EquipmentItem[]>(`/account/mine/equipments?${params.toString()}`)
|
|
9
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { getAccount } from './getAccount';
|
|
2
2
|
import { getMyEquipment } from './getMyEquipment';
|
|
3
|
+
|
|
3
4
|
import type { AccountsApi } from './types';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
export const accountsApi: AccountsApi = {
|
|
7
|
+
getAccount,
|
|
8
|
+
getMyEquipment,
|
|
9
|
+
}
|
|
5
10
|
export type { AccountsApi };
|
|
6
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
getAccount,
|
|
13
|
+
getMyEquipment,
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { Region } from "@/types/country";
|
|
3
|
+
|
|
4
|
+
type GetCountryRegionsParams = {
|
|
5
|
+
country_id: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export async function getCountryRegions({
|
|
9
|
+
country_id
|
|
10
|
+
}: GetCountryRegionsParams): Promise<Region[]>{
|
|
11
|
+
const params = new URLSearchParams({ country_id: String(country_id) });
|
|
12
|
+
return apiFetch<Region[]>(`/country/regions?${params.toString()}`)
|
|
13
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { getCountries } from './getCountries';
|
|
2
2
|
import { getCountryRegions } from './getCountryRegions';
|
|
3
|
+
|
|
3
4
|
import type { CountriesApi } from './types';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
export const countriesApi: CountriesApi = {
|
|
7
|
+
getCountries,
|
|
8
|
+
getCountryRegions,
|
|
9
|
+
}
|
|
5
10
|
export type { CountriesApi };
|
|
6
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
getCountries,
|
|
13
|
+
getCountryRegions,
|
|
14
|
+
}
|
|
@@ -4,9 +4,10 @@ export { marketApi as market } from './market';
|
|
|
4
4
|
export { serverApi as server } from './server';
|
|
5
5
|
export { statisticsApi as statistics } from './statistics';
|
|
6
6
|
export { warsApi as wars } from './wars';
|
|
7
|
+
|
|
7
8
|
export type { AccountsApi } from './accounts/types';
|
|
8
9
|
export type { CountriesApi } from './countries/types';
|
|
9
10
|
export type { MarketApi } from './market/types';
|
|
10
11
|
export type { ServerApi } from './server/types';
|
|
11
12
|
export type { StatisticsApi } from './statistics/types';
|
|
12
|
-
export type { WarsApi } from './wars/types';
|
|
13
|
+
export type { WarsApi } from './wars/types';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { MarketAuctionBid } from "@/types/market";
|
|
3
|
+
|
|
4
|
+
export async function getAuctionBid({
|
|
5
|
+
auction_id,
|
|
6
|
+
page = 1,
|
|
7
|
+
}: { auction_id: number; page?: number }): Promise<MarketAuctionBid[]> {
|
|
8
|
+
const params = new URLSearchParams({
|
|
9
|
+
auction_id: String(auction_id),
|
|
10
|
+
page: String(page),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return apiFetch<MarketAuctionBid[]>(`/market/auction/bids/get?${params.toString()}`);
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { MarketAuction } from "@/types/market";
|
|
3
|
+
|
|
4
|
+
export async function getAuctions({
|
|
5
|
+
finished = 0,
|
|
6
|
+
page = 1,
|
|
7
|
+
}: { finished?: 0 | 1; page?: number } = {}): Promise<MarketAuction[]> {
|
|
8
|
+
const params = new URLSearchParams({
|
|
9
|
+
finished: finished.toString(),
|
|
10
|
+
page: page.toString(),
|
|
11
|
+
});
|
|
12
|
+
return apiFetch<MarketAuction[]>(`/market/auctions/get?${params.toString()}`);
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { apiFetch } from '@/client';
|
|
2
|
+
import { MarketCoinOffer } from '@/types/market';
|
|
3
|
+
|
|
4
|
+
export async function getCoinOffers({
|
|
5
|
+
currency_id,
|
|
6
|
+
transaction = 'BUY',
|
|
7
|
+
page = 1,
|
|
8
|
+
}: {
|
|
9
|
+
currency_id: number;
|
|
10
|
+
transaction?: 'BUY' | 'SELL';
|
|
11
|
+
page?: number;
|
|
12
|
+
}): Promise<MarketCoinOffer[]> {
|
|
13
|
+
const query = new URLSearchParams({
|
|
14
|
+
currency_id: String(currency_id),
|
|
15
|
+
transaction: String(transaction),
|
|
16
|
+
page: String(page),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return apiFetch<MarketCoinOffer[]>(`/market/coin/get?${query}`);
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { apiFetch } from '@/client';
|
|
2
|
+
import { MarketItemOffer } from '@/types/market';
|
|
3
|
+
|
|
4
|
+
export async function getItemOffers({
|
|
5
|
+
country_id,
|
|
6
|
+
item_id,
|
|
7
|
+
page = 1,
|
|
8
|
+
}: {
|
|
9
|
+
country_id: number;
|
|
10
|
+
item_id: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
}): Promise<MarketItemOffer[]> {
|
|
13
|
+
const query = new URLSearchParams({
|
|
14
|
+
country_id: String(country_id),
|
|
15
|
+
item_id: String(item_id),
|
|
16
|
+
page: String(page),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return apiFetch<MarketItemOffer[]>(`/market/items/get?${query}`);
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { MarketJobOffer } from "@/types/market";
|
|
3
|
+
|
|
4
|
+
type GetJobsParams = {
|
|
5
|
+
country_id: number;
|
|
6
|
+
page?: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function getJobs({
|
|
10
|
+
country_id,
|
|
11
|
+
page = 1,
|
|
12
|
+
}: GetJobsParams): Promise<MarketJobOffer[]> {
|
|
13
|
+
const query = new URLSearchParams({
|
|
14
|
+
country_id: String(country_id),
|
|
15
|
+
page: String(page),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return apiFetch<MarketJobOffer[]>(`/market/jobs/get?${query}`);
|
|
19
|
+
}
|
|
@@ -3,11 +3,21 @@ import { getItemOffers } from './getItemOffers';
|
|
|
3
3
|
import { getJobs } from './getJobs';
|
|
4
4
|
import { getAuctions } from './getAuctions';
|
|
5
5
|
import { getAuctionBid } from './getAuctionBid';
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import type { MarketApi } from './types';
|
|
8
|
+
|
|
9
|
+
export const marketApi: MarketApi = {
|
|
7
10
|
getCoinOffers,
|
|
8
11
|
getItemOffers,
|
|
9
12
|
getJobs,
|
|
10
13
|
getAuctions,
|
|
11
14
|
getAuctionBid,
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
15
|
+
}
|
|
16
|
+
export type { MarketApi };
|
|
17
|
+
export {
|
|
18
|
+
getCoinOffers,
|
|
19
|
+
getItemOffers,
|
|
20
|
+
getJobs,
|
|
21
|
+
getAuctions,
|
|
22
|
+
getAuctionBid,
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MarketAuction, MarketAuctionBid, MarketCoinOffer, MarketItemOffer, MarketJobOffer } from "@/types";
|
|
2
|
+
|
|
3
|
+
export interface MarketApi {
|
|
4
|
+
getCoinOffers({ currency_id, transaction, page }: { currency_id: number, transaction: 'BUY' | 'SELL', page?: number }): Promise<MarketCoinOffer[]>;
|
|
5
|
+
getItemOffers({ country_id, item_id, page }: { country_id: number, item_id: number, page?: number }): Promise<MarketItemOffer[]>;
|
|
6
|
+
getJobs({ country_id, page }: { country_id: number, page?: number }): Promise<MarketJobOffer[]>;
|
|
7
|
+
getAuctions({ finished, page }: { finished?: 0 | 1, page?: number }): Promise<MarketAuction[]>;
|
|
8
|
+
getAuctionBid({ auction_id, page }: { auction_id: number, page?: number }): Promise<MarketAuctionBid[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { ServerEquipment } from "@/types/server";
|
|
3
|
+
|
|
4
|
+
export async function getServerEquipments(
|
|
5
|
+
{ page = 1 }: { page?: number } = {}
|
|
6
|
+
): Promise<ServerEquipment[]> {
|
|
7
|
+
const params = new URLSearchParams({ page: String(page) });
|
|
8
|
+
return apiFetch<ServerEquipment[]>(`/server/equipments?${params}`);
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { ServerItem } from "@/types/server";
|
|
3
|
+
|
|
4
|
+
export async function getServerItems(
|
|
5
|
+
{ page = 1 }: { page?: number } = {}
|
|
6
|
+
): Promise<ServerItem[]> {
|
|
7
|
+
const params = new URLSearchParams({ page: String(page) });
|
|
8
|
+
return apiFetch<ServerItem[]>(`/server/items?${params}`);
|
|
9
|
+
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { getServerStatus } from './getStatus';
|
|
2
2
|
import { getServerItems } from './getItems';
|
|
3
3
|
import { getServerEquipments } from './getEquipments';
|
|
4
|
+
|
|
4
5
|
import type { ServerApi } from './types';
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
export const serverApi: ServerApi = {
|
|
8
|
+
getServerStatus,
|
|
9
|
+
getServerItems,
|
|
10
|
+
getServerEquipments,
|
|
11
|
+
};
|
|
6
12
|
export type { ServerApi };
|
|
7
|
-
export {
|
|
13
|
+
export {
|
|
14
|
+
getServerStatus,
|
|
15
|
+
getServerItems,
|
|
16
|
+
getServerEquipments,
|
|
17
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServerEquipment, ServerItem, ServerStatus } from "@/types/server";
|
|
2
|
+
export interface ServerApi {
|
|
3
|
+
getServerStatus(): Promise<ServerStatus[]>;
|
|
4
|
+
getServerItems({ page }: { page?: number }): Promise<ServerItem[]>;
|
|
5
|
+
getServerEquipments({ page }: { page?: number }): Promise<ServerEquipment[]>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { CountryStatisticType, RankingItem } from "@/types/statistics";
|
|
3
|
+
|
|
4
|
+
type GetStatisticsParams = {
|
|
5
|
+
statistic: CountryStatisticType;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export async function getStatistics({
|
|
9
|
+
statistic,
|
|
10
|
+
}: GetStatisticsParams): Promise<RankingItem[]> {
|
|
11
|
+
const query = new URLSearchParams({ statistic });
|
|
12
|
+
|
|
13
|
+
return apiFetch<RankingItem[]>(`/statistics/country?${query}`);
|
|
14
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { getStatistics } from './getStatistics';
|
|
2
|
+
|
|
2
3
|
import type { StatisticsApi } from './types';
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
export const statisticsApi: StatisticsApi = {
|
|
6
|
+
getStatistics,
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
export type { StatisticsApi };
|
|
5
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
getStatistics,
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { WarHit } from "@/types/wars";
|
|
3
|
+
|
|
4
|
+
type GetWarRoundHitsParams = {
|
|
5
|
+
war_round_id: number;
|
|
6
|
+
page?: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function getWarRoundHits({
|
|
10
|
+
war_round_id,
|
|
11
|
+
page = 1,
|
|
12
|
+
}: GetWarRoundHitsParams): Promise<WarHit[]> {
|
|
13
|
+
const query = new URLSearchParams({
|
|
14
|
+
war_round_id: String(war_round_id),
|
|
15
|
+
page: String(page),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return apiFetch<WarHit[]>(`/war/round/hits?${query}`);
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { WarRound } from "@/types/wars";
|
|
3
|
+
|
|
4
|
+
type GetWarRoundsParams = {
|
|
5
|
+
war_id: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export async function getWarRounds({ war_id }: GetWarRoundsParams): Promise<WarRound[]> {
|
|
9
|
+
const query = new URLSearchParams({ war_id: String(war_id) });
|
|
10
|
+
return apiFetch<WarRound[]>(`/war/rounds?${query}`);
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { apiFetch } from "@/client";
|
|
2
|
+
import { GetWarsParams, War } from "@/types/wars";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export async function getWars({
|
|
7
|
+
event_wars = 0,
|
|
8
|
+
extra_details = 0,
|
|
9
|
+
war_id = 0,
|
|
10
|
+
expired = 0,
|
|
11
|
+
page = 1,
|
|
12
|
+
}: GetWarsParams = {}): Promise<War[]> {
|
|
13
|
+
const query = new URLSearchParams({
|
|
14
|
+
event_wars: String(event_wars),
|
|
15
|
+
extra_details: String(extra_details),
|
|
16
|
+
war_id: String(war_id),
|
|
17
|
+
expired: String(expired),
|
|
18
|
+
page: String(page)
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return apiFetch<War[]>(`/wars?${query}`);
|
|
22
|
+
}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { getWars } from './getWars';
|
|
2
2
|
import { getWarRounds } from './getWarRounds';
|
|
3
3
|
import { getWarRoundHits } from './getWarRoundHits';
|
|
4
|
+
|
|
4
5
|
import type { WarsApi } from './types';
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
export const warsApi: WarsApi = {
|
|
8
|
+
getWars,
|
|
9
|
+
getWarRounds,
|
|
10
|
+
getWarRoundHits,
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
export type { WarsApi };
|
|
7
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
getWars,
|
|
16
|
+
getWarRounds,
|
|
17
|
+
getWarRoundHits,
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WarRound, WarHit, War, GetWarsParams } from "@/types";
|
|
2
|
+
|
|
3
|
+
export interface WarsApi {
|
|
4
|
+
getWars(params: GetWarsParams): Promise<War[]>;
|
|
5
|
+
getWarRounds({ war_id }: { war_id: number }): Promise<WarRound[]>;
|
|
6
|
+
getWarRoundHits({ war_round_id }: { war_round_id: number }): Promise<WarHit[]>;
|
|
7
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { accountsApi } from './api/accounts';
|
|
2
|
+
import { countriesApi } from './api/countries';
|
|
3
|
+
import { marketApi } from './api/market';
|
|
4
|
+
import { serverApi } from './api/server';
|
|
5
|
+
import { statisticsApi } from './api/statistics';
|
|
6
|
+
import { warsApi } from './api/wars';
|
|
7
|
+
|
|
8
|
+
import type { AccountsApi } from './api/accounts/types';
|
|
9
|
+
import type { CountriesApi } from './api/countries/types';
|
|
10
|
+
import type { MarketApi } from './api/market/types';
|
|
11
|
+
import type { ServerApi } from './api/server/types';
|
|
12
|
+
import type { StatisticsApi } from './api/statistics/types';
|
|
13
|
+
import type { WarsApi } from './api/wars/types';
|
|
14
|
+
|
|
15
|
+
type ApiResponse<T> = {
|
|
16
|
+
code: number;
|
|
17
|
+
description: string;
|
|
18
|
+
data: T;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const BASE_URL = 'https://api.eclesiar.com';
|
|
22
|
+
|
|
23
|
+
let token = '';
|
|
24
|
+
|
|
25
|
+
export function setToken(newToken: string) {
|
|
26
|
+
token = newToken;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function apiFetch<T>(
|
|
30
|
+
endpoint: string,
|
|
31
|
+
options: RequestInit = {}
|
|
32
|
+
): Promise<T> {
|
|
33
|
+
const res = await fetch(`${BASE_URL}${endpoint}`, {
|
|
34
|
+
...options,
|
|
35
|
+
headers: {
|
|
36
|
+
Authorization: `Bearer ${token}`,
|
|
37
|
+
...(options.headers || {}),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (!res.ok) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`API Error: ${res.status} ${res.statusText} ${endpoint}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const json: ApiResponse<T> = await res.json();
|
|
48
|
+
|
|
49
|
+
return json.data;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface SdkClient {
|
|
53
|
+
accounts: AccountsApi;
|
|
54
|
+
countries: CountriesApi;
|
|
55
|
+
market: MarketApi;
|
|
56
|
+
server: ServerApi;
|
|
57
|
+
statistics: StatisticsApi;
|
|
58
|
+
wars: WarsApi;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const apiClient: SdkClient = {
|
|
62
|
+
accounts: accountsApi,
|
|
63
|
+
countries: countriesApi,
|
|
64
|
+
market: marketApi,
|
|
65
|
+
server: serverApi,
|
|
66
|
+
statistics: statisticsApi,
|
|
67
|
+
wars: warsApi,
|
|
68
|
+
};
|
package/src/index.ts
ADDED
|
@@ -8,9 +8,10 @@ export type AccountData = {
|
|
|
8
8
|
total_mined_gold: number;
|
|
9
9
|
total_builder_progress: number;
|
|
10
10
|
day_of_birth: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type EquipmentItem = {
|
|
13
14
|
id: number;
|
|
14
15
|
equipment_id: number;
|
|
15
16
|
is_equipped: boolean;
|
|
16
|
-
}
|
|
17
|
+
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
export type Currency = {
|
|
2
2
|
id: number;
|
|
3
3
|
name: string;
|
|
4
|
-
symbol: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
4
|
+
symbol: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type Nation = {
|
|
7
8
|
id: number;
|
|
8
9
|
name: string;
|
|
9
10
|
avatar: string;
|
|
10
11
|
currency: Currency;
|
|
11
12
|
is_availible: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RegionBonus {
|
|
16
|
+
type: string;
|
|
15
17
|
value: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type RegionFactories = {
|
|
18
21
|
food: number;
|
|
19
22
|
weapon: number;
|
|
20
23
|
oil: number;
|
|
@@ -23,8 +26,9 @@ export type RegionFactories = {
|
|
|
23
26
|
aircraft: number;
|
|
24
27
|
titanium: number;
|
|
25
28
|
tickets: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type Region = {
|
|
28
32
|
id: number;
|
|
29
33
|
name: string;
|
|
30
34
|
type: number;
|
|
@@ -35,4 +39,4 @@ export type Region = {
|
|
|
35
39
|
pollution: number;
|
|
36
40
|
factories: RegionFactories;
|
|
37
41
|
bonus: RegionBonus[];
|
|
38
|
-
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface ApiResponse<T> {
|
|
2
|
+
code: number;
|
|
3
|
+
description: string;
|
|
4
|
+
data: T;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface MarketCoinOffer {
|
|
8
|
+
amount: number;
|
|
9
|
+
rate: number;
|
|
10
|
+
owner: {
|
|
11
|
+
id: number;
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface MarketItemOffer {
|
|
17
|
+
amount: number;
|
|
18
|
+
rate: number;
|
|
19
|
+
owner: {
|
|
20
|
+
id: number;
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface MarketJobOffer {
|
|
26
|
+
value: number;
|
|
27
|
+
amount: number;
|
|
28
|
+
economic_skill: number;
|
|
29
|
+
currency_id: number;
|
|
30
|
+
business_id: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface MarketAuction {
|
|
34
|
+
id: number;
|
|
35
|
+
item: {
|
|
36
|
+
id: number;
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
owner: {
|
|
40
|
+
id: number;
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
initial_bid: number;
|
|
44
|
+
created_at: string;
|
|
45
|
+
end_at: string;
|
|
46
|
+
status: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface MarketAuctionBid {
|
|
50
|
+
id: number;
|
|
51
|
+
bid: number;
|
|
52
|
+
created_at: string;
|
|
53
|
+
owner: {
|
|
54
|
+
id: number;
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
}
|