diff --git a/modules/epomDspBidAdapter.js b/modules/epomDspBidAdapter.js new file mode 100644 index 00000000000..ee4dade4abd --- /dev/null +++ b/modules/epomDspBidAdapter.js @@ -0,0 +1,108 @@ +/** + * @name epomDspBidAdapter + * @version 1.0.0 + * @description Adapter for Epom DSP and AdExchange + * @module modules/epomDspBidAdapter + * @license Open Source - Apache 2.0 + */ + +import { logError, logWarn, registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +const BIDDER_CODE = 'epomDsp'; + +export const spec = { + code: BIDDER_CODE, + + isBidRequestValid(bid) { + const globalSettings = config.getBidderConfig()[BIDDER_CODE]?.epomSettings || {}; + const hasEndpoint = bid.params?.endpoint || globalSettings.endpoint; + return !!(hasEndpoint); + }, + + buildRequests(bidRequests, bidderRequest) { + const bidderConfig = config.getBidderConfig(); + const globalSettings = bidderConfig['epomDsp']?.epomSettings || {}; + + const requests = bidRequests.map((bid) => { + const endpoint = bid.params?.endpoint || globalSettings.endpoint; + const payload = { + ...bid, + referer: bidderRequest?.refererInfo?.referer, + gdprConsent: bidderRequest?.gdprConsent, + uspConsent: bidderRequest?.uspConsent, + }; + delete payload.params; + + return { + method: 'POST', + url: endpoint, + data: JSON.parse(JSON.stringify(payload)), + options: { + contentType: 'application/json', + withCredentials: false, + }, + }; + }); + + return requests.filter((request) => request !== null); + }, + + interpretResponse(serverResponse) { + const bidResponses = []; + const response = serverResponse.body; + + if (response && Array.isArray(response.bids)) { + response.bids.forEach((bid) => { + if (bid.cpm && bid.ad && bid.width && bid.height) { + bidResponses.push({ + requestId: bid.requestId, + cpm: bid.cpm, + currency: bid.currency, + width: bid.width, + height: bid.height, + ad: bid.ad, + creativeId: bid.creativeId || bid.requestId, + ttl: typeof bid.ttl === 'number' ? bid.ttl : 300, + netRevenue: bid.netRevenue !== false, + }); + } else { + logWarn(`[${BIDDER_CODE}] Invalid bid response:`, bid); + } + }); + } else { + logError(`[${BIDDER_CODE}] Empty or invalid server response:`, serverResponse); + } + + return bidResponses; + }, + + getUserSyncs(syncOptions, serverResponses) { + const syncs = []; + + if (syncOptions.iframeEnabled && serverResponses.length > 0) { + serverResponses.forEach((response) => { + if (response.body?.userSync?.iframe) { + syncs.push({ + type: 'iframe', + url: response.body.userSync.iframe, + }); + } + }); + } + + if (syncOptions.pixelEnabled && serverResponses.length > 0) { + serverResponses.forEach((response) => { + if (response.body?.userSync?.pixel) { + syncs.push({ + type: 'image', + url: response.body.userSync.pixel, + }); + } + }); + } + + return syncs; + }, +}; + +registerBidder(spec); diff --git a/modules/epomDspBidAdapter.md b/modules/epomDspBidAdapter.md new file mode 100644 index 00000000000..29126533b11 --- /dev/null +++ b/modules/epomDspBidAdapter.md @@ -0,0 +1,166 @@ + +# Overview + +``` +Module Name: Epom DSP Bid Adapter +Module Type: Bidder Adapter +Maintainer: support@epom.com +``` + +# Description + +The **Epom DSP Bid Adapter** connects publishers to the Epom DSP Exchange for programmatic advertising. This adapter supports banner formats and follows the OpenRTB protocol. + +# Supported Media Types + +- **Banner** + +--- + +# Integration Guide for Publishers + +## Basic Configuration + +Here is an example configuration for integrating the Epom DSP Bid Adapter into your Prebid.js setup. + +### Sample Banner Ad Unit + +```javascript +var adUnits = [ + { + code: 'epom-banner-div', // Ad slot HTML element ID + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [728, 90] + ] // Banner sizes + } + }, + bids: [ + { + bidder: 'epomDsp', // Adapter code + params: { + endpoint: 'https://your-epom-endpoint.com/bid', // Epom DSP endpoint + }, + adUnitId: 'sampleAdUnitId123', // Unique Ad Unit ID + bidfloor: 0.5, // Minimum bid floor (optional) + } + ] + } +]; +``` + +--- + +# Params + +Below are the parameters that can be configured in the `params` object for the **Epom DSP Bid Adapter**. + +| Parameter | Type | Required | Description | +|----------------|----------|----------|-----------------------------------------------------------------------------| +| `endpoint` | string | Yes | The URL of the Epom DSP bidding endpoint. | +| `adUnitId` | string | No | Unique identifier for the Ad Unit. | +| `bidfloor` | number | No | Minimum CPM value for the bid in USD. | +| `banner` | object | No | Banner-specific parameters like `btype` (ad type) or `pos` (ad position). | + +--- + +# Global Settings (Optional) + +You can define global configuration parameters for the **Epom DSP Bid Adapter** using `pbjs.setBidderConfig`. These settings will apply to all requests made via the adapter. + +### Example Global Configuration + +```javascript +pbjs.setBidderConfig({ + bidders: ['epomDsp'], + config: { + epomSettings: { + endpoint: 'https://your-epom-endpoint.com/bid', // Epom DSP endpoint + } + } +}); +``` + +--- + +# Response Format + +The **Epom DSP Bid Adapter** complies with the OpenRTB protocol and returns responses in the following format: + +```json +{ + "bids": [ + { + "requestId": "uniqueRequestId", + "cpm": 1.5, + "currency": "USD", + "width": 300, + "height": 250, + "ad": "