prebid-server icon indicating copy to clipboard operation
prebid-server copied to clipboard

Consider making constants for currencies

Open scr-oath opened this issue 11 months ago • 2 comments

I see "USD" in many places… there may be others… we should consider what the strategy is for enum-like constants and use it for this.

I personally like https://github.com/abice/go-enum as a generated enum, which has json/yaml marshaling and the ability to add your own template additions from the structured awareness of the enum metadata.

  • See https://github.com/prebid/prebid-server/pull/4076#discussion_r1905973463

scr-oath avatar Jan 07 '25 19:01 scr-oath

Interesting idea @scr-oath . We discussed in committee but we're thinking that since USD is the only currency mentioned in the codebase it doesn't make sense to add an enum for any more. And there's concern about the switching back and forth of enums to strings for currencies.

Any followup thoughts?

bretg avatar Jan 10 '25 15:01 bretg

USD is used by many bidders, or they internally convert non-USD to $. No extra package is needed. The string 'USD' can be defined as a constant in the internal PBS package, and other modules can import it

linux019 avatar Apr 09 '25 17:04 linux019

There is no clear benefit from doing this apart from cleaner code, but there will be an issue that newly submitted bidder adapters might continue to use old style. Which will create a split in codebase style.

But generally if someone from the community want to implement this, both Go and Java will be glad to aссept the submission.

Net-burst avatar May 30 '25 14:05 Net-burst