Add endpoint client/ragfair/offer/findbyid
This commit is contained in:
parent
1bb2f0e568
commit
cf782a8fcb
@ -13,6 +13,7 @@ import { IExtendOfferRequestData } from "@spt-aki/models/eft/ragfair/IExtendOffe
|
||||
import { IGetItemPriceResult } from "@spt-aki/models/eft/ragfair/IGetItemPriceResult";
|
||||
import { IGetMarketPriceRequestData } from "@spt-aki/models/eft/ragfair/IGetMarketPriceRequestData";
|
||||
import { IGetOffersResult } from "@spt-aki/models/eft/ragfair/IGetOffersResult";
|
||||
import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer";
|
||||
import { IRemoveOfferRequestData } from "@spt-aki/models/eft/ragfair/IRemoveOfferRequestData";
|
||||
import { ISearchRequestData } from "@spt-aki/models/eft/ragfair/ISearchRequestData";
|
||||
import { ISendRagfairReportRequestData } from "@spt-aki/models/eft/ragfair/ISendRagfairReportRequestData";
|
||||
@ -142,4 +143,10 @@ export class RagfairCallbacks implements OnLoad, OnUpdate
|
||||
this.ragfairTaxService.storeClientOfferTaxValue(sessionId, request);
|
||||
return this.httpResponse.nullResponse();
|
||||
}
|
||||
|
||||
/** Handle client/ragfair/offer/findbyid */
|
||||
public getFleaOfferById(url: string, request: any, sessionID: string): IGetBodyResponseData<IRagfairOffer>
|
||||
{
|
||||
return this.httpResponse.getBody(this.ragfairController.getOfferById(sessionID, request));
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import { IExtendOfferRequestData } from "@spt-aki/models/eft/ragfair/IExtendOffe
|
||||
import { IGetItemPriceResult } from "@spt-aki/models/eft/ragfair/IGetItemPriceResult";
|
||||
import { IGetMarketPriceRequestData } from "@spt-aki/models/eft/ragfair/IGetMarketPriceRequestData";
|
||||
import { IGetOffersResult } from "@spt-aki/models/eft/ragfair/IGetOffersResult";
|
||||
import { IGetRagfairOfferByIdRequest } from "@spt-aki/models/eft/ragfair/IGetRagfairOfferByIdRequest";
|
||||
import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer";
|
||||
import { ISearchRequestData } from "@spt-aki/models/eft/ragfair/ISearchRequestData";
|
||||
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
|
||||
@ -147,6 +148,20 @@ export class RagfairController
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client/ragfair/offer/findbyid
|
||||
* @param sessionId Player id
|
||||
* @param request Request data
|
||||
* @returns IRagfairOffer
|
||||
*/
|
||||
public getOfferById(sessionId: string, request: IGetRagfairOfferByIdRequest): IRagfairOffer
|
||||
{
|
||||
const offers = this.ragfairOfferService.getOffers();
|
||||
const offerToReturn = offers.find(x => x.intId === request.id);
|
||||
|
||||
return offerToReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offers for the client based on type of search being performed
|
||||
* @param searchRequest Client search request data
|
||||
|
@ -34,6 +34,9 @@ export class RagfairOfferGenerator
|
||||
protected ragfairConfig: IRagfairConfig;
|
||||
protected allowedFleaPriceItemsForBarter: { tpl: string; price: number; }[];
|
||||
|
||||
/** Internal counter to ensure each offer created has a unique value for its intId property */
|
||||
protected offerCounter = 0;
|
||||
|
||||
constructor(
|
||||
@inject("WinstonLogger") protected logger: ILogger,
|
||||
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||
@ -121,7 +124,7 @@ export class RagfairOfferGenerator
|
||||
|
||||
const offer: IRagfairOffer = {
|
||||
_id: this.hashUtil.generate(),
|
||||
intId: 0,
|
||||
intId: this.offerCounter,
|
||||
user: {
|
||||
id: this.getTraderId(userID),
|
||||
memberType: (userID === "ragfair")
|
||||
@ -149,6 +152,8 @@ export class RagfairOfferGenerator
|
||||
CurrentItemCount: itemCount,
|
||||
};
|
||||
|
||||
this.offerCounter++;
|
||||
|
||||
return offer;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
export interface IGetRagfairOfferByIdRequest
|
||||
{
|
||||
id: number
|
||||
}
|
@ -57,6 +57,14 @@ export class RagfairStaticRouter extends StaticRouter
|
||||
return this.ragfairCallbacks.getFleaPrices(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
new RouteAction(
|
||||
"/client/ragfair/offer/findbyid",
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
(url: string, info: any, sessionID: string, output: string): any =>
|
||||
{
|
||||
return this.ragfairCallbacks.getFleaOfferById(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user