updates to concierge bot to support adding services and routes
This commit is contained in:
@@ -2,6 +2,13 @@ import { ESI_SCOPE } from '../oauth/auth.types';
|
||||
import { ESI_RATE_LIMIT_GROUP } from './util/rate-limits';
|
||||
import { checkScopesAndGetCharacterId, esiFetch, type EsiOptions, type PublicEsiOptions } from './util/fetch';
|
||||
|
||||
export enum ContractType {
|
||||
ITEM_EXCHANGE = 'item_exchange',
|
||||
AUCTION = 'auction',
|
||||
COURIER = 'courier',
|
||||
LOAN = 'loan',
|
||||
}
|
||||
|
||||
export interface PublicContract {
|
||||
buyout?: number;
|
||||
collateral?: number;
|
||||
@@ -21,10 +28,29 @@ export interface PublicContract {
|
||||
volume?: number;
|
||||
}
|
||||
|
||||
export enum ContractAvailability {
|
||||
PUBLIC = 'public',
|
||||
PERSONAL = 'personal',
|
||||
CORPORATION = 'corporation',
|
||||
ALLIANCE = 'alliance',
|
||||
}
|
||||
|
||||
export enum ContractStatus {
|
||||
OUTSTANDING = 'outstanding',
|
||||
IN_PROGRESS = 'in_progress',
|
||||
FINISHED_ISSUER = 'finished_issuer',
|
||||
FINISHED_CONTRACTOR = 'finished_contractor',
|
||||
CANCELLED = 'cancelled',
|
||||
REJECTED = 'rejected',
|
||||
FAILED = 'failed',
|
||||
DELETED = 'deleted',
|
||||
REVERSED = 'reversed',
|
||||
}
|
||||
|
||||
export interface Contract extends PublicContract {
|
||||
acceptor_id: number;
|
||||
assignee_id: number;
|
||||
availability: 'public' | 'personal' | 'corporation' | 'alliance';
|
||||
availability: ContractAvailability;
|
||||
date_accepted?: string;
|
||||
date_completed?: string;
|
||||
status:
|
||||
@@ -43,7 +69,7 @@ export interface Contract extends PublicContract {
|
||||
* Returns contracts available to a character, only if the character is issuer, acceptor or assignee.
|
||||
* Only returns contracts no older than 30 days, or if the status is "in_progress".
|
||||
*/
|
||||
export function getCharacterContracts(options: EsiOptions, page: number = 1) {
|
||||
export function getCharacterContracts(options: EsiOptions, page: number = 1): Promise<Contract[]> {
|
||||
const character_id = checkScopesAndGetCharacterId(options, ESI_SCOPE['esi-contracts.read_character_contracts.v1']);
|
||||
return esiFetch<Contract[]>(`/characters/${character_id}/contracts/?page=${page}`, {
|
||||
...options,
|
||||
@@ -61,7 +87,7 @@ export interface ContractBid extends PublicContractBid {
|
||||
bidder_id: number;
|
||||
}
|
||||
|
||||
export function getContractBids(options: EsiOptions, contract_id: number) {
|
||||
export function getContractBids(options: EsiOptions, contract_id: number): Promise<ContractBid[]> {
|
||||
const character_id = checkScopesAndGetCharacterId(options, ESI_SCOPE['esi-contracts.read_character_contracts.v1']);
|
||||
return esiFetch<ContractBid[]>(`/characters/${character_id}/contracts/${contract_id}/bids/`, {
|
||||
...options,
|
||||
@@ -78,7 +104,7 @@ export interface ContractItem {
|
||||
type_id: number; // type ID of the item
|
||||
}
|
||||
|
||||
export function getContractItems(options: EsiOptions, contract_id: number) {
|
||||
export function getContractItems(options: EsiOptions, contract_id: number): Promise<ContractItem[]> {
|
||||
const character_id = checkScopesAndGetCharacterId(options, ESI_SCOPE['esi-contracts.read_character_contracts.v1']);
|
||||
return esiFetch<ContractItem[]>(`/characters/${character_id}/contracts/${contract_id}/items/`, {
|
||||
...options,
|
||||
@@ -86,7 +112,7 @@ export function getContractItems(options: EsiOptions, contract_id: number) {
|
||||
});
|
||||
}
|
||||
|
||||
export function getPublicContractBids(contract_id: number, page: number = 1, options?: PublicEsiOptions) {
|
||||
export function getPublicContractBids(contract_id: number, page: number = 1, options?: PublicEsiOptions): Promise<PublicContractBid[]> {
|
||||
return esiFetch<PublicContractBid[]>(`/contracts/public/bids/${contract_id}?page=${page}`, options);
|
||||
}
|
||||
|
||||
@@ -102,15 +128,15 @@ export interface PublicContractItem {
|
||||
type_id: number; // type ID of the item
|
||||
}
|
||||
|
||||
export function getPublicContractItems(contract_id: number, page: number = 1, options?: PublicEsiOptions) {
|
||||
export function getPublicContractItems(contract_id: number, page: number = 1, options?: PublicEsiOptions): Promise<PublicContractItem[]> {
|
||||
return esiFetch<PublicContractItem[]>(`/contracts/public/items/${contract_id}?page=${page}`, options);
|
||||
}
|
||||
|
||||
export function getPublicContracts(region_id: number, page: number = 1, options?: PublicEsiOptions) {
|
||||
export function getPublicContracts(region_id: number, page: number = 1, options?: PublicEsiOptions): Promise<PublicContract[]> {
|
||||
return esiFetch<PublicContract[]>(`/contracts/public/${region_id}?page=${page}`, options);
|
||||
}
|
||||
|
||||
export function getCorporationContracts(options: EsiOptions, corporation_id: number, page: number = 1) {
|
||||
export function getCorporationContracts(options: EsiOptions, corporation_id: number, page: number = 1): Promise<Contract[]> {
|
||||
const character_id = checkScopesAndGetCharacterId(options, ESI_SCOPE['esi-contracts.read_corporation_contracts.v1']);
|
||||
return esiFetch<Contract[]>(`/corporations/${corporation_id}/contracts/?page=${page}`, {
|
||||
...options,
|
||||
@@ -118,7 +144,7 @@ export function getCorporationContracts(options: EsiOptions, corporation_id: num
|
||||
});
|
||||
}
|
||||
|
||||
export function getCorporationContractBids(options: EsiOptions, corporation_id: number, contract_id: number) {
|
||||
export function getCorporationContractBids(options: EsiOptions, corporation_id: number, contract_id: number): Promise<ContractBid[]> {
|
||||
const character_id = checkScopesAndGetCharacterId(options, ESI_SCOPE['esi-contracts.read_corporation_contracts.v1']);
|
||||
return esiFetch<ContractBid[]>(`/corporations/${corporation_id}/contracts/${contract_id}/bids/`, {
|
||||
...options,
|
||||
@@ -126,7 +152,7 @@ export function getCorporationContractBids(options: EsiOptions, corporation_id:
|
||||
});
|
||||
}
|
||||
|
||||
export function getCorporationContractItems(options: EsiOptions, corporation_id: number, contract_id: number) {
|
||||
export function getCorporationContractItems(options: EsiOptions, corporation_id: number, contract_id: number): Promise<ContractItem[]> {
|
||||
const character_id = checkScopesAndGetCharacterId(options, ESI_SCOPE['esi-contracts.read_corporation_contracts.v1']);
|
||||
return esiFetch<ContractItem[]>(`/corporations/${corporation_id}/contracts/${contract_id}/items/`, {
|
||||
...options,
|
||||
|
||||
Reference in New Issue
Block a user