import axios from "axios"; import { IEventModel, ISellerPartnerData } from "@nimee/shared-types"; const port = process.env.PAYMENT_PORT; const basePath = process.env.IS_LOCAL === "true" ? `http://127.0.0.1:${port}` : "http://payment"; const endUserSeasonTicketUrl = `${basePath}/payment/endUserSeasonTicket`; import { ISeasonTicketStatusType } from "@nimee/shared-types"; interface GetEndUserSeasonTicketBySellerAndSeasonTicketParams { marketplaceId: string; sellerId: string; seasonTicketId?: string; jwt: string; status?: string; } export class EndUserSeasonTicketClient { async getEndUserSeasonTicketBySellerAndSeasonTicket(params: { marketplaceId: string; sellerId: string; seasonTicketId?: string; status?: ISeasonTicketStatusType; jwt: string; }) { const { marketplaceId, sellerId, seasonTicketId, status, jwt } = params; const response = await axios.get( `${endUserSeasonTicketUrl}/getBySellerId/${marketplaceId}/${sellerId}?seasonTicketId=${seasonTicketId}${ status ? `&status=${status}` : "" }`, { headers: { jwt }, } ); return response?.data; } // get end user season ticket by endUser id // getByEndUserId: "/payment/endUserSeasonTicket/getByEndUserId/:marketplaceId/:sellerId/:endUserId", async getEndUserSeasonTicketByEndUserId(params: { marketplaceId: string; sellerId: string; endUserId: string; jwt: string }) { const { marketplaceId, sellerId, endUserId, jwt } = params; const response = await axios.get(`${endUserSeasonTicketUrl}/getByEndUserId/${marketplaceId}/${sellerId}/${endUserId}`, { headers: { jwt }, }); return response?.data; } // Soft-delete (flag isDelete=true on) all of an end user's NON-active season-ticket rows. // Used by the end-user soft-delete flow in the user service. Active rows block the delete // upstream, so they are never reached here. Internal call — JWT_ADMIN. async softDeleteSeasonTicketsByEndUser(params: { marketplaceId: string; sellerId: string; endUserId: string; jwt: string; }) { const { marketplaceId, sellerId, endUserId, jwt } = params; const response = await axios.post( `${endUserSeasonTicketUrl}/softDeleteByEndUser/${marketplaceId}/${sellerId}/${endUserId}`, {}, { headers: { jwt } } ); return response?.data; } async getByEndUserId(params: { endUserId: string; jwt: string; shouldPopulateEndUser: boolean; marketplaceId: string; sellerId: string; }) { const { endUserId, jwt, shouldPopulateEndUser, marketplaceId, sellerId } = params; if (shouldPopulateEndUser) { const response = await axios.get( `${endUserSeasonTicketUrl}/getByEndUserIdAndPopulateEndUser/${marketplaceId}/${sellerId}/${endUserId}`, { headers: { jwt, shouldPopulateEndUser }, } ); return response?.data; } else { const response = await axios.get(`${endUserSeasonTicketUrl}/getByEndUserId/${marketplaceId}/${sellerId}/${endUserId}`, { headers: { jwt }, }); return response?.data; } } }