Skip to content

Commit

Permalink
feat: 🎸 Added getById feature to the dealsManager
Browse files Browse the repository at this point in the history
  • Loading branch information
kostysh committed Feb 2, 2024
1 parent eeddca1 commit d6687a2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/client/src/dealsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,25 @@ export class ClientDealsManager<
return await this._buildDealRecord(offer);
}

/**
* Returns an up-to-date deal record by offer Id
*
* @param {Hash} id Offer Id
* @returns {Promise<DealRecord<CustomRequestQuery, CustomOfferOptions>>}
* @memberof ClientDealsManager
*/
async getById(
id: Hash,
): Promise<DealRecord<CustomRequestQuery, CustomOfferOptions>> {
const deal = this.deals.get(id);

if (!deal) {
throw new Error(`Deal with offer Id: ${id} not found!`);
}

return await this._buildDealRecord(deal.offer);
}

/**
* Returns all an up-to-date deal records
*
Expand Down

0 comments on commit d6687a2

Please sign in to comment.