Skip to content

Force usage of native specs when required #46

Open
@valdo404

Description

@valdo404

Dsps should forcibly reply native responses when requests contains native request.

hence the following code should be using the bid request to determine if impression is native based.

implicit val admOneOfDecoder: Decoder[SeatBid.Bid.AdmOneof] = { cursor =>
    cursor.focus.map {
      case json if json.isString =>
        json.asString
          .map(s => {
            decode[NativeResponse](s)
              .map(AdmOneof.AdmNative) // the string can be decoded as native
              .getOrElse(AdmOneof.Adm(s)) // the string cannot be decoded
          })
          .getOrElse(AdmOneof.Empty) // there's no string or it's impossible to decode it
      case json if json.isObject =>
        json.as[NativeResponse].map(AdmOneof.AdmNative).getOrElse(AdmOneof.Empty)
    }.orElse(Some(AdmOneof.Empty)).map(Right(_)).get
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions