Skip to content

Commit

Permalink
Merge pull request #16 from aukgit/develop
Browse files Browse the repository at this point in the history
# Static bidding POC + Database updates
- [x] Static Bid Response Serving Properly (POC)
- [x] POC tested in DemandSidePlatformSimulatorServiceApiController for static bidding
- [x] Database updated as per impression place holder. 
   - [x] Dimensions (Height/Width)  removed from BidRequest to ImpressionPlaceHolder.
   - [x] Create relationship with impression with impressionPlaceholder(can be banner, video or native) and holds dimensions and request information.
- [x] Improved Extension methods [WIP]

# TODOs
- [ ] Static Bid Requires more improvements
- [ ] More improvements in extensions methods
- [ ] Testing Bidding Static [WIP]
  • Loading branch information
aukgit authored May 28, 2020
2 parents 9c7fb3b + d617509 commit a08861d
Show file tree
Hide file tree
Showing 82 changed files with 2,021 additions and 491 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ import play.api.mvc._
import shared.com.ortb.controllers.core.AbstractBaseSimulatorServiceApiController
import shared.com.ortb.manager.AppManager
import shared.com.ortb.model.config._
import shared.com.ortb.persistent.Repositories
import shared.io.helpers.{ FileHelper, JsonHelper }
import shared.io.loggers._

class RequestSimulatorServiceApiController @Inject()(
repositories : Repositories,
appManager : AppManager,
components : ControllerComponents)
extends AbstractBaseSimulatorServiceApiController(repositories, appManager, components) {
extends AbstractBaseSimulatorServiceApiController(appManager, components) {

lazy val currentServiceModel : ServiceModel = services.requestSimulatorService
lazy val jsonDirectory = "jsonRequestSamples"

def getAvailableCommands : Action[AnyContent] = Action { implicit request =>
try {
val jsonString = JsonHelper.toJson(selfProperties.currentServiceModel.routing).get.toString()
selfProperties.restWebApiOkJson.OkJson(jsonString)
selfProperties.restWebApiOkJson.okJson(jsonString)
} catch {
case e : Exception =>
AppLogger.error(e)
Expand All @@ -36,7 +34,7 @@ class RequestSimulatorServiceApiController @Inject()(
"requests",
s"${ bannerSuffix }-bid-request.json")

selfProperties.restWebApiOkJson.OkJson(jsonString)
selfProperties.restWebApiOkJson.okJson(jsonString)
} catch {
case e : Exception =>
AppLogger.error(e)
Expand Down
17 changes: 15 additions & 2 deletions app/shared/com/ortb/constants/AppConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package shared.com.ortb.constants
import shared.com.ortb.manager.AppManager
import shared.com.ortb.persistent.Repositories


object AppConstants {

/**
Expand Down Expand Up @@ -59,7 +60,17 @@ object AppConstants {
/**
* System.lineSeparator
*/
lazy val NewLine : String = System.lineSeparator
lazy val SystemNewLine : String = System.lineSeparator

/**
* '\n'
*/
lazy val NewLine : Char = '\n'

/**
* '\t'
*/
lazy val Tab : Char = '\t'

lazy val DoubleSpace : String = " "

Expand All @@ -80,11 +91,12 @@ object AppConstants {

lazy val DefaultDateTimeFormatPattern = "MM/dd/yyyy HH:mm:ss"
lazy val DefaultDateFormatPattern = "MM/dd/yyyy"
lazy val IsThrownOnFailed = true

/**
* "=${NewLine}"
*/
lazy val LogEqualNewLine : String = s"${ EqualSign }${ NewLine }"
lazy val LogEqualNewLine : String = s"${ EqualSign }${ SystemNewLine }"

/**
* "=${NewLine}${DoubleSpace}"
Expand All @@ -94,4 +106,5 @@ object AppConstants {
lazy val AppManager : AppManager = new AppManager

lazy val Repositories : Repositories = new Repositories(AppManager)
lazy val biddingConstants = new BiddingConstants
}
44 changes: 44 additions & 0 deletions app/shared/com/ortb/constants/BiddingConstants.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package shared.com.ortb.constants

import shared.com.ortb.model.auctionbid.bidresponses.BidModel
import shared.io.extensions.TypeConvertExtensions._

sealed class BiddingConstants {
lazy val aDomains = List(
"Advertiser blocked domains list",
"Sample-Site-blocked.com",
"Sample-Site2-blocked.com",
"Sample-Site3-blocked.com")

lazy val staticBidModel : BidModel = BidModel(
"static:bidId",
"-1",
0,
"static:Advertise Id".toSome,
None,
"adm win-notice markup, optional and should be ignored.".toSome,
aDomains.toSome,
"iurl : uncached image link".toSome,
"static: CampaignId".toSome,
List("static: categoryId1", "static: categoryId2").toSome,
"static: dealId".toSome,
h = None,
w = None
)

/**
* HTTP 204 “No Content” from the bidder (most economical in terms of bandwidth).
*  An empty JSON object: {}
*  A well-formed no bid response: {"id": "1234567890", "seatbid": []}
*  A well-formed no bid response with a reason code: {"id": "1234567890", "seatbid": [], "nbr": 2}
*/
lazy val emptyStaticBidResponse = "{\"id\": \"\", \"seatbid\": []}"

/**
* HTTP 204 “No Content” from the bidder (most economical in terms of bandwidth).
*  An empty JSON object: {}
*  A well-formed no bid response: {"id": "1234567890", "seatbid": []}
*  A well-formed no bid response with a reason code: {"id": "1234567890", "seatbid": [], "nbr": 2}
*/
lazy val emptyStaticBidResponseWithNoBidResponseCodeUnknown = "{\"id\": \"\", \"seatbid\": [], \"nbr\": 0}"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package shared.com.ortb.controllers.core

import shared.com.ortb.controllers.implementations.{ RestWebApiOkJsonImplementation, ServiceControllerPropertiesContractsImplementation }
import shared.com.ortb.controllers.implementations.{ RestWebApiOkImplementation, ServiceControllerPropertiesContractsImplementation }
import shared.com.ortb.controllers.traits.properties.ServiceControllerCorePropertiesContracts
import javax.inject.Inject
import play.api.Logger
Expand All @@ -12,13 +12,12 @@ import shared.com.ortb.persistent.Repositories
import shared.io.loggers.AppLogger

abstract class AbstractBaseSimulatorServiceApiController @Inject()(
repositories : Repositories,
appManager : AppManager,
components : ControllerComponents)
extends ServiceBaseApiController(repositories, appManager, components)
extends ServiceBaseApiController(appManager, components)
with ServiceControllerCorePropertiesContracts {
val currentServiceModel : ServiceModel
lazy override val restWebApiOkJson : RestWebApiOkJsonImplementation = selfProperties.restWebApiOkJson
lazy override val restWebApiOkJson : RestWebApiOkImplementation = selfProperties.restWebApiOkJson
lazy override val serviceTitle : String = currentServiceModel.title
lazy val config : ConfigModel = appManager.config
lazy val services : ServicesModel = config.server.services
Expand All @@ -28,7 +27,7 @@ abstract class AbstractBaseSimulatorServiceApiController @Inject()(

def getServiceName : Action[AnyContent] = Action { implicit request =>
try {
selfProperties.restWebApiOkJson.OkJson(selfProperties.serviceTitle)
selfProperties.restWebApiOkJson.okJson(selfProperties.serviceTitle)
} catch {
case e : Exception =>
handleError(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import shared.com.ortb.model.config.ServiceModel
import shared.com.ortb.persistent.Repositories

class ServiceBaseApiController @Inject()(
val repositories : Repositories,
val appManager : AppManager,
components : ControllerComponents)
extends AbstractController(components)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package shared.com.ortb.controllers.implementations

import akka.util.ByteString
import play.api.http.{ HttpEntity, Status }
import play.api.mvc.{ AbstractController, ResponseHeader, Result }
import play.mvc.Http.MimeTypes
import shared.io.extensions.TypeConvertExtensions._

class RestWebApiOkImplementation(controller : AbstractController) {
def okJson(jsonString : String) : Result = controller.Ok(jsonString).as(MimeTypes.JSON)

lazy val noContent : Result = controller.NoContent.as(MimeTypes.JSON)

def okJsonWithStatus(
jsonString : String,
statusCode : Int = Status.OK,
contentType : String = MimeTypes.JSON
) : Result = okJsonWithHeader(
jsonString,
ResponseHeader(statusCode),
contentType)

def okTextWithStatus(
jsonString : String,
statusCode : Int = Status.OK,
contentType : String = MimeTypes.TEXT
) : Result = okJsonWithHeader(
jsonString,
ResponseHeader(statusCode),
contentType)

def okJsonWithHeader(
jsonString : String,
responseHeader : ResponseHeader = ResponseHeader(Status.OK),
contentType : String = MimeTypes.JSON
) : Result = Result(
header = responseHeader,
body = HttpEntity.Strict(ByteString(jsonString), contentType.toSome)
)

def okHtmlWithStatus(
jsonString : String,
statusCode : Int = Status.OK,
contentType : String = MimeTypes.HTML
) : Result = okJsonWithHeader(
jsonString,
ResponseHeader(statusCode),
contentType)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ServiceControllerPropertiesContractsImplementation
(val serviceBaseApiController : ServiceBaseApiController, val serviceModelInstance : ServiceModel)
extends ServiceControllerCorePropertiesContracts {
EmptyValidateHelper.throwOnNullOrNoneOrNil(serviceModelInstance)
lazy val restWebApiOkJson = new RestWebApiOkJsonImplementation(serviceBaseApiController)
lazy val restWebApiOkJson = new RestWebApiOkImplementation(serviceBaseApiController)
lazy val config : ConfigModel = appManager.config
lazy val serviceTitle : String = serviceModelInstance.title
lazy override val appManager : AppManager = serviceBaseApiController.appManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package shared.com.ortb.controllers.traits.properties

import shared.com.ortb.controllers.implementations.RestWebApiOkJsonImplementation
import shared.com.ortb.controllers.implementations.RestWebApiOkImplementation
import play.api.Logger
import shared.com.ortb.manager.AppManager
import shared.com.ortb.model.config.{ ConfigModel, DemandSidePlatformConfigurationModel, ServiceModel, ServicesModel }
Expand All @@ -12,7 +12,7 @@ trait ServiceControllerCorePropertiesContracts {
val selfProperties : ServiceControllerCorePropertiesContracts
val currentServiceModel : ServiceModel
val appManager : AppManager
val restWebApiOkJson : RestWebApiOkJsonImplementation
val restWebApiOkJson : RestWebApiOkImplementation
val serviceTitle : String
val logger : Logger
val databaseLogger : DatabaseLogTracer
Expand Down
Loading

0 comments on commit a08861d

Please sign in to comment.